Creating a Primary Key

Create a primary key to specify the column or columns whose values uniquely identify a row in a table.

Prerequisites 

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

  1. Expand the Tables folder and find the table for which you want to create a primary key.
  2. Right-click the table, and select New > Primary Key .
  3. Specify properties for the new primary key.
    Field Description
    Primary Key Name Enter a name for the primary key.
    Filter Column by Name Pattern Enter a filter expression for the columns to be displayed in the list of available columns. For example, * lists all columns for the specified table.
    Available Columns Available columns for defining a primary key. 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 primary-key index is created in ascending order for this column.
    • Highlight the column, and click ASC>>. This also specifies that the primary-key index is created in ascending order for this column.
    • Highlight the column, and click DESC>>. This specifies that the primary-key index is created in descending order for this column.
    Selected Columns A list of columns selected as defining the primary key. You can sort the list of columns by clicking 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 Displays the DDL for creating the primary key.
  4. Click Next, and specify constraint properties for the primary key.
    Field Description
    Fill Factor Choose the fill factor setting, which specifies how full the data server makes each page when it creates a new primary key on existing data. The default 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 primary key on a default or system segment.
    Clustered Make the primary key clustered.
  5. Click Next, and specify save and execution properties for the primary key.
    Field Description
    Generate Script Generate DDL for the primary key.
    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 primary key.
  6. Click Finish to create the primary key.
Related concepts
Primary Keys
Related tasks
Editing Table Schema Data
Creating a Foreign Key
Editing a Primary Key
Dropping a Primary Key

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