Jump to content
  • 0
Bhuvi11

SQL Server issue with unique keys

Question

The distinction between a unique key and a primary key, as well as between a unique key constraint and a main key constraint in SQL Server, confuses me much.

Can my table have more than one primary key defined? Once more, I'm confused on how to add a unique key in my table and what it will actually be used for. Second, I discovered this quote on the internet.

A UNIQUE constraint is defined on a PRIMARY KEY constraint by default.

It should be noted that each table can have an unlimited number of UNIQUE constraints, but only one PRIMARY KEY constraint.

Does this imply that if I establish a primary key, the unique key associated with it is immediately defined, allowing for a single insertion of a null value? 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.