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';
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
.