Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
how to set multiple primary keys in a table
..
Posted
Comments
Thanks7872 21-Oct-13 0:44am    
What? Multiple Primary key? Can you please elaborate your question?
Sergey Alexandrovich Kryukov 21-Oct-13 1:00am    
I think I understand the question, please see my answer.
—SA

In addition to Solution 1:

It would be very useful for you to learn some basics first, in particular, about unique and primary keys. Please see: http://en.wikipedia.org/wiki/Primary_key[^].

Pay attention for the section: "Differences between Primary Key and Unique Key":
Wikipedia says:
Each table can have at most one primary key.
So, no, you cannot have multiple primary keys. And you don't want it. It would not really make sense. The mere fact that the multiplicity of COLUMN expression in the syntax diagram is 1+ should be enough for you.

—SA
 
Share this answer
 
v4
Comments
Thanks7872 21-Oct-13 1:12am    
Yes. I thought the same. +5.
Sergey Alexandrovich Kryukov 21-Oct-13 1:15am    
Thank you, Rohan. And thank you for improving my text, but then I had to fix your improvement to make it typographically correct. :-)
—SA
Thanks7872 21-Oct-13 1:34am    
:-)
you can use composite primary key in your table.
Check this link.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Oct-13 0:59am    
This is quite correct, but it does not formally answers the question. And the answer should be "no, a table cannot have multiple primary keys". And only than bring to OP's attention the use of composite keys. Please see my answer and the referenced article.
I voted 4.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900