问一个数据库约束的有关问题
问一个数据库约束的问题
create table A(
Id int identity(100,1) primary key,
Name varchar(32) not null,
ParentId int
)
现在字段PARENTID 要求只能选择字段ID内已存在的值 问语句怎么写
------解决方案--------------------
这个约束应该是做不到的
------解决方案--------------------
在业务程序里做选择的时候限制,或者给表加个触发器判断也行,优先前者
create table A(
Id int identity(100,1) primary key,
Name varchar(32) not null,
ParentId int
)
现在字段PARENTID 要求只能选择字段ID内已存在的值 问语句怎么写
------解决方案--------------------
这个约束应该是做不到的
------解决方案--------------------
在业务程序里做选择的时候限制,或者给表加个触发器判断也行,优先前者