Online Documentation for SQL Manager for PostgreSQL

Editing foreign key definition


Use the Foreign Key tab of Foreign Key Editor to create/edit a foreign key constraint and specify its properties.

 

Foreign key name

Enter a name for the new foreign key, or modify the name of the foreign key being edited.

 

CheckBox Not validated (for Postgres 9.1 and higher)

If this option is selected then a foreign key can initially be added to a large existing table without checking its initial contents, but new tuples must comply with it.

 

Foreign table

The drop-down list of tables allows you to select the table for which the foreign key is created.

 

Foreign Key Editor - Editing foreign key definition

 

 

The Table Columns area allows you to select Foreign key column(s).

To select a column, you need to move it from the Available Columns list to the Included Columns list. Use the Move to Selected Move to Available buttons or drag-and-drop operations to move the columns from one list to another.

 

Foreign table

Use the drop-down list to select the foreign table.

 

The Foreign Table Columns area allows you to select the column(s) of the Foreign table.

To select a column, you need to move it from the Available Columns list to the Included Columns list. Use the Move to Selected Move to Available buttons or drag-and-drop operations to move the column from one list to another.

 

If the referenced column(s) are changed frequently, it may be wise to add an index to the foreign key column so that referential actions associated with the foreign key column were performed more efficiently. See Indexes for details.

 

On Update action / On Delete action

  • No action

Produce an error indicating that the deletion or update would create a foreign key constraint violation. If the constraint is deferred, this error will be produced at constraint check time if there still exist any referencing rows. This is the default action.

  • Restrict

Produce an error indicating that the deletion or update would create a foreign key constraint violation. This is the same as NO ACTION except that the check is not deferrable.

  • Cascade

Delete any rows referencing the deleted row, or update the value of the referencing column to the new value of the referenced column, respectively.

  • Set NULL

Set the referencing column(s) to null.

  • Set default

Set the referencing column(s) to their default values.

 

Match type

A value inserted into the referencing column(s) is matched against the values of the referenced table and referenced columns using the given match type. These are the available match types:

RadioButton Simple

Allows some foreign key columns to be null while other parts of the foreign key are not null (MATCH SIMPLE).

RadioButton Full

Does not allow one column of a multicolumn foreign key to be null unless all foreign key columns are null (MATCH FULL).

 

Deferrable

CheckBox Deferrable

This option controls whether the constraint can be deferred. A constraint that is not deferrable will be checked immediately after every command. Checking of constraints that are deferrable may be postponed until the end of the transaction.

 

Check Time

If a constraint is deferrable, this option specifies the default time to check the constraint:

Immediate

If the constraint is INITIALLY IMMEDIATE, it is checked after each statement.

Deferred

If the constraint is INITIALLY DEFERRED, it is checked only at the end of the transaction.