Pages

Men

rh

10/30/2013

Primary Key Constraints in SQL Server

Primary Key Constraints defines one or more columns in a table  that constitute a Primary Key. The Primary Key uniquely  identifies a row in a table and enforce entity integrity of the table.

Consider the following facts before you implement a PRIMARY KEY Constraints.

  • A table can have a only one Primary key constraints.
  • The column  included in the Primary Key Constraints can not accept null values.
  • The value in the columns specified as the Primary Key must be unique. If the Primary Key constraints contains more than one column, duplicates can appear in one column, but the combination of values from all the  columns in the Primary Key constraint definition must be unique.
  • A Primary Key constraint creates a unique index with the specified columns as the index key.


When to use Primary Key Constraints?:-

One or more columns in the table should uniquely identifies each row in the table.
One of the column in the table is an identity column.

No comments :

Post a Comment