Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8627749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:21:36+00:00 2026-06-12T08:21:36+00:00

How can I see which entries depend on a given entry using PostgreSQL ?

  • 0

How can I see which entries depend on a given entry using PostgreSQL ? (dependent meaning “having a foreign key referencing the entry”).

Basically, I want to check which entries might be cascaded when I DELETE a given entry of a table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:21:37+00:00Added an answer on June 12, 2026 at 8:21 am

    To see all actual rows depending via fk constraint, identify the columns with the tools described below.

    Where foreign key constraints are defined with ON DELETE CASCADE, depending rows will be deleted (possibly cascading the DELETE to more depending tables).

    Where foreign key constraints are defined with ON DELETE SET NULL / ON DELETE SET DEFAULT, only the value in the columns will be reset to NULL / default value.

    Else a DELETE on rows with dependent rows would fail with an exception.

    Then run queries like the following on the identified tables / columns:

    SELECT f.tbl_fk_id, f.col_fk
    FROM   tbl_fk f
    JOIN   tbl t ON f.col_fk = t.col
    AND    <same condition as DELETE here>;
    

    pgAdmin supplies this feature:

    Dependents

    Pick the the object in the object browser to the left and chose the dependents pane top right.

    pgAdmin uses a couple of queries to the system catalog to assemble the list. You could log the commands issued if you want to build a query yourself.

    Also, when deleting an object where you are not completely sure about dependents, try a plain DROP first (without CASCADE). You will get an error message if any dependent exists …

    And finally, but proceed with caution!, you can start a transaction and just issue the command:

    BEGIN;
    DROP TABLE tbl CASCADE;
    

    Then, if you like what you see:

    COMMIT;
    

    If you don’t:

    ROLLBACK;
    

    And it will be like it never happened. 😉

    You will see something like this:

    NOTICE:  drop cascades to 4 other objects
    DETAIL:  drop cascades to constraint tbl1_tbl_id_fkey on table myschema.tbl1
    drop cascades to constraint tbl_winner_tbl_id_fkey on table myschema.tbl_foo
    drop cascades to constraint bar_tbl_id_fkey on table myschema.bar
    drop cascades to constraint tbl1_tbl_id_fkey on table x.tbl1
    
    Query returned successfully with no result in 47 ms.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to secure an application so that users can only see objects which
I am trying to see which button was clicked on so I can preform
I have a drop down menu which you can see here on jsfiddle .
Heres my custom function called doIt which as im sure you can see simply
In my application I have an edit profile page which you can see below;
I have two async classes in my application which you can see below class
In my SVG, which you can see on pastebin here , I draw two
I am trying to make a server-client model in which the server can see
I have a BHO, which i can see it as enabled in Add On's
I see JRE all over the place, but i can not be sure which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.