Hello.

No one knows if it is possible for PostgreSQL to somehow use the system tables to find out if there is an established cascading deletion for a particular table in the tables referring to it?

You just need to find out, when deleting a specific entry, which other entries were deleted in cascade.

    1 answer 1

    To check ON DELETE :

     SELECT constraint_catalog,constraint_catalog,constraint_name,table_catalog,table_schema,table_name,column_name,delete_rule FROM information_schema.constraint_column_usage ccu INNER JOIN information_schema.referential_constraints rc USING (constraint_catalog, constraint_schema, constraint_name) WHERE delete_rule <> 'NO ACTION'; 
    • It is possible as you suggest. I solved it this way: SELECT tc.table_name, kcu.column_name FROM information_schema.table_constraints, create a cure, a rationale, a red quota, a hint JOIN information_schema.key_column_usage, kcu ON tc.constraint_name = kcu.constraint_name ON tc.constraint_name = rc.constraint_name WHERE constraint_type = 'FOREIGN KEY' AND ccu.table_name = 'Table of Interest' AND rc.delete_rule = 'CASCADE'; - Vaycheslav