How can I find which tables reference a given table in Oracle SQL Developer? How can I find which tables reference a given table in Oracle SQL Developer? oracle oracle

How can I find which tables reference a given table in Oracle SQL Developer?


No. There is no such option available from Oracle SQL Developer.

You have to execute a query by hand or use other tool (For instance PLSQL Developer has such option). The following SQL is that one used by PLSQL Developer:

select table_name, constraint_name, status, ownerfrom all_constraintswhere r_owner = :r_ownerand constraint_type = 'R'and r_constraint_name in (   select constraint_name from all_constraints   where constraint_type in ('P', 'U')   and table_name = :r_table_name   and owner = :r_owner )order by table_name, constraint_name

Where r_owner is the schema, and r_table_name is the table for which you are looking for references. The names are case sensitive


Be careful because on the reports tab of Oracle SQL Developer there is the option "All tables / Dependencies" this is from ALL_DEPENDENCIES which refers to "dependencies between procedures, packages, functions, package bodies, and triggers accessible to the current user, including dependencies on views created without any database links.". Then, this report have no value for your question.


To add this to SQL Developer as an extension do the following:

  1. Save the below code into an xml file (e.g. fk_ref.xml):
<items>    <item type="editor" node="TableNode" vertical="true">    <title><![CDATA[FK References]]></title>    <query>        <sql>            <![CDATA[select a.owner,                            a.table_name,                            a.constraint_name,                            a.status                     from   all_constraints a                     where  a.constraint_type = 'R'                            and exists(                               select 1                               from   all_constraints                               where  constraint_name=a.r_constraint_name                                      and constraint_type in ('P', 'U')                                      and table_name = :OBJECT_NAME                                      and owner = :OBJECT_OWNER)                               order by table_name, constraint_name]]>        </sql>    </query>    </item></items>
  1. Add the extension to SQL Developer:

    • Tools > Preferences
    • Database > User Defined Extensions
    • Click "Add Row" button
    • In Type choose "EDITOR", Location is where you saved the xml file above
    • Click "Ok" then restart SQL Developer
  2. Navigate to any table and you should now see an additional tab next to SQL one, labelled FK References, which displays the new FK information.

  3. Reference


Replace [Your TABLE] with emp in the query below

select owner,constraint_name,constraint_type,table_name,r_owner,r_constraint_name  from all_constraints  where constraint_type='R'   and r_constraint_name in (select constraint_name                                from all_constraints                               where constraint_type in ('P','U')                                 and table_name='[YOUR TABLE]');