有没有办法防止在列中指定显式值?identity 属性防止指定显式值(只要 IDENTITY_INSERT 关闭),这是我想要的行为类型。
create table testguid (
ID uniqueidentifier default newsequentialid() not null primary key
,somedate datetime
)
[这里是约束还是触发?]
insert into testguid (somedate) values (getdate()) -- this is ok
insert into testguid (ID, somedate) values (newid(), getdate()) -- this is not ok
我希望数据库插入值,但我想阻止以任何方式指定它们。