SQL CHECK Constraint |
Can you explain the use of SQL CHECK Constraint with an example? |
By : Chanuri Email : chanuri@tekstart.lk |
Date/time : 2021-09-25 |
ID | 1 |
Name | Sisira Palihakkara |
sisiraedck@gmail.com | |
Answer | • The CHECK constraint is used to limit the value range that can be placed in a column. • If you define a CHECK constraint on a table it can limit the values in certain columns based on values in other columns in the row. |
Date/Time | 2021-09-26 |
ID | 2 |
Name | Sisira |
sisiraedck@gmail.com | |
Answer | CREATE TABLE Student ( Adno int Primary Key, Name varchar(255) NOT NULL UNIQUE, Age int, CHECK (Age<20) ); |
Date/Time | 2021-09-26 |