It defines the conditions that each row must be satisfy.CHECK constraint is used to limit the value
range that can be placed in a column.
Restrictions:
DEFAULT option:
Syntax:
CREATE TABLE <TABLE_NAME>
(COLUMN_NAME1 <DATA_TYPE>(WIDTH) CONSTRAINT Constraint_Name CHECK (column_name BETWEEN start_rng AND end_rng ) ,
COLUMN_NAME2 <DATA_TYPE>(WIDTH) CONSTRAINT Constraint_Name CHECK (column_name=UPPER(column_name)) DISABLE,
COLUMN_NAMEn <DATA_TYPE>(WIDTH) DEFAULT SYSDATE);
See The Example:
CHECK CONSTRAINT EXAMPLE
range that can be placed in a column.
Restrictions:
- CHECK Constraint can refer to any column in same table but it can't refer any column from other table
- In CHECK Constraint we can't use pseudo columns.
- A Single column can have multiple CHECK Constraint.
- CHECK Constraint can be define column and table level.
DEFAULT option:
- The DEFAULT option is given to maintain a default value in column.
- The DEFAULT value can be leteral or any expression or sql function.
Syntax:
CREATE TABLE <TABLE_NAME>
(COLUMN_NAME1 <DATA_TYPE>(WIDTH) CONSTRAINT Constraint_Name CHECK (column_name BETWEEN start_rng AND end_rng ) ,
COLUMN_NAME2 <DATA_TYPE>(WIDTH) CONSTRAINT Constraint_Name CHECK (column_name=UPPER(column_name)) DISABLE,
COLUMN_NAMEn <DATA_TYPE>(WIDTH) DEFAULT SYSDATE);
See The Example:
CHECK CONSTRAINT EXAMPLE
No comments:
Post a Comment