---创建主键约束,唯一约束,检查约束 create table test ( id int, testname varchar(50), sex bit, class varchar(50), score float default(0) constraint pk_test primary key/*这里可以指定是创建聚集或非聚集索引clustered|nonclustered可选项*/(id) constraint ix_test unique(testname) constraint ck_test check/*这里可以使用 not for replication可选项,用于指定当从其他表中复制数据时,不检查约束条件*/(score>=0) ) go
create table test
(
id int,
testname varchar(50),
sex bit,
class varchar(50),
score float default(0)
constraint pk_test primary key/*这里可以指定是创建聚集或非聚集索引clustered|nonclustered可选项*/(id)
constraint ix_test unique(testname)
constraint ck_test check/*这里可以使用 not for replication可选项,用于指定当从其他表中复制数据时,不检查约束条件*/(score>=0)
)
go