How can I get the name of all the non partitioned tables in my DB ? I use PostgresSQL 9.6
And how do I get the names of the partitioned tables only ?
For now I have the names of the partions in my DB, specifying a table name, but I need to do that dinamically.
SELECT i.inhrelid::regclass AS child
FROM pg_inherits i
WHERE i.inhparent = 'public.documento'::regclass;
pg_inherits
records information about table and index inheritance hierarchies.
If you need to get all partitioned tables only(exclude partitioned indexes), we can use:
select relnamespace::regnamespace::text schema_name, oid::regclass::text table_name from pg_class
where relkind = 'p' and oid in (select distinct inhparent from pg_inherits)
order by schema_name, table_name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With