0
select 
    relname as partitioned_tables
from pg_class
where relkind = 'p';

I get partitioned_tables with the code. I need to get information about these tables' partition types (range,hash,list etc.) and partition column names.

Solution:

select pg_class.relname from pg_class inner join 
pg_partitioned_table on pg_class.oid = pg_partitioned_table.partrelid where pg_partitioned_table.partstrat = 'r';

1 Answers1

0

For that, you have to consult the system catalog pg_partitioned_table. partstrat contains the partitioning strategy, partattrs the column numbers of the partitioning key columns and partexprs contains the parsed form of the parttioning expressions for the entries with 0 in partattrs.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • I wrote this query and it is work: ` select pg_class.relname from pg_class inner join pg_partitioned_table on pg_class.oid = pg_partitioned_table.partrelid where pg_partitioned_table.partstrat = 'r'; ` – Deniz Gölbaş Oct 10 '22 at 11:54