Create Table Wizard - Primary, Foreign, and Unique Keys
Use this page to define the primary, foreign, and unique keys for a new table.
The database server enforces a unique or primary key constraint on a table through a unique index. You can add a unique or primary key constraint when you create a table or when you add a unique index. If you add a unique or primary key constraint when you create a table, the database server adds the unique index using the default options. If you add a unique or primary key constraint when you add a unique index, you can specify the index name, the storage scheme, and the storage location.
Primary Key
Define a primary key for the table.
- Name
- Type a name for the primary key that is unique among index and constraint names in the table. The name must follow the guidelines of SQL syntax for an identifier.
- Available Columns
- This list displays the columns in the table that can be part of the primary key. Select the columns for the primary key.
- Primary Key Columns
- This list displays the columns that are selected for the primary key. Use the arrows to change the order of the columns in the key.
Foreign Keys
The list displays information about the foreign keys in the table:
- Name
- The name of the foreign key.
- Reference Table
- The table that is referenced by the foreign key
- Columns
- The columns in the table that are mapped to the referenced table.
To define a foreign key for the table, click Add and
complete the fields.
- Name
- Type a name for the foreign key that is unique among index and constraint names in the table. The name must follow the guidelines of SQL syntax for an identifier.
- Reference Keys
- This list displays the tables in the database that have primary or unique keys that can be referenced by the foreign key. Expand a table and select a reference key.
- Mapping
- Map the referenced column to a column in the table.
- Disable the index for this foreign key
- Select this option to disable the index that is created automatically by the database server for the foreign key constraint. Disabling the index can improve the efficiency of insert, delete, and update operations on large child tables. This option requires Informix® 11.70.
Unique Keys
The list displays information about the unique keys in the table:
- Name
- The name of the unique key.
- Columns
- The columns in the table that the unique key applies to.
To define a unique key for the table, click Add and
complete the fields.
- Name
- Type a name for the unique key that is unique among index and constraint names in the table. The name must follow the guidelines of SQL syntax for an identifier.
- Available Columns
- This list displays the columns in the table that can be part of a unique key. Select the columns for the unique key.
- Unique Key Columns
- This list displays the columns that are selected for the unique key. Use the arrows to change the order of the columns in the unique key.