postgresql怎么查表的分区信息

   2025-02-13 9200
核心提示:要查看表的分区信息,可以使用以下两个 PostgreSQL 系统表:pg_partitioned_table:此表存储了所有被分区的表的信息。pg_partiti

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

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

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

SELECT    parent.relname AS parent_table,    child.relname AS child_table,    pg_get_expr(partition_def, parent.oid) AS partition_expressionFROM    pg_partitioned_table AS pJOIN    pg_class AS parent ON p.partrelid = parent.oidJOIN    pg_class AS child ON p.partid = child.oidJOIN    pg_partitioned_table AS pp ON pp.partrelid = child.oidORDER BY    parent.relname,    child.relname;

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

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

 
 
更多>同类维修知识
推荐图文
推荐维修知识
点击排行
网站首页  |  关于我们  |  联系方式  |  用户协议  |  隐私政策  |  网站留言