filmov
tv
SQL - Lecture 3 - Default Expression & Check Constraints - Oracle - Practical Demonstrations

Показать описание
This video demonstrates step by step implementation of default expression and check constraints in details.
Lecture Summary
*DEFAULT* is used to insert the default value.
If default is set into column then we can insert it in 2 ways.
1. Using Default keyword
2. By skipping the column at time of insert.
*Check constraint*
It is used to put validation on column for each row.
Syntax:
CHECK (condition)
Example
*1.* CHECK(CITY = 'RAJKOT')
*2.* CHECK(LENGTH(MOBILE)=10)
*3.* CHECK(EMAILID LIKE '___%@__%.__%')
*4.* CHECK(SUBSTR(NAME,1,1) BETWEEN 'A' AND 'P')
*5* CHECK (CITY IN ('AHM', 'RJT', 'SURAT'))
*Note*
CONSTRAINT constraint_name is recommended for each constraints to identify constraints at the time of violations.
Constraint name is unique within the database.
*Syntax of table*
CREATE TABLE table_name(
col1 data_type [default expr] [ [constraint constraint_name] constraint_type ],
col2 data_type [default expr] [ [constraint constraint_name] constraint_type ],
.
.
colN data_type [default expr] [ [constraint constraint_name] constraint_type ], [table_level_constraint]
)
For Learning More about Programming
Lecture Summary
*DEFAULT* is used to insert the default value.
If default is set into column then we can insert it in 2 ways.
1. Using Default keyword
2. By skipping the column at time of insert.
*Check constraint*
It is used to put validation on column for each row.
Syntax:
CHECK (condition)
Example
*1.* CHECK(CITY = 'RAJKOT')
*2.* CHECK(LENGTH(MOBILE)=10)
*3.* CHECK(EMAILID LIKE '___%@__%.__%')
*4.* CHECK(SUBSTR(NAME,1,1) BETWEEN 'A' AND 'P')
*5* CHECK (CITY IN ('AHM', 'RJT', 'SURAT'))
*Note*
CONSTRAINT constraint_name is recommended for each constraints to identify constraints at the time of violations.
Constraint name is unique within the database.
*Syntax of table*
CREATE TABLE table_name(
col1 data_type [default expr] [ [constraint constraint_name] constraint_type ],
col2 data_type [default expr] [ [constraint constraint_name] constraint_type ],
.
.
colN data_type [default expr] [ [constraint constraint_name] constraint_type ], [table_level_constraint]
)
For Learning More about Programming
Комментарии