已经定义了一个表
create table 学生
(学号 char(10) primary key constraint xh check(学号 like '0808___[1-2]__'),
姓名 nvarchar(20) not null,
生日 datetime
)
在“生日”上添加不对已有数据进行验证的数据校验约束“bircheck”,要求输入的数据需满足的条件是学生的年龄必须不小于14岁。
该怎么写?还有,如果要对已有的数据验证呢?
------解决思路----------------------
alter table 学生 with nocheck add constraint 约束名 check (datediff(year,生日,getdate())>=14)