Page 1 of 1

PRIMARY KEY vs. UNIQUE restrictions in MySQL

Posted: Mon Sep 19, 2022 5:43 am
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.