Jump to content

PRIMARY KEY vs. UNIQUE restrictions in MySQL

Recommended Posts

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.

Edited by DollyG
removed link
Link to comment
Share on other sites

You do not have enough posts for us to allow a link to a site like that, despite your intentions. You'll have to use more official type sources for a little while, otherwise people may think you are a spammer (if you are a spammer, we'll find out, don't worry).

IDK if this is something that is a better reference (heck, it might even be the answer)


  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.

  • Create New...