Drop check constraint: Check constraint can be dropped from the relation in the database in MySQL using the syntax: alter table TABLE_NAME drop check CHECK_CONSTRAINT_NAME.Remove check constraint: Check constraint can be removed from the relation in the database from SQL server using the syntax: alter table TABLE_NAME drop constraint CHECK_CONSTRAINT_NAME.Giving variable name to check constraint:Check constraints can be given a variable name using the syntax: alter table TABLE_NAME add constraint CHECK_CONST check (Predicate).
With alter: Check constraint can also be added to an already created relation using the syntax: alter table TABLE_NAME modify COLUMN_NAME check(Predicate).
#SQLITESTUDIO CHECK CONSTRAINTS OR UPDATE#
There won’t be any database update and as the age < 17 years.ĭifferent options to use Check constraint: If, however following SQL statement is executed: INSERT INTO student(STUDENTID, NAME, AGE, GENDER) Schema for student database in university: CREATE TABLE student(Įxplanation: In the above relation, the age of all students is greater than equal to 17 years, according to the constraint mentioned in the check statement in the schema of the relation. If a new tuple is added or an existing tuple in the relation is updated with a GENDER that doesn’t belong to any of the three categories mentioned, then the corresponding database update is aborted.Ĭonstraint: Only students with age >= 17 are can enroll themselves in a university.
Note: The check constraint in the above SQL command restricts the GENDER to belong to only the categories specified.