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


Please Help Members By Posting Answers For Below Questions

Explain two easy sql optimizations.

604


Explain clause in sql?

564


What is trigger and stored procedure in sql?

558


how would you enter characters as hex numbers? : Sql dba

516


write an sql query to get third maximum salary of an employee from a table named employee_table. : Sql dba

542






Which column in the user.triggers data dictionary view shows that the trigger is a pl/sql trigger?

603


What are the different types of functions in sql?

515


What is a boolean in sql?

524


Name the operator which is used in the query for pattern matching?

505


How to get help at the sql prompt?

643


Can we use join in subquery?

567


How do I send sql query results to excel?

580


What does the acronym acid stand for in database management?

542


What is substitution variable in pl sql?

505


what is 'mysqlshow'? : Sql dba

589