Creating a Check Constraint

Creating a check constraint specifies a condition that any value must pass before it is inserted into the table.

A check constraint specifies a condition that any value must pass before it is inserted into the table. You can can create a check constraint at the table or column level. Column-level check constraints reference a single column. Table-level check constraints apply to the entire table.

  1. In the Perspective Resources view, select the server on which the table resides, then click the drop-down arrow next to the server name and select Administration Console.
  2. In the left pane of the Administration Console, expand ASE Servers > Schema Objects > Tables, then choose one of the following:
    • User Tables
    • Proxy Tables
  3. Select a table for the new check constraint.
  4. Select Properties.
  5. From the Table Properties window, select Check Constraint > New.
    You see the Add Check Constraint wizard.
  6. Enter a name for the check constraint.
  7. Enter an expression that defines the constraint.
    For example, salary > 0. The comparable command line syntax using alter table is:
    alter table sample.dbo.employee
    add constraint test_const
    CHECK  (salary > 0)
  8. (Optional) Click Summary to verify the check constraint expression.
Related tasks
Creating a Unique Constraint
Creating a Primary Key
Creating a Foreign Key
Binding Defaults and Rules to a Column