Skip to Main Content

Referenced primary keys

OwnerTable NameColumn NameConstraint NameR OwnerR Table Name
TEDSTRUIKEMPDEPTNOSYS_C0014033TEDSTRUIKDEPT
TEDSTRUIKEMPMGRSYS_C0014032TEDSTRUIKEMP

Hierarchy of primary & foreign keys

OwnerTable NameConstraint TypeConstraint NamePositionColumn NameR OwnerR Table Name
TEDSTRUIKDEPTPSYS_C00139261DEPTNO
TEDSTRUIKEMPPSYS_C00139811EMPNO
TEDSTRUIKEMPRSYS_C00140321MGRTEDSTRUIKEMP
TEDSTRUIKEMPRSYS_C00140331DEPTNOTEDSTRUIKDEPT
TEDSTRUIKTED_AMAZON_LOGSRTED_AMAZON_LOGS_PROD_K1PROD_PK_IDTEDSTRUIKTED_AMAZON_PRODUCTS
  • 1 - 5 of 16

Info

Primary & foreign keys and the tables & columns they reference.

Referenced primary keys
Simple query that lists all primary keys and the tables & columns they use. Adjust the where clause to your needs.

Hierarchy of primary & foreign keys
A more complex query:
This will travel the hierarchy of foreign keys for a given table and column and return columns from child and grandchild, and all descendant tables.
It uses sub-queries to add r_table_name and r_column_name to user_constraints, and then uses them to connect rows.

Adjust the where clause to your needs.

Either run these as sys/system, or give the user these 2 privileges:
You can find the original queries here; I did change them quite a bit to make them more legible and to use the dba_% views:
http://stackoverflow.com/questions/1729996/list-of-foreign-keys-and-the-tables-they-reference

Code

Region

Identification
Sequence
Title
Type
Source
Source Type
Region Source

Region

Identification
Sequence
Title
Type
Source
Source Type
Region Source