Reputation: 143
How do prevent a table with 2 FOREIGN key's from having repeated rows with the same value.
Thks in advance.
Upvotes: 0
Views: 51
Reputation: 1269773
Use a unique index or constraint:
alter table example
add constraint unq_example_fk1_fk2 unique (fk1, fk2);
A unique constraint and unique index do essentially the same thing. So, you can also do:
create unique index unq_example_fk_fk on example(fk1, fk2);
Upvotes: 3