PRIMARY KEY vs. UNIQUE restrictions in MySQL

Issues and / or general discussion relating to Puppy

Moderator: Forum moderators

Post Reply
KalamyQ
Posts: 16
Joined: Wed Jul 13, 2022 10:59 am
Has thanked: 3 times

PRIMARY KEY vs. UNIQUE restrictions in MySQL

Post by KalamyQ »

The distinction between a PRIMARY KEY constraint and a UNIQUE constraint, according to the MySQL documentation, is that a PK constraint does not permit NULL values whereas a UQ constraint does. One may generate both PK and UQ for the same column in a MySQL table!

What use does it serve to add a UNIQUE constraint to a column that already has a PK constraint?
Why won't MySQL let me add a unique constraint to a column with a PK constraint already?

Click here for more references.

Post Reply

Return to “Users”