Foreign Keys Wizard (PostgreSQL)
Go Up to PostgreSQL Object Wizards
This wizard lets you build and submit an ALTER TABLE... ADD CONSTRAINT .. statement, adding a new, foreign key to an existing table.
To create a new foreign key using a wizard:
- Open a creation wizard for a foreign Key. For details, see Opening an Object Wizard.
- Use the following topics as a guide to setting properties and performing tasks as you pass through the wizard panels:
- Properties panel - Foreign Keys (PostgreSQL) - Properties.
- Column Mapping panel - Foreign Keys (PostgreSQL) - Column Mapping.
- Comment panel - for details, see Adding a Comment to an Object.
- DDL View panel - for details, see Previewing the DDL Generated to Create the New Object.
- Finally, use the Execute button to create the object.
Foreign Keys (PostgreSQL) - Properties
When creating or editing a domain, this tab/panel lets you work with the following settings:
Setting | Description |
---|---|
Table Schema and Table Name |
Let you select the table in which the foreign key is being defined. |
Name |
Lets you provide the ADD CONSTRAINT parameter value, naming the new foreign key. |
Validate |
If not selected, a NOT VALID parameter is included in the generated DDL, specifying that the initial check to verify that all rows satisfy the constraint is not executed. |
Deferrable |
If selected, a DEFERRABLE parameter is included in the generated DDL, specifying that checking of constraints can be postponed until the end of the transaction |
Deferred |
If IMMEDIATE is not selected, an INITIALLY DEFERRED parameter is added to the generated DDL, ensuring that the constraint is checked at the end of the transaction. |
Delete Rule and Update Rule |
Choices correspond to ON DELETE... and ON UPDATE parameter variations added to the generated DDL: CACHE, SET DEFAULT , SET NULL , and RESTRICT. |
Match Full |
If selected, a MATCH FULL parameter is added to the generated DDL, ensuring that no column of a multicolumn foreign key can be null unless all foreign key columns are null. |
Foreign Keys (PostgreSQL) - Column Mapping
When creating or editing a foreign key, this tab/panel lets you specify the REFERENCES and FOREIGN KEY parameters of the generated ALTER TABLE... DDL.
- Under Main Table, select the check boxes corresponding to the columns in the current table that are to use values in the referenced table.
- Under Referenced Table, choose the Owner and then the Table name of the referenced table and then select the check boxes corresponding to the columns in the referenced table whose values are to be used in the main table.