Reputation: 6248
I have a table in Postgres with a composite primary key.
What's the syntax to alter another existing table to add a composite foreign key to the composite primary key of the first table?
Upvotes: 3
Views: 2162
Reputation: 1062
ALTER TABLE my_fk_table
ADD CONSTRAINT my_fk
FOREIGN KEY (pk1, pk2)
REFERENCES my_pk_table
ON DELETE CASCADE;
Upvotes: 5