user3663882
user3663882

Reputation: 7357

Create foreign key to a non-primary key?

Is it possible to create a foreign key constraint to a non-primary key column which is UNIQUE? I'm using PostgreSQL 8.4.

Upvotes: 1

Views: 1174

Answers (1)

Denys Séguret
Denys Séguret

Reputation: 382132

Yes.

From the documentation:

Finally, we should mention that a foreign key must reference columns that either are a primary key or form a unique constraint.

Upvotes: 5

Related Questions