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 is the use of anchoring object? what r the difference between anchoring object & enclosing object? can any one tell me all the details?
Can we join two tables without common column?
What operators deal with null?
What is an oracle stored procedure?
what is a view? : Sql dba
how to use myisamchk to check or repair myisam tables? : Sql dba
How do I run a sql query in pgadmin 4?
Does a user_objects view have an entry for a trigger?
how mysql optimizes distinct? : Sql dba
What is the difference between microsoft access and sql?
Explain how to use transactions efficiently : transact sql
What is a trigger word?
What is embedded sql what are its advantages?
What are different types of indexes?
What is trigger in sql?