pg_publication_rel
是一个存储关系和发布之间映射的系统目录表。
pg_publication_rel
在PostgreSQL 10 中添加。
视图pg_publication_tables
提供了该表的易于理解版本。
请注意,只有显式添加到发布的关系(例如,CREATE PUBLICATION ... FOR TABLE ...
)才会记录在此表中。使用 CREATE PUBLICATION ... FOR ALL TABLES
创建的发布中的表不会记录在pg_publication_rel
中,但将在pg_publication_tables
中可见。
按 PostgreSQL 版本定义
pg_publication_rel (PostgreSQL 17)
Table "pg_catalog.pg_publication_rel" Column | Type | Collation | Nullable | Default ---------+--------------+-----------+----------+--------- oid | oid | | not null | prpubid | oid | | not null | prrelid | oid | | not null | prqual | pg_node_tree | C | | prattrs | int2vector | | | Indexes: "pg_publication_rel_oid_index" PRIMARY KEY, btree (oid) "pg_publication_rel_prpubid_index" btree (prpubid) "pg_publication_rel_prrelid_prpubid_index" UNIQUE CONSTRAINT, btree (prrelid, prpubid)
pg_publication_rel (PostgreSQL 16)
Table "pg_catalog.pg_publication_rel" Column | Type | Collation | Nullable | Default ---------+--------------+-----------+----------+--------- oid | oid | | not null | prpubid | oid | | not null | prrelid | oid | | not null | prqual | pg_node_tree | C | | prattrs | int2vector | | | Indexes: "pg_publication_rel_oid_index" PRIMARY KEY, btree (oid) "pg_publication_rel_prpubid_index" btree (prpubid) "pg_publication_rel_prrelid_prpubid_index" UNIQUE CONSTRAINT, btree (prrelid, prpubid)
pg_publication_rel (PostgreSQL 15)
Table "pg_catalog.pg_publication_rel" Column | Type | Collation | Nullable | Default ---------+--------------+-----------+----------+--------- oid | oid | | not null | prpubid | oid | | not null | prrelid | oid | | not null | prqual | pg_node_tree | C | | prattrs | int2vector | | | Indexes: "pg_publication_rel_oid_index" PRIMARY KEY, btree (oid) "pg_publication_rel_prpubid_index" btree (prpubid) "pg_publication_rel_prrelid_prpubid_index" UNIQUE CONSTRAINT, btree (prrelid, prpubid)
pg_publication_rel (PostgreSQL 14)
Table "pg_catalog.pg_publication_rel" Column | Type | Collation | Nullable | Default ---------+------+-----------+----------+--------- oid | oid | | not null | prpubid | oid | | not null | prrelid | oid | | not null | Indexes: "pg_publication_rel_oid_index" PRIMARY KEY, btree (oid) "pg_publication_rel_prrelid_prpubid_index" UNIQUE CONSTRAINT, btree (prrelid, prpubid)
pg_publication_rel (PostgreSQL 13)
Table "pg_catalog.pg_publication_rel" Column | Type | Collation | Nullable | Default ---------+------+-----------+----------+--------- oid | oid | | not null | prpubid | oid | | not null | prrelid | oid | | not null | Indexes: "pg_publication_rel_oid_index" UNIQUE, btree (oid) "pg_publication_rel_prrelid_prpubid_index" UNIQUE, btree (prrelid, prpubid)
pg_publication_rel (PostgreSQL 12)
Table "pg_catalog.pg_publication_rel" Column | Type | Collation | Nullable | Default ---------+------+-----------+----------+--------- oid | oid | | not null | prpubid | oid | | not null | prrelid | oid | | not null | Indexes: "pg_publication_rel_oid_index" UNIQUE, btree (oid) "pg_publication_rel_prrelid_prpubid_index" UNIQUE, btree (prrelid, prpubid)
pg_publication_rel (PostgreSQL 11)
Table "pg_catalog.pg_publication_rel" Column | Type | Collation | Nullable | Default ---------+------+-----------+----------+--------- prpubid | oid | | not null | prrelid | oid | | not null | Indexes: "pg_publication_rel_oid_index" UNIQUE, btree (oid) "pg_publication_rel_prrelid_prpubid_index" UNIQUE, btree (prrelid, prpubid)
pg_publication_rel (PostgreSQL 10)
Table "pg_catalog.pg_publication_rel" Column | Type | Collation | Nullable | Default ---------+------+-----------+----------+--------- prpubid | oid | | not null | prrelid | oid | | not null | Indexes: "pg_publication_rel_oid_index" UNIQUE, btree (oid) "pg_publication_rel_prrelid_prpubid_index" UNIQUE, btree (prrelid, prpubid)
变更历史
自它在PostgreSQL 10 中添加以来,此表没有被修改。
- PostgreSQL 10
- (提交 665d1fad)
示例
如果为一个或多个指定的表创建发布,则会在pg_publication_rel
中为每个表创建一个条目,将其与该发布关联起来。
postgres=# CREATE PUBLICATION test_publication FOR TABLE foo; CREATE PUBLICATION postgres=# SELECT *, prrelid::regclass AS table FROM pg_publication_rel; oid | prpubid | prrelid | table -------+---------+---------+------- 16394 | 16393 | 16390 | foo (1 row)
参考资料
- PostgreSQL 文档: pg_publication_rel