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
describe transaction-safe table types in mysql : sql dba
What is query execution plan in sql?
What operating systems are supported by oracle sql developer?
Why indexing is needed?
Do triggers have restrictions on the usage of large datatypes, such as long and long raw?
What is a natural join?
What is scope of pl sql developer in future?
What is cte sql?
What is rownum and rowid?
What are different types of keys?
How much does a sql dba make? : SQL DBA
What does select count (*) mean in sql?
what is sql in mysql? : Sql dba
How many types of sql are there?
What do you understand by pl/sql cursors?