Creating a Unique Constraint

Create a unique table constraint to require that all non-null values in specified columns be unique.

Prerequisites 

Before you can create a unique constraint, be sure that the data server containing the tables 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 > Unique Constraint from the context menu.

    The New Unique Constraint wizard opens.

  3. Specify properties for the new unique constraint.
    Field Description
    Unique constraint name Enter a name for the unique constraint in the text field.
    Filter column by name pattern Optionally enter a filter expression for columns to be displayed in the list of available columns. For example, * will list all columns for the specified table.
    Available columns This is a list of columns available for defining a unique constraint. You can sort the list of columns by clicking on Column Name above the list. Move a column from the Available columns list to the Selected columns list in one of three ways:
    • Double-click the column in the Available columns list. This specifies that the unique constraint is created in ascending order for this column.
    • Highlight the column, and click ASC>>. This also specifies that the unique constraint is created in ascending order for this column.
    • Highlight the column, and click DESC>>. This specifies that the unique constraint is created in descending order for this column.
    Selected columns This is a list of columns selected as defining the unique constraint. You can sort the list of columns by clicking on Column Name above the list. You can also reorder a list item by highlighting the column in the list and clicking Up or Down. To place a column back in the Available columns list, highlight the column and click <<Remove.
    Preview This field displays the DDL for creating the foreign key.
  4. Click Next, and specify storage options for the unique constraint.
    Field Description
    Fill factor Choose the fill factor setting, which specifies how full the data server makes each page when it creates a new unique constraint on existing data. The deault is 0.
    Maximum rows per page Specify the maximum number of rows on data pages and the leaf-level pages of indexes. The default is 0.
    Reserve page gap Specify the ratio of filled pages to empty pages to be left during I/O allocation operations. For each specified number of pages, an empty page is left for future expansion of the index. Valid values are 0 - 255. The default is 0.
    Create on segment Specify whether to create the unique constraint on a default or system segment.
    Clustered Specify whether or not to make the unique constraint clustered.
  5. Click Next, and specify save and execution properties for the foreign key.
    Field Description
    Generate script Select this option to generate DDL for the unique 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 unique constraint.
    Open in editor after creation Create the unique constraint, and then open it in the Table Schema Editor.
  6. Click Finish to create the unique constraint.
Related concepts
Unique Constraints
Related tasks
Editing Table Schema Data
Creating a Check Constraint
Editing a Unique Constraint
Dropping a Unique Constraint
Creating a Check Constraint
Creating a Column Check Constraint

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.