use tempdb go if object_id('stu') is not null drop table stu go create table stu( Sname nvarchar(10), Sage int, Sex nchar(1) ) go ---- 以上为测试表 ------约束最好是加上明确的名称,默认约束无法默认两个值 alter table stu add constraint CK_Sage check (Sage>0 and Sage<100), constraint DF_Sex default ('男') for Sex
go
if object_id('stu') is not null
drop table stu
go
create table stu(
Sname nvarchar(10),
Sage int,
Sex nchar(1)
)
go
---- 以上为测试表 ------约束最好是加上明确的名称,默认约束无法默认两个值
alter table stu
add constraint CK_Sage check (Sage>0 and Sage<100),
constraint DF_Sex default ('男') for Sex