soul shrestha
soul shrestha

Reputation: 125

confusion on unique key vs PK

hi guys I have a one question. I searched and google for ok abs unique key concepts. But got some confusion. There can be only one PK in a table but can have multiple unique index right. So, does this mean one one column in a table will be the PK and for unique index there can be multiple columns. Could you please make me clear on this?

Upvotes: 1

Views: 24

Answers (2)

nbk
nbk

Reputation: 49400

You can have also have a multiple column primary key, which means that the combination of all columns has to be unique and Indexed

A unique Constraint only guarantees that every row in that column is unique.

A KEY is a indexed column which can be [UNIQUE | FULLTEXT | SPATIAL]

Upvotes: 1

Gordan Bobić
Gordan Bobić

Reputation: 1888

Neither PK nor the unique index have to be single-column. They can both span multiple columns.

Upvotes: 1

Related Questions