15.10 - CHECK Constraints - Teradata Database

Teradata Database SQL Data Types and Literals

prodname
Teradata Database
vrm_release
15.10
category
Programming Reference
featnum
B035-1143-151K

CHECK constraints compare values of a field or fields in the same row with constants or other fields.

CHECK constraints are applied to rows generated as candidates for INSERT and UPDATE operations.

You cannot specify CHECK constraints for Identity columns.

If the condition is met or the proposed INSERT or UPDATE contains NULLs, the operation is permitted.

If the condition is not met, an error is reported as a constraint violation. For details on the syntax, see “CREATE TABLE” in SQL Data Definition Language.

For character data, constraints are checked using the current session collation. Therefore, it is possible for a value to meet the constraint for one collation and violate the constraint for another collation.

Also see “Constraint Specifications” in Database Design.

   CREATE TABLE stats_tbl
      (Id INTEGER
      ,Sex CHAR(1)
      ,EdLev INTEGER
      ,CHECK (Sex = 'F' OR Sex = 'M')
      ,CHECK ((EdLev >= 0) AND (EdLev <= 22)));