Thursday, 26 December 2013

SQL SERVER : Difference Between UNIQUE KEY and PRIMARY KEY

PRIMARY Key and UNIQUE Key enforce the Uniqueness of the values on the column[columns] on which it is defined.


  •  By Default, UNIQUE Key creates a NON CLUSTERED INDEX while PRIMARY Key creates a   CLUSTERED  INDEX 
  • You can create multiple UNIQUE Keys on a table but you can have ONLY One PRIMARY Key on a table.
  • PRIMARY Key can be used in Foreign key relationship where as UNIQUE Key can not be used.
  • PRIMARY Keys can not have nulls but UNIQUE Key allows null value (But only one null value). 


No comments:

Post a Comment

Using Polybase to load data into Azure Synapse Analytics (SQL DW) from Blob Storage

Azure Synapse Analytics supports many data loading methods. The fastest and most scalable way to load is through Polybase technology. Polyba...