Example documentationCONSTRAINTS Locate this document in the navigation structure

 

Use of the system table DOMAIN.CONSTRAINTS

Prerequisites

You can use the demo data for the SQL tutorial. Start the Database Studio as database administrator MONA with the password RED and log on to demo database DEMODB: Logging On to a Database.

Define and use constraints. Proceed as described in SQL Tutorial, Constraints.

Activities

You can use Database Studio to enter and execute SQL statements. More information: Working with SQL Statements: Overview

Note the General Instructions for formulating SQL statements.

You can use the system table CONSTRAINTS to determine the following database information, among other things:

  • All conditions on the columns of the tables of the HOTEL schema that represent explicit value checks

    SELECT tablename, constraintname, definition

    FROM DOMAIN.CONSTRAINTS

    WHERE schemaname = 'HOTEL'

  • All conditions on the columns of the table CUSTOMER that represent explicit value checks

    SELECT tablename, constraintname

    FROM DOMAIN.CONSTRAINTS

    WHERE tablename = 'CUSTOMER'

Constraints (integrity conditions) that relate to NOT NULL definitions, primary keys, UNIQUE definitions or referential constrains are not found with this SELECT statement.

More Information

NOT-NULL columns: see COLUMNS

Primary key: see COLUMNS

UNIQUE columns: see INDEXES

Referential constraint: see FOREIGNKEYS

Columns in a referential constraint: see FOREIGNKEYCOLUMNS

Constraint of a domain: see DOMAINCONSTRAINTS