我想在创建表格时在某个字段上添加条件。
此字段必须> 20。
我试过了:
Create table tblvideos(
VideoID identity(1,1) primarykey,
Rental bigint default>20
);
答案 0 :(得分:4)
您正在寻找检查约束
Create table tblvideos(
VideoID identity(1,1) primarykey,
Rental bigint
CHECK (Rental >=20) );
如果你想要名字检查约束,你可以在下面
Create table tblvideos(
VideoID int identity(1,1) primary key,
Rental bigint,
CONSTRAINT CHK_limt CHECK (rental>=20)
);