我有一个分区表超出了主表的使用范围。
CREATE TABLE public.partition1 PARTITION OF public.maintable
FOR VALUES FROM ('2017-01-01 00:00:00') TO ('2050-01-01 00:00:00')
如何使用查询postgres来获取Values范围信息。
我使用了一个查询,它至少为我提供了主表和分区表的信息,但我似乎无法找到访问分配给表partition 1的值范围**FROM('2017 -01-01 00:00:00')TO('2050 -01-01 00:00:00')**的方法
用于获取分区表信息的查询
WITH RECURSIVE partition_info
(relid,
relname,
relsize,
relispartition,
relkind) AS
(
(SELECT oid AS relid,
relname,
pg_relation_size(oid) AS relsize,
relispartition,
relkind
FROM pg_catalog.pg_class
WHERE relname = 'completedorders' AND
relkind = 'p')
UNION ALL
(SELECT
c.oid AS relid,
c.relname AS relname,
pg_relation_size(c.oid) AS relsize,
c.relispartition AS relispartition,
c.relkind AS relkind
FROM partition_info AS p,
pg_catalog.pg_inherits AS i,
pg_catalog.pg_class AS c
WHERE p.relid = i.inhparent AND
c.oid = i.inhrelid AND
c.relispartition = true)
)
SELECT * FROM partition_info;
2条答案
按热度按时间rwqw0loc1#
下面的查询也提供了有关分区的信息。从那里它只是字符串操作,以获得进一步的信息。注意:需要在查询中更改表名。
u5rb5r592#
具有parent_schema和仅表relkind的版本: