Primary Key and Unique Key
1) Only 1 Primary key can be defined in one table while as unique key can be defined more than 1 in a table2) Primary never accept null value while as the Unique key can accept multiple null values
3) On the creation of Primary Key, a clustered index created on the table while as On the creation of Unique Key, a non-clustered index created on the table
4) The primary key is used for identifying a record while a Unique key is used to prevent duplicate records in a table
Primary Key:
- There can only be one primary key in a table
- In some DBMS it cannot be
NULL
- e.g. MySQL addsNOT NULL
- Primary Key is a unique key identifier of the record
Unique Key:
- Can be more than one unique key in one table
- Unique key can have
NULL
values - It can be a candidate key
- Unique key can be
NULL
and may not be unique
0 comments:
Post a Comment