SQL Server 2008 新建\修改表及约束命令
1、创建表命令:
create table 表名
([字段名] [字段类型](长度),
…… [字段名] [字段类型](长度))
2、修改非空约束:
alter table 表名
alter column 字段名 类型 not null
3、创建主键约束:
alter table 表名
add constraint 约束名 Primary key(字段名)
4、创建唯一约束:
alter table 表名
add constraint 约束名 unique(字段名)
5、创建检查约束:
alter table 表名
add constraint 约束名 check(条件)
6、创建默认约束:
alter table 表名
add constraint 约束名 default 值 for 字段名
7、创建外键约束:
alter table 表名
add constraint 约束名 foreign key(字段名) references 外表名(字段名)
8、删除表: drop table 表名
删除约束:drop constraint 约束名
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:62
阅读量:59
阅读量:35
阅读量:62
阅读量:60