Creating a Unique Constraint

The unique constraint specifies that one or more columns uniquely identify each row in the table.

Prerequisites
Database Version Table Constraint Privileges
SAP Sybase IQ 15.3 and 15.4 You must have one of:
  • DBA authority
  • ALTER and REFERENCE permission on the underlying table
  • You own the underlying table
SAP Sybase IQ 16.0 You must have one of:
  • ALTER ANY OBJECT system privilege
  • CREATE permission on the dbspace the table is defined on, along with one of:
    • ALTER ANY TABLE system privilege
    • ALTER and REFERENCE permission on the underlying table
    • You own the underlying table
Task

The unique constraint is essentially the same as the primary key constraint, except that you can specify more than one unique constraint in a table. Columns must not contain any NULL values.

  1. In the Perspective Resources view, select the resource, and select Resource > Administration Console.
  2. In the left pane, expand IQ Servers > Schema Objects > Tables, and then select Tables or Global Temporary Tables.
  3. Select a table from the right pane and either:
    • Click the arrow to the right of the name and select Properties, or
    • From the Administration Console menu bar, select Resource > Properties.
    The Table or Global Temporary Table Properties view appears.
  4. Select Constraints.
  5. Click New.
    The Create Constraint Wizard appears.
  6. On the Welcome page, select Unique constraint from the drop-down list. Click Next.
  7. (Optional) On the Constraint Name page, enter a name for the unique constraint, and click Next. If you do not specify a name, the system generates one automatically.
  8. On the Columns page, specify:
    Option Description
    Add Asc. >> Moves columns from the Available Columns pane to the Selected Columns pane, in ascending order.
    Add Desc. >> (IQ catalog store (system store) tables only.) Moves columns from the Available Columns pane to the Selected Columns pane, in descending order.
    << Remove Moves columns from the Selected Columns pane to the Available Columns pane.
  9. Click Next.
  10. (System store (catalog store) tables only) On the clustered index page, select the option if you want to make the constraint's underlying index a clustered index. Clustered indexes can improve performance. Click Next.
  11. On the Comment page, add an optional, descriptive comment. Comments help you organize your database.
  12. Click Finish to close the Create Constraint Wizard.
    The Properties view appears.
    Tip: Although you closed the Create Constraint Wizard, the constraint creation process is not complete until you click Apply and OK on the Table Properties view.
  13. Do one of:
    • Click OK to update any changes to the database and exit the properties view.
    • Click Apply to update any changes to the database, but remain in the properties view.
    • Click Cancel to cancel any changes not updated to the database and exit the properties view.
Related tasks
Creating a Column Check Constraint
Creating a Foreign Key Constraint
Creating a Table Check 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