Constraints -
Constraints are the
rules enforced on data columns on table. This ensures the accuracy and
reliability of the data in the database. Constraints define some
conditions that restricts the column to remain true while inserting or updating
or deleting data in column.
Constraints
can be defined in two ways
1) The constraints can be specified immediately after the column definition.
1) The constraints can be specified immediately after the column definition.
This is called
column-level definition.
2) The constraints can be specified after all the columns are defined.
2) The constraints can be specified after all the columns are defined.
This is called table-level definition.
Types of Constraints in SQL-Server
NOT NULL- This constraint is responsible for a column to confirm that a
column cannot have a null value.
DEFAULT – This constraint provides a default value when specified
non for this column.
UNIQUE- This constraint insure that each row for the column has
different value.
PRIMARY KEY- Primary key constraint is a combination of a NOT NULL constraint and a
UNIQUE constraint. This constraint ensures that the specific column for a table
have an unique identity.
FOREIGN KEY- this constraints responsible to uniquely identified a rows/records in any another database
table.
CHECK-
The CHECK responsible to enables a condition to
check the value being entered into a record
Comments
Post a Comment