Difference between primary key and unique key ?

Answer Posted / madhumita majhi

In SQL both primary key and unique enforce uniqueness of
the column on which they are defined. But by default
primary key creates a clustered index on the column, where
are unique creates a non-clustered index by default.
Another major difference is that, primary key doesn't allow
NULLs, but unique key allows one NULL only.

Unique Key: Identify the row by uniquely, means if you are
inserting a records into the table suppose you already
inserted a record with ID 101 and another record you are
inserting with the same ID then it will give an error
(unique key voilation).

Prmary Key:Once you define a primay key on a particular
column then a column become a mandatory field.That means
you need to insert something on it, you can not leave as a
blank otherwise it will give an error as primary key
voilation.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the dynamic sql in oracle?

603


How to change user password in oracle?

608


What is the purpose of tables, private synonyms and public synonyms in Oracle?

593


How to convert characters to numbers in oracle?

596


What is open database communication (odbc) in oracle?

551






How to do paging with oracle?

576


What is Segment Advisor in Oracle?

676


 What are the oracle DML commands possible through an update strategy?

583


How to use subqueries with the in operator using oracle?

614


how to use select statement as formal parameter in procedure specification?(someone said that using string) ex:-procedure(a in number,select ename from emp ) i am asking syntax like this?

1533


What is the difference between formal parameters and actual parameters?

547


What is the difference between post-database commit and post-form commit?

517


What is oracle rownum?

522


What is the difference between a hot backup and a cold backup in oracle?

579


What are the ways tablespaces can be managed and how do they differ?

1620