How to view table foreign keys (FKs) in SQL Workbench/J

In this tutorial I would like to show you how to view table foreign keys with SQL Workbench/J - a free, DBMS-independent, cross-platform SQL query tool.

There are two ways to see FKs.

Option 1: Database Explorer

When connected to your database go to Tools menu > Show Database Explorer to launch Database Explorer.

This will open a window that lists all objects in your database in left side of the window and details of selected object in the right side. Select table you want to view foreign keys of.

Foreign keys (parent tables) are displayed in References tab. There are two separate components that show table foreign keys - the one on the top shows foreign keys in a grid, and the one on the bottom in a tree format. The latter shows a hierarchy - FKs of related tables.

What is very useful in SQL Workbench/J is that it also shows child tables - the one that reference this table with a foreign key. You can see them Referenced by tab. Relationships are presented in similar manner.

From the component on the bottom you can navigate to related tables with selecting the table, right click and Select in object list option.

Option 2: Database Object tree

There's another useful component in SQL Workbench/J to browse schema - Database Object tree. You can open it in Tools menu > Show DbTree.

It is visible in statement editor on the left side of screen. If you don't see it go to existing statement tab or open a new one with ctrl+T.

Database tree enables you to browse schema objects and their structure. To see table FKs expand schema table belongs to, then TABLE element, then your table, then References and/or Referenced by elements to see parent and child tables.

By right clicking o table and choosing Fiind in object tree option you can jump to related table.

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.