pg_partitioned_table

存储表分区信息的系统表

pg_partitioned_table 是一个 系统目录 表,用于存储在 pg_class 中定义的且 relkind 为 'p' 的表的表分区信息。

pg_partitioned_table 添加于 PostgreSQL 10

按PostgreSQL版本定义

pg_partitioned_table (PostgreSQL 17)

            Table "pg_catalog.pg_partitioned_table"
    Column     |     Type     | Collation | Nullable | Default 
---------------+--------------+-----------+----------+---------
 partrelid     | oid          |           | not null | 
 partstrat     | "char"       |           | not null | 
 partnatts     | smallint     |           | not null | 
 partdefid     | oid          |           | not null | 
 partattrs     | int2vector   |           | not null | 
 partclass     | oidvector    |           | not null | 
 partcollation | oidvector    |           | not null | 
 partexprs     | pg_node_tree | C         |          | 
Indexes:
    "pg_partitioned_table_partrelid_index" PRIMARY KEY, btree (partrelid)
    

文档: pg_partitioned_table

pg_partitioned_table (PostgreSQL 16)

            Table "pg_catalog.pg_partitioned_table"
    Column     |     Type     | Collation | Nullable | Default 
---------------+--------------+-----------+----------+---------
 partrelid     | oid          |           | not null | 
 partstrat     | "char"       |           | not null | 
 partnatts     | smallint     |           | not null | 
 partdefid     | oid          |           | not null | 
 partattrs     | int2vector   |           | not null | 
 partclass     | oidvector    |           | not null | 
 partcollation | oidvector    |           | not null | 
 partexprs     | pg_node_tree | C         |          | 
Indexes:
    "pg_partitioned_table_partrelid_index" PRIMARY KEY, btree (partrelid)
    

文档: pg_partitioned_table

pg_partitioned_table (PostgreSQL 15)

            Table "pg_catalog.pg_partitioned_table"
    Column     |     Type     | Collation | Nullable | Default 
---------------+--------------+-----------+----------+---------
 partrelid     | oid          |           | not null | 
 partstrat     | "char"       |           | not null | 
 partnatts     | smallint     |           | not null | 
 partdefid     | oid          |           | not null | 
 partattrs     | int2vector   |           | not null | 
 partclass     | oidvector    |           | not null | 
 partcollation | oidvector    |           | not null | 
 partexprs     | pg_node_tree | C         |          | 
Indexes:
    "pg_partitioned_table_partrelid_index" PRIMARY KEY, btree (partrelid)
    

文档: pg_partitioned_table

pg_partitioned_table (PostgreSQL 14)

            Table "pg_catalog.pg_partitioned_table"
    Column     |     Type     | Collation | Nullable | Default 
---------------+--------------+-----------+----------+---------
 partrelid     | oid          |           | not null | 
 partstrat     | "char"       |           | not null | 
 partnatts     | smallint     |           | not null | 
 partdefid     | oid          |           | not null | 
 partattrs     | int2vector   |           | not null | 
 partclass     | oidvector    |           | not null | 
 partcollation | oidvector    |           | not null | 
 partexprs     | pg_node_tree | C         |          | 
Indexes:
    "pg_partitioned_table_partrelid_index" PRIMARY KEY, btree (partrelid)
    

文档: pg_partitioned_table

pg_partitioned_table (PostgreSQL 13)

            Table "pg_catalog.pg_partitioned_table"
    Column     |     Type     | Collation | Nullable | Default 
---------------+--------------+-----------+----------+---------
 partrelid     | oid          |           | not null | 
 partstrat     | "char"       |           | not null | 
 partnatts     | smallint     |           | not null | 
 partdefid     | oid          |           | not null | 
 partattrs     | int2vector   |           | not null | 
 partclass     | oidvector    |           | not null | 
 partcollation | oidvector    |           | not null | 
 partexprs     | pg_node_tree | C         |          | 
Indexes:
    "pg_partitioned_table_partrelid_index" UNIQUE, btree (partrelid)
    

文档: pg_partitioned_table

pg_partitioned_table (PostgreSQL 12)

            Table "pg_catalog.pg_partitioned_table"
    Column     |     Type     | Collation | Nullable | Default 
---------------+--------------+-----------+----------+---------
 partrelid     | oid          |           | not null | 
 partstrat     | "char"       |           | not null | 
 partnatts     | smallint     |           | not null | 
 partdefid     | oid          |           | not null | 
 partattrs     | int2vector   |           | not null | 
 partclass     | oidvector    |           | not null | 
 partcollation | oidvector    |           | not null | 
 partexprs     | pg_node_tree | C         |          | 
Indexes:
    "pg_partitioned_table_partrelid_index" UNIQUE, btree (partrelid)
    

文档: pg_partitioned_table

pg_partitioned_table (PostgreSQL 11)

            Table "pg_catalog.pg_partitioned_table"
    Column     |     Type     | Collation | Nullable | Default 
---------------+--------------+-----------+----------+---------
 partrelid     | oid          |           | not null | 
 partstrat     | "char"       |           | not null | 
 partnatts     | smallint     |           | not null | 
 partdefid     | oid          |           | not null | 
 partattrs     | int2vector   |           | not null | 
 partclass     | oidvector    |           | not null | 
 partcollation | oidvector    |           | not null | 
 partexprs     | pg_node_tree |           |          | 
Indexes:
    "pg_partitioned_table_partrelid_index" UNIQUE, btree (partrelid)
    

文档: pg_partitioned_table

pg_partitioned_table (PostgreSQL 10)

            Table "pg_catalog.pg_partitioned_table"
    Column     |     Type     | Collation | Nullable | Default 
---------------+--------------+-----------+----------+---------
 partrelid     | oid          |           | not null | 
 partstrat     | "char"       |           | not null | 
 partnatts     | smallint     |           | not null | 
 partattrs     | int2vector   |           | not null | 
 partclass     | oidvector    |           | not null | 
 partcollation | oidvector    |           | not null | 
 partexprs     | pg_node_tree |           |          | 
Indexes:
    "pg_partitioned_table_partrelid_index" UNIQUE, btree (partrelid)
    

文档: pg_partitioned_table

更改历史记录

示例

在从 PostgreSQL 分区文档 创建示例表之后

postgres=# CREATE TABLE measurement (
               city_id         int not null,
               logdate         date not null,
               peaktemp        int,
               unitsales       int
           ) PARTITION BY RANGE (logdate);
CREATE TABLE

以下条目将添加到 pg_partitioned_table

postgres=# SELECT * FROM pg_partitioned_table WHERE partrelid='measurement'::REGCLASS\gx
-[ RECORD 1 ]-+------
partrelid     | 17824
partstrat     | r
partnatts     | 1
partdefid     | 0
partattrs     | 2
partclass     | 3122
partcollation | 0
partexprs     |

分类

分区, 系统目录

另请参阅

pg_inherits, pg_get_partkeydef(), 声明式分区

反馈

提交您对 "pg_partitioned_table" 的任何评论、建议或更正 在此处