What are constraints?

There are six types of constraints in SQL Server.

  • PRIMARY KEY – It doesn’t allow Null values. A table can have only one PRIMARY KEY.
  • FOREIGN KEY – Ensure the referential integrity of the data in one table to match values in another table.
  • UNIQUE KEY – Allows Null value. But only one Null value. A table can have more than one UNIQUE Key Column[s].
  • NOT NULL – Indicates that a column cannot store NULL value.
  • CHECK – Ensures that the value in a column meets a specific condition.
  • DEFAULT – Specifies a default value when specified none for this column.