Creating a Check Constraint

Create a check constraint to limits the data that can be inserted into a table according to a specified condition.

Prerequisites 

Before you can create a check constraint, be sure that the data server containing the table for which you are creating a check constraint is running, and you created and established a connection to the data server.

  1. Expand the Tables folder.
  2. Right-click the table, and select New > Check Constraint .
  3. Specify properties for the new check constraint.
    Field Description
    Check Constraint Name Enter a name for the check constraint.
    Filter Column by Name Pattern (Optional) Enter a filter expression for columns to be displayed in the list of available columns. For example, * lists all columns for the specified table.
    Available Columns Columns available for defining a check constraint. You can sort the list of columns by clicking Column Name above the list. Move a column from the Available Columns list to the Definition field using Paste>>.
    Definition Enter a Boolean expression that defines the check constraint on the specified column values. The constraints can include:
    • A list of constant expressions introduced with in.
    • A set of conditions, which may contain wildcard characters, introduced with like. An expression can include arithmetic operations and Transact-SQL functions. The expression cannot contain subqueries, aggregate functions, parameters, or host variables.
    Preview DDL for creating the check constraint.
  4. Click Next, and specify save and execution properties for the check constraint.
    Field Description
    Generate Script Generate DDL for the check constraint.
    Enter or Select the Parent Folder Specify an existing project or create a new project in which to save the DDL.
    File Name Enter the name of the file in which to store the DDL.
    Execute Immediately Execute the DDL immediately. If you do not select this option, you must complete execution of the DDL later to create the check constraint.
    Open in Editor After Creation Create the check constraint, and then open it in the Table Schema Editor.
  5. Click Finish to create the check constraint.
Related concepts
Check Constraints
Related tasks
Editing Table Schema Data
Creating a Unique Constraint
Editing a Check Constraint
Dropping a Check Constraint
Creating a Unique Constraint
Creating a Column Check Constraint

For product-related issues, contact Sybase Technical Support at 1-800-8SYBASE. Send your feedback on this help topic directly to Sybase Technical Publications: pubs@sybase.com