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 are internal user account in oracle?

571


For a field in a repeating frame, can the source come from the column which does not exist in the data group which forms the base for the frame ?

1558


Can objects of the same schema reside in different tablespace?

590


Can we insert data in view oracle?

537


How to pass parameters to procedures?

555






How to pass a cursor variable to a procedure?

562


What is meant by recursive hints in oracle?

620


what are actual and formal parameters?

596


How to rollback the current transaction in oracle?

539


What is Reduced List of Values?

1708


You have found corruption in a tablespace that contains static tables that are part of a database that is in NOARCHIVE log mode. How would you restore the tablespace without losing new data in the other tablespaces?

1460


How can I convert single byte kana characters into multi byte kana characters and vice-versa.

1933


What is rowid and rownum in oracle?

545


How to connect ms access to oracle servers?

552


Oracle

1855