SQl MYSQL check with example
CHECK Constraint can be defined on a single column or complete table to limit the value
Example of Check IN MYSQL
Create Table Employee
(
E_id Int Not Null,
Name varchar(255),
City varchar(250),
Primary key(E_id),
CHECK (E_id>1)
)
Example of Check IN SQL
Create Table Employee
(
E_id Int Not Null Primary key(E_id) CHECK (E_id>1),
Name varchar(255),
City varchar(250),
)
Check can also be added by altering the Table
Example:
ALTER TABLE Employee
ADD CHECK (E_id>1)
Check can also be Dropped by altering the Table
Example in MYSQL:
ALTER TABLE Employee
DROP CHECK chk_Employee
Example in SQL:
ALTER TABLE Employee
DROP CONSTRAINT chk_Employee
No comments:
Post a Comment