34,590
社区成员
发帖
与我相关
我的任务
分享
create table 学生
(学号 char(10) primary key constraint xh check(学号 like '0808___[1-2]__'),
姓名 nvarchar(20) not null,
生日 datetime
)
alter table 学生 with nocheck add check (datediff(year,生日,getdate())>=14)
--这个是不对现有数据进行校验
--把with nocheck 去掉就会对现有
alter table 学生 with nocheck add constraint 约束名 check (datediff(year,生日,getdate())>=14)