Constraints let you define the way the
Database Engine automatically enforces the integrity of a database. Constraints
define rules regarding the values allowed in columns and are the standard
mechanism for enforcing integrity.
1.
NOT NULL specifies
that the column does not accept NULL values.
2.
CHECK constraints
enforce domain integrity by limiting the values that can be put in a column.
3.
UNIQUE constraints
enforce the uniqueness of the values in a set of columns.
4.
PRIMARY KEY
constraints identify the column or set of columns that have values that
uniquely identify a row in a
table.
5.
FOREIGN KEY
constraints identify and enforce the relationships between tables.
The ON DELETE
clause controls what actions are taken when you try to delete a row to which
existing foreign keys point. The ON DELETE clause has the following options:
·
NO ACTION specifies
that the deletion fails with an error.
·
CASCADE specifies that
all the rows with foreign keys pointing to the deleted row are also deleted.
·
SET NULL specifies
that all rows with foreign keys pointing to the deleted row are set to NULL.
·
SET DEFAULT specifies
that all rows with foreign keys pointing to the deleted row are set to their default
value.
No comments:
Post a Comment