Member-only story
Constraints in SQL Server
Constraints are the rules and restrictions to apply on the type of data in a table. They specify the limit on the type of data that can be stored in a particular column in a table using constraints and also maintain the data integrity and accuracy in the table. They also ensure the unwanted data can’t be inserted into tables.
The basic funda is that A Not null constraint restrict the insertion of null values into a column.
Note: What data is valid and what is invalid can be defined using constraints.
How to specify constraints?
Constraints can be easily classified in the following two types-
Column Types Constraints: A column-level constraint references a single column and is defined along with the definition of the column at the time of creating the table using CREATE TABLE statement. Any constraint can be defined at the column level except for a COMPOSITE primary key constraints
Table Types Constraints : A table-level constraint references one or more columns and is defined separately after the creation of the table using the Alter Command. All constraints can be defined at the table level except for the NOT NULL constraint.