postgresql怎么查表的分区信息

avatar
作者
猴君
阅读量:0

要查看表的分区信息,可以使用以下两个 PostgreSQL 系统表:

  1. pg_partitioned_table:此表存储了所有被分区的表的信息。
  2. pg_partitioned_table:此表存储了每个分区的详细信息。

以下是一个示例查询,用于查看表的分区信息:

SELECT     parent.relname AS parent_table,     child.relname AS child_table,     pg_get_expr(partition_def, parent.oid) AS partition_expression FROM     pg_partitioned_table AS p JOIN     pg_class AS parent ON p.partrelid = parent.oid JOIN     pg_class AS child ON p.partid = child.oid JOIN     pg_partitioned_table AS pp ON pp.partrelid = child.oid ORDER BY     parent.relname,     child.relname; 

该查询将返回被分区的表的名称、每个分区的名称以及分区表达式。

请注意,您需要有足够的权限才能查询这些系统表。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!