Add Foreign Key -- Fields and controls

" " Table schema
" " Table name
" " Primary key
" " Available columns
" " >, >>, <, <<
" " Foreign key
" " On delete
" " On update
" " Constraint name
" " OK
" " Cancel
" " Apply



" " Table schema

Use this box to specify the schema of the parent table.

The parent table must have a primary key. The foreign key specified for the table being created must have the same number of columns as the primary key of its parent table. Furthermore, the nth column in the foreign key must be compatible in terms of data type with the nth column of the primary key of its parent table.

Use one of these methods:

You can specify an ordinary or delimited identifier.

" " Table name

Use this box to specify the name of the parent table. The parent table must have a primary key. The foreign key specified for the table being created must have the same number of columns as the primary key of its parent table. Furthermore, the nth column in the foreign key must be compatible in terms of data type with the nth column of the primary key of its parent table.

Use one of these methods:

You can specify an ordinary or delimited identifier.

" " Primary key

This box lists all of the columns defined as primary key columns in the parent table. The primary key columns are listed in order of significance.

Use this box to view the list of primary key columns for the parent table. The foreign key columns that you select in the Available columns box must match the parent table's primary key columns in meaning and data type.

" " Available columns

This box lists all of the columns defined for the table. Use this box to select the column or columns that you want to define as foreign key columns and then click on the > push button. Each column that you select must match a column listed in the Primary key box in meaning and data type. You can select one or more columns at the same time.

Attention: You cannot define columns of data type LOB, LONG VARCHAR, or LONG VARGRAPHIC to be part of a foreign key.

" " >, >>, <, <<

Use these push buttons to change the list of columns displayed in the Available columns and Foreign key boxes. You can use:

>
To move the selected columns in the Available columns box to the Foreign key box.

>>
To move all columns displayed in the Available columns box to the Foreign key box.

<
To move the selected columns in the Foreign key box to the Available columns box.

<<
To move all columns displayed in the Foreign key box to the Available columns box.

" " Foreign key

This box lists all of the columns defined as foreign key columns. Use this box to view the list of foreign key columns or to select a column or columns to remove from the list with the < push button.

To add a column to this list, select a column from the Available columns box and then click on the > push button.

" " On delete

Optional: Use this box to specify what action is to take place on the dependent table when a row of the parent table is deleted. Click on the down arrow and select one of the following actions:

No action
Specifies that an error occurs for the DELETE operation on the parent table and no rows are deleted. A delete rule of NO ACTION is enforced after other referential constraints. NO ACTION is the default.

Restrict
Specifies that an error occurs for the DELETE operation on the parent table and no rows are deleted. A delete rule of RESTRICT is enforced before all other constraints.

Cascade
Specifies that the delete operation is propagated to the dependents of the deleted row in the parent table.

Set null
Specifies that each nullable column of the foreign key of each dependent of the deleted row is set to null. Do not specify this action unless some column of the foreign key allows null values.

" " On update

Optional: Use this box to specify what action is to take place on the dependent table when a row of the parent table is updated. Click on the down arrow and select one of the following actions:

No action
Specifies that an error occurs for the UPDATE operation on the parent table and no rows are updated. An update rule of NO ACTION is enforced after other referential constraints. NO ACTION is the default.

Restrict
Specifies that an error occurs for the UPDATE operation on the parent table and no rows are updated. An update rule of RESTRICT is enforced before all other constraints.

" " Constraint name

Optional: Type a name for the constraint that you're defining. This name:

If you do not specify a constraint name, one is generated for you.