In PSQL, is there a good way of finding all the tables that inherit from another table? Ideally, I could get the data from a SQL query, but at this point, I'd be happy with any reliable method.
+1
A:
What do you mean "from sql query"? Does it mean SELECT
ing from pg_inherits
is not good enough for you?
SELECT pg_inherits.*, c.relname AS child, p.relname AS parent
FROM
pg_inherits JOIN pg_class AS c ON (inhrelid=c.oid)
JOIN pg_class as p ON (inhparent=p.oid);
Michael Krelin - hacker
2009-09-22 18:21:20
When I wrote "sql query", I meant something I could pass to PSQL on the command line, as opposed to something like \d that must be run interactively. So selecting from pg_inherits is a good start. Where can I find a table listing table names and their oids?
Watusimoto
2009-09-22 18:38:11
Das is perfekt! Vielen dank!
Watusimoto
2009-09-22 18:49:52
de rien ;-)
Michael Krelin - hacker
2009-09-22 19:00:50
Watusimoto - \d can be passed to psql on the command line as well :)
depesz
2009-09-22 19:06:59
depesz, +1 ;-)
Michael Krelin - hacker
2009-09-22 19:10:06