(Note I am now living with one foot in SQL Server land and the other in Oracle Land - hence the semicolons)
create table tmp1 ( f1 char(1), f2 char(1), primary key ( f1, f2) ); create table tmp2 ( f1 char(1), f2 char(1) , constraint FK_composite foreign key (f1, f2) references tmp1 (f1, f2) ); insert into tmp1 (f1, f2) values ('1', '1'); insert into tmp1 (f1, f2) values ('2', '2'); -- succeeds insert into tmp2 (f1, f2) values ('1', '1'); insert into tmp2 (f1, f2) values ('2', '2'); -- fails insert into tmp2 (f1, f2) values ('1', '2'); insert into tmp2 (f1, f2) values ('2', '1'); select * from tmp1; select * from tmp2; drop table tmp2; drop table tmp1; |
No comments:
Post a Comment