溫馨提示×

postgresql怎么查表的分區信息

小億
1672
2023-12-13 20:40:12
欄目: 云計算

要查看表的分區信息,可以使用以下兩個 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;

該查詢將返回被分區的表的名稱、每個分區的名稱以及分區表達式。

請注意,您需要有足夠的權限才能查詢這些系統表。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女