Setting the Primary Key

Set the primary key to prohibit two or more rows in the table from having identical values for a column or set of columns. You can set the primary key on base tables and global temporary tables only.

Prerequisites
Database Version Table Privileges
SAP Sybase IQ 15.3 and 15.4 You must have one of:
  • DBA authority
  • ALTER and REFERENCE permission on the table
  • You own the table
SAP Sybase IQ 16.0 To create a new or modify an existing primary key – you must have one of:
  • ALTER ANY TABLE system privilege
  • ALTER ANY OBJECT system privilege
  • CREATE permission on the dbspace where the table resides
  • ALTER and REFERENCE permission on the table
  • You own the table

To modify the name only of an existing primary key, you must have the ALTER ANY INDEX system privilege.

Task
  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 Set Primary Key, or
    • From the Administration Console menu bar, select Resource > Set Primary Key.
    The Set Primary Key wizard appears.
  4. On the Constraint Name page of the wizard, specify the primary key name and click Next.
    If the table does not already have a primary key, the primary key name is optional.
  5. 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.
    Select columns that do not allow NULL values. Click Next.
  6. (System store (IQ catalog store) tables only) On the clustered index page, specify:
    Option Description
    Create a clustered primary key Select if you want to make the primary key's underlying index a clustered index. Clustered indexes can improve performance.
  7. Click Next.
  8. On the Comment page, add an optional, descriptive comment. Comments help you organize your database.
  9. Click Finish to close the Set Primary Key wizard.
Related concepts
Table Columns
Table Permissions
Table Constraints
Table Indexes
Table Triggers
Table Partitions
Related tasks
Creating a Table with No Partitions in the IQ Main Store
Creating a Table with No Partitions in the IQ (Catalog) System Store
Creating a Table with a Hash Partition
Creating a Table with a Range Partition
Creating a Table with a Hash-Range Partition
Creating a Global Temporary Table
Creating a Proxy Table
Viewing Table Data in the Execute SQL Window
Deleting a Table
Generating Table DDL Commands
Moving a Table to Another Dbspace
Validating a System Store Table
Setting a Clustered Index
Merging Table Data from RLV Store with IQ Main Store
Calculating the Number of Rows in a Table
Moving Table Objects to Another Dbspace
Enabling or Disabling Row-Level Versioning in a Table
Viewing or Modifying Base Table Properties
Viewing or Modifying Global Temporary Table Properties
Viewing and Modifying Proxy Table Properties
Authenticating a Login Account for a Managed Resource
Related reference
Table Privilege Summary