合美:SQL中怎么定义一个属性的值必须是非负数
来源:百度文库 编辑:高考问答 时间:2024/05/15 18:30:25
加check约束
举个例子
create table test
(
rowid int CONSTRAINT ck_test_rowid check(rowid>=0)
)
如果是现有的表
则语句为
alter table test
add constraint ck_test_rowid check(rowid>=0)
这样test表中的rowid字段就必须是非负的
高考问答是一部内容开放、自由的互动网络百科全书
客观、专业、权威的知识性百科全书
来源:百度文库 编辑:高考问答 时间:2024/05/15 18:30:25
加check约束
举个例子
create table test
(
rowid int CONSTRAINT ck_test_rowid check(rowid>=0)
)
如果是现有的表
则语句为
alter table test
add constraint ck_test_rowid check(rowid>=0)
这样test表中的rowid字段就必须是非负的