Is declaring an attribute of a table as UNIQUE equivalent to declaring it as PRIMARY KEY?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Nope.
PRIMARY KEYs must be UNIQUE, but UNIQUE keys need not be primary. You can have multiple UNIQUE keys in a table.
The key difference is that PRIMARY keys can not have NULL values, as they must uniquely identify a row. UNIQUE keys may be NULL, and multiple NULL values are permitted (unless you’re using an uncommon table engine like BDB).