Questions tagged [check-constraint]

Check constraints in a relational database ensure that only certain values can be stored in one (or more columns). Check constraints can only validate columns of a single row.

Check constraints validate the value of one or more columns in a single row of a relational table. Typical check constraints are salary > 0 (validating a single column) or hire_date < fire_date (validating the dependency between two columns).

Check constraints can not be used to validate columns between different rows.

All relational DBMS except MySQL support check constraints.

77 questions
-4
votes
1 answer

SQL : Column check constraint cannot reference other columns. (for different tables)

I have two tables: T1(A,B) where create table T1( A char(2) NOT NULL primary key check(T1.A not in T2.B), B char(2) unique ); T2(C,B) where create table T2( C number(2) primary key, B char(2) unique references T1 check(T1.B not in T1.A) ); Here,…
denizen
  • 458
  • 1
  • 5
  • 15
-6
votes
2 answers

query about check constraint

want to write a check constraint(while creating a table) which accepts value between 2 dates like ('25-oct-94' to '10-may-16')
1 2 3 4 5
6