Creating a Column Check Constraint

A column check constraint enforces a specified condition on a column. Add a column check constraint to a table using the Create Constraint Wizard.

Prerequisites
Database Version Table Constraint Privileges
SAP Sybase IQ 15.3 and 15.4 Requires one of:
  • DBA authority.
  • ALTER permission on the underlying table.
  • You own the underlying table.
SAP Sybase IQ 16.0 Requires one of:
  • ALTER ANY OBJECT system privilege.
  • ALTER ANY TABLE system privilege.
  • You have ALTER permission on the underlying table.
  • You own the underlying table.
Task
  1. In the Perspective Resources view, select the resource and select Resource > Administration Console.
  2. In the Administration Console, expand IQ Servers > Schema Objects > Tables.
  3. Select Tables or Global Temporary Tables, select the table in the right pane, click the drop-down arrow that appears to the right, and select Properties.
  4. Select Constraints.
  5. Click New.
    The Create Constraint Wizard appears.
  6. On the Welcome page, specify a column check constraint:
    Option Description
    Select the type of constraint From the Select an item pull-down, select Column check constraint.
  7. Click Next.
  8. On the Constraint Name page, specify:
    Option Description
    What do you want to name the new column check constraint? Specify a descriptive name for the column check constraint.
    For which column do you want to create the new check constraint? Filter the Name, Primary Key, Data Type, Size, and Scale columns to locate the desired column. Select a single column you want to create the constraint on.
  9. Click Next.
  10. On the Definition page, specify:
    Option Description
    Specify a condition to restrict the values. SQL definition of the check constraint.

    Use this example as a model when specifying a definition:

    CHECK(TerminationDate >= StartDate);

    This example adds a constraint on the Employees table to ensure that the TerminationDate is always later than, or equal to, the StartDate.

  11. Click Finish to close the Create Constraint Wizard.
    The Properties view appears.
    Tip: Although you closed the Create Constraint Wizard, the constraint is still in-progress until you click Apply and OK in step 12. If there is a problem with the constraint definition, modify the in-progress constraint by clicking Properties and then making the necessary SQL changes.
  12. Click Apply and OK.
Related tasks
Creating a Foreign Key Constraint
Creating a Table Check Constraint
Creating a Unique Constraint
Deleting a Table or Column Check Constraint
Deleting a Primary, Foreign, or Unique Key Constraint
Rebuilding a Unique, Primary or Foreign Key Constraint
Validating a Unique, Primary or Foreign Key Constraint
Generating Constraint DDL Commands
Viewing or Modifying Constraint Properties
Authenticating a Login Account for a Managed Resource
Related reference
Table Constraints Privilege Summary