create tb a
(
aa char(4) not null,
bb varchar(60) not null,
cc char(10) not null,
dd int not null
)
create tb b
(
aa char(4) not null,
bb varchar(60) not null
)
现在我要a表的aa和bb字段插入的数据与b表中每行都能对上
效果类似在a表中constraint chk check((aa='xx' and bb='xxx') or (aa='yy' and bb='yyy')),我只会这种在a表中的这种check约束写法,如果有更简单的写法请告诉下,我觉得这样写太不效率了就打算建个表进行参照
最好能不用触发器,感觉有的时候sql server的触发器差个数据半天反应不过来
...全文
3068打赏收藏
怎么在两个表之间建立check约束
create tb a ( aa char(4) not null, bb varchar(60) not null, cc char(10) not null, dd int not null ) create tb b ( aa char(4) not null, bb varchar(60) not null ) 现在我要a表的aa和bb字段插入的数据与b表中每行都能对上 效果类似在a表中constraint chk check((aa='xx' and bb='xxx') or (aa