List all child tables of a partitioned table in PostgreSQL 14

To find the child tables of a partitioned table in PostgreSQL 14 use the below query.

select relname as table_name
from pg_class join pg_inherits on (pg_class.oid=pg_inherits.inhrelid and relkind='r')
where inhparent in (select oid from pg_class where relname='<parent_table_name>');

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s