2013.4.6

News 数据库 t1是表

exec sp_help t1 //表属性的查询

exec sp_rename 't1','student1' //表的重命名

exec sp_rename 'sudent1.专业方向','专业' // 字段的重命名

alter table student1

add 性别 varchar(30) //添加新列

alter table student1

alter column 性别 char(1) not null  //更改数据类型

alter table sudent1

drop column 专业  //删除列

drop table student2   // 删除表

truncate table student1 //删除表中所有数据

创建主键约束:

alter table 表名

add constraint pk

primary key clustered(列名)

 

创建外键约束:

alter table 表名 //(创建所在外键的)

add constraint wz

foreign key (列名)

references 表名(列名)//本来是主键的表名

posted on 2013-04-06 13:07  路途中  阅读(172)  评论(0)    收藏  举报