CHECK
The CHECK constraint is used to give the limit for the values given on the column.
CHECK is constraints column- Level (Single column) and table- Level (Multiple columns).
Syntax :-
column_name data_type CHECK (condition)
Example : Let's see how to create CHECK constraint in table.Query :
Output :
CREATE TABLE student
(
id INT(2) NOT NULL,
name VARCHAR(50),
marks INT(2) CHECK (marks > 40 )
);
The following create a new table called student and add three columns here. we add a CHECK with marks column, so that you cannot have any student who is below 40 marks.
0 Comments