【发布时间】:2018-02-15 13:21:46
【问题描述】:
我有两个表,这两个表中的每一个都有一个主键列,另一个表(表 3)有一个外键,它引用了主键列以上的两个列。
现在我想将记录插入到表 3 中,如果它出现在这两个主键表中的任何一个中。
注意:我不想创建一个由主键表组合的新表并添加对新创建表的引用
【问题讨论】:
-
你遇到了什么错误?
-
@ZaidMirza - /*create table table1(id int primary key) * / /* create table table2(id int primary key) */ /*create table table3(id int foreign key references table1( id)) */ /*alter table table3 add constraint fk_id foreign key(id) references table2(id)*/......In This table 3 is refereing both table1 and table2 .now I want to enter records in table3 如果它在 table1 或 table2 中具有相同的记录。有什么办法可以做到 sql server
-
@ZaidMirza- 在上面的例子中提到它允许我将数据输入到 table3 如果它存在于两个表(table1 和 table2)中
标签: sql sql-server database performance