What is the difference between UNIQUE CONSTRAINT and
PRIMARY KEY?
1. There is no difference.
2. A PRIMARY KEY cannot be declared on multiple columns.
3. A UNIQUE CONSTRAINT cannot be declared on multiple
columns.
4. A table can have multiple PRIMARY KEYS but only one
UNIQUE CONSTRAINT.
5. A table can have multiple UNIQUE CONSTRAINTs but only
one PRIMARY KEY.
Answer Posted / andsens
Fields in UNIQUE CONSTRAINTs can be NULL. They cannot with PRIMARY KEYs.
You can define more than one UNIQUE KEY in a table.
Because of this, the behaviour of UNIQUE CONSTRAINTs is very different from PRIMARY KEY constraints. As long as one of the fields in a UNIQUE CONSTRAINT is NULL the constraint itself does not apply and you can set the other fields to whatever you want without getting an error.
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
What does bitemporal mean?
Is time a data type in sql?
What are the triggers associated with image items?
What is denormalization in a database?
Is left join same as join?
How do I make my sql query run faster?
what is datawarehouse? : Sql dba
Does google use sql?
How can you tell the difference between an index and a view?
what is a cursor? : Sql dba
What is the difference between left and left outer join?
What is group by in sql?
What is sql key?
what are the performance and scalability characteristics of mysql? : Sql dba
What is pragma in pl sql?