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.
Answers were Sorted based on User's Feedback
Answer / sdp
A table can have multiple UNIQUE CONSTRAINTs but only
one PRIMARY KEY.
| Is This Answer Correct ? | 21 Yes | 1 No |
Answer / radhika
A table can hava multiple Unique constraints but only one
primary key.
| Is This Answer Correct ? | 16 Yes | 1 No |
Answer / rajesh.m
There is no difference.
The One & only Difference is a UNIQUE would allow Null
Values where as The Primary Key Not.
| Is This Answer Correct ? | 15 Yes | 2 No |
Answer / 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 |
Answer / sunitha
yes, i agree with Rajesh ,primary key constraint doesn't allow null values but unique constraint allows null values.this is the main difference .
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vikneswaran
1) primary key don't allow null values but unique const
allow null values
2)we can declare primary key as multiple column. but table
should have one primary key
3)we can declare unique as multiple column. but table should
have one unique key
4) and 5)
in table we can create multiple column of primary key and
multiple column of unique. but only the restriction is in
table should have one primary key and one unique key .. if
it is neccessary.
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / chandrasekar.ramasamy
A table can have compite primarykey but only one unique
constraint
| Is This Answer Correct ? | 0 Yes | 15 No |
What is informix sql?
Describe types of sql statements?
Define sql delete statement.
What is time based sql injection?
what is sql profiler
How to find last day of the month in sql query
What are the types of subqueries?
column A column b | output 10 7 | 10 5 8 | 8 7 -9 | 7 3 5 | 5 0 6 | 6 Write a sql query to print such output.
What are the 3 modes of parameter?
What do you understand by pl/sql records?
how to select unique records from a table? : Sql dba
What is full join?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)