How to view table foreign keys (FKs) in Toad for IBM DB2

Bart Gawrych - Dataedo Team Bart Gawrych 2019-09-17

Table of Contents:


    This article will show you how to view table foreign keys (FKs) and related tables in Toad for IBM DB2.

    Option 1: All Foreign Keys in schema

    Open Explorer from main menu (Fig.1).

    Fig.1. Explorer in menu

    In the explorer for treeview explorer view expand following branches: Schemas -> [you schema] -> Constraints -> Foreign Keys (Fig. 2 [1]).
    For tabbed explorer view select schema and switch to Constraints tab (Fig. 2 [2]).
    To the right of foreign key name you can see on which table FK is defined.

    Fig.2. [1] Foreign Keys in treeview, [2] Foreign Keys in tabbed

    To see to which table or column FK refers to just click on it and in viewer switch to Columns tab (Fig. 3).

    Fig.3. Foreign Key columns and references

    Option 2: Foreign Keys of table

    Like in previous option, open Explorer from main menu (Fig.1). In the explorer select appropriate table (Fig.4 [1]) and switch to Constraints tab (Fig.4 [2]) in the viewer. If table have any foreign keys it will be on the list with Foreign Key type (Fig.4 [3]).

    Fig.4. [1] Selected table, [2] Constraints tab, [3] Foreign Key

    If you want to see related table right click on foreign key row and select Alter Constraint…
    In the Parent Table Information you can see referenced table. Next to it are columns from parent constraint. Constraints columns refers to parent columns in the same order (1st from Constraints columns refers to 1st from primary columns etc.)

    Fig.5. Foreign Key alter window

    Option 3: Using database map

    From main menu open Database Map (Fig. 6)

    Fig.6. Database Map in menu

    In the Database map option check all three options. Next, from Explorer drag and drop table which FKs you want to see. Database map will consist of all table dependencies with foreign keys either. If map is too large you can change depth level to 2 which allows to see referenced tables.

    Fig.7. Database Map workspace and example

    You can also see foreign key dependencies by drag and drop Foreign Key from explorer to workspace like in Fig.8:

    Fig. 8. Foreign Key in Database Map

    0
    There are no comments. Click here to write the first comment.

    By continuing to use our website, you consent to the use of cookies in accordance with our Privacy Policy (updated 28-04-2020).
    Accept