1.

What Is A "constraint"?

Answer»

A constraint allows you to apply simple referential INTEGRITY checks to a table.

There are four primary types of constraints:

PRIMARY/UNIQUE - enforces uniqueness of a particular table COLUMN. But by default primary KEY creates a clustered index on the column, where are unique creates a non-clustered index by default. Another major DIFFERENCE is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

DEFAULT - specifies a default value for a column in case an insert operation does not provide one.

FOREIGN KEY - validates that every value in a column exists in a column of another table.

CHECK - checks that every value stored in a column is in some specified list. Each type of constraint performs a specific type of action. Default is not a constraint. NOT NULL is one more constraint which does not allow values in the specific column to be null. And also it the only constraint which is not a table level constraint.

A constraint allows you to apply simple referential integrity checks to a table.

There are four primary types of constraints:

PRIMARY/UNIQUE - enforces uniqueness of a particular table column. But by default primary key creates a clustered index on the column, where are unique creates a non-clustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

DEFAULT - specifies a default value for a column in case an insert operation does not provide one.

FOREIGN KEY - validates that every value in a column exists in a column of another table.

CHECK - checks that every value stored in a column is in some specified list. Each type of constraint performs a specific type of action. Default is not a constraint. NOT NULL is one more constraint which does not allow values in the specific column to be null. And also it the only constraint which is not a table level constraint.



Discussion

No Comment Found