pg_publication_tables 是一个 系统目录 视图,它列出了 发布 与其包含的表之间的映射关系。
pg_publication_tables 在 PostgreSQL 10 中被添加。
按 PostgreSQL 版本定义
pg_publication_tables (PostgreSQL 19)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+--------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
attnames | name[] | | |
rowfilter | text | | |
pg_publication_tables (PostgreSQL 18)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+--------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
attnames | name[] | | |
rowfilter | text | | |
pg_publication_tables (PostgreSQL 17)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+--------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
attnames | name[] | | |
rowfilter | text | | |
pg_publication_tables (PostgreSQL 16)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+--------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
attnames | name[] | | |
rowfilter | text | | |
pg_publication_tables (PostgreSQL 15)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+--------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
attnames | name[] | | |
rowfilter | text | | |
pg_publication_tables (PostgreSQL 14)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
pg_publication_tables (PostgreSQL 13)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
pg_publication_tables (PostgreSQL 12)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
pg_publication_tables (PostgreSQL 11)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
pg_publication_tables (PostgreSQL 10)
View "pg_catalog.pg_publication_tables"
Column | Type | Collation | Nullable | Default
------------+------+-----------+----------+---------
pubname | name | | |
schemaname | name | | |
tablename | name | | |
变更历史
自 PostgreSQL 10 引入以来,此视图一直保持不变。
- PostgreSQL 10
- 添加于 (提交 665d1fad)
示例
pg_publication_tables 的示例用法
postgres=# \dt
List of relations
Schema | Name | Type | Owner
--------+------+-------+----------
public | bar | table | postgres
public | foo | table | postgres
(2 rows)
postgres=# CREATE PUBLICATION foo_publication
FOR TABLE foo;
CREATE PUBLICATION
postgres=# CREATE PUBLICATION all_publication
FOR ALL TABLES;
CREATE PUBLICATION
postgres=# SELECT * FROM pg_publication_tables;
pubname | schemaname | tablename
-----------------+------------+-----------
foo_publication | public | foo
all_publication | public | foo
all_publication | public | bar
(3 rows)
参考资料
- PostgreSQL 文档: pg_publication_tables
