Difference Between Primary Key and Unique Key - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Difference Between Primary Key and Unique Key

Difference Between Primary Key and Unique Key

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 table

2) 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 adds NOT 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


 

 

About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.