Is there a clean, simple, and preferably prepackaged (ready function?) way to list the order of referential integrity in a
Postgres database, rather than trying to read the system tables to find that order manually, which is tedious and time consuming?
What I mean is, if the entity hierarchy is
USER --> ACCOUNT --> TRANSACTION
meaning that a single user can have multiple accounts and that a single account can have multiple transactions, if I want to delete all the three tables without breaking any
foreign keys, I would have to do it in the exact following order:
DELETE FROM TRANSACTION; DELETE FROM ACCOUNT; DELETE FROM USER;
Now this is a very simple and obvious example. But real life databases have a lot more tables and foreign keys. If I wanted to delete every table down to 0 rows, is there a quick way to obtain the exact order of referential integrity to do it in?