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

preview_player
Показать описание
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
Рекомендации по теме
Комментарии
Автор

thank you so much sir .i wish your classes will be liked by many students who really want to know oracle like me .since i started taking your classes i haven't met any problem .you are genus .keep up being there for people in need

ousmanekaba
Автор

Thanks a lot sir. Feels as if I am doing hands-on.

sanamoughal
Автор

Thank you so much, I’ve learned a lot
Could you please tell me how I add check constraint for date (end_date> start_date) ?

khalidalmohammadi
join shbcf.ru