Question

Imagine I have a table with only 2 columns (FKs to other tables). I want to define "the primary key of this table is the combination of the 2 values".

What happens if I don't have a PK in this kind of table?

Était-ce utile?

La solution

Without a UNIQUE constraint or unique index defined on the two columns, the table could have duplicate rows.

Also, a primary key is a clustered index by default: you would need to separately index the table for expected query performance.

Refer to another SO question and yet another SO question declared as a duplicate of it regarding the differences between primary key & unique constraints and unique indexes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top