• In relational database primary key is a specific choice of minimal set of attributes that uniquely specify a relation.
  • Primary key is a special realational database table column key that uniquely identifies a table record.
  • In a table if primary key needs to be created then we have to define a primary key constraint when you create or modify a table.
  • When multiple coulmns are declared as primary key then it is called as Composite key.
  • A table should not contain more than one primary key.

A primary key’s main features are:

  • It must contain a unique value for each row of data. A table can have only one primary key constraint
  • It cannot contain null values.
  • Every row must have a primary key value.
  • It enforces the entity integrity of data.
  • Primary key always has a unique data.
  • Primary key length cannot be more than 900 bytes.
  • Primary key cannot have a null value.
  • Duplicate values are not allowed in primary key.
  • A primary key might use one or more fields already present in the table, or a unique field can be created to be the primary key.

Categorized in: