pg_publication

存储数据库中创建的所有发布的系统表

pg_publication 是一个存储数据库中创建的所有发布系统目录表。

pg_publicationPostgreSQL 10 中添加。

各个表通过pg_publication_rel 表与订阅关联。

psql 命令

  • \dRp[+] - 列出可用的发布

按 PostgreSQL 版本定义

pg_publication (PostgreSQL 17)

            Table "pg_catalog.pg_publication"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 oid          | oid     |           | not null | 
 pubname      | name    |           | not null | 
 pubowner     | oid     |           | not null | 
 puballtables | boolean |           | not null | 
 pubinsert    | boolean |           | not null | 
 pubupdate    | boolean |           | not null | 
 pubdelete    | boolean |           | not null | 
 pubtruncate  | boolean |           | not null | 
 pubviaroot   | boolean |           | not null | 
Indexes:
    "pg_publication_oid_index" PRIMARY KEY, btree (oid)
    "pg_publication_pubname_index" UNIQUE CONSTRAINT, btree (pubname)
    

文档: pg_publication

pg_publication (PostgreSQL 16)

            Table "pg_catalog.pg_publication"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 oid          | oid     |           | not null | 
 pubname      | name    |           | not null | 
 pubowner     | oid     |           | not null | 
 puballtables | boolean |           | not null | 
 pubinsert    | boolean |           | not null | 
 pubupdate    | boolean |           | not null | 
 pubdelete    | boolean |           | not null | 
 pubtruncate  | boolean |           | not null | 
 pubviaroot   | boolean |           | not null | 
Indexes:
    "pg_publication_oid_index" PRIMARY KEY, btree (oid)
    "pg_publication_pubname_index" UNIQUE CONSTRAINT, btree (pubname)
    

文档: pg_publication

pg_publication (PostgreSQL 15)

            Table "pg_catalog.pg_publication"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 oid          | oid     |           | not null | 
 pubname      | name    |           | not null | 
 pubowner     | oid     |           | not null | 
 puballtables | boolean |           | not null | 
 pubinsert    | boolean |           | not null | 
 pubupdate    | boolean |           | not null | 
 pubdelete    | boolean |           | not null | 
 pubtruncate  | boolean |           | not null | 
 pubviaroot   | boolean |           | not null | 
Indexes:
    "pg_publication_oid_index" PRIMARY KEY, btree (oid)
    "pg_publication_pubname_index" UNIQUE CONSTRAINT, btree (pubname)
    

文档: pg_publication

pg_publication (PostgreSQL 14)

            Table "pg_catalog.pg_publication"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 oid          | oid     |           | not null | 
 pubname      | name    |           | not null | 
 pubowner     | oid     |           | not null | 
 puballtables | boolean |           | not null | 
 pubinsert    | boolean |           | not null | 
 pubupdate    | boolean |           | not null | 
 pubdelete    | boolean |           | not null | 
 pubtruncate  | boolean |           | not null | 
 pubviaroot   | boolean |           | not null | 
Indexes:
    "pg_publication_oid_index" PRIMARY KEY, btree (oid)
    "pg_publication_pubname_index" UNIQUE CONSTRAINT, btree (pubname)
    

文档: pg_publication

pg_publication (PostgreSQL 13)

            Table "pg_catalog.pg_publication"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 oid          | oid     |           | not null | 
 pubname      | name    |           | not null | 
 pubowner     | oid     |           | not null | 
 puballtables | boolean |           | not null | 
 pubinsert    | boolean |           | not null | 
 pubupdate    | boolean |           | not null | 
 pubdelete    | boolean |           | not null | 
 pubtruncate  | boolean |           | not null | 
 pubviaroot   | boolean |           | not null | 
Indexes:
    "pg_publication_oid_index" UNIQUE, btree (oid)
    "pg_publication_pubname_index" UNIQUE, btree (pubname)
    

文档: pg_publication

pg_publication (PostgreSQL 12)

            Table "pg_catalog.pg_publication"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 oid          | oid     |           | not null | 
 pubname      | name    |           | not null | 
 pubowner     | oid     |           | not null | 
 puballtables | boolean |           | not null | 
 pubinsert    | boolean |           | not null | 
 pubupdate    | boolean |           | not null | 
 pubdelete    | boolean |           | not null | 
 pubtruncate  | boolean |           | not null | 
Indexes:
    "pg_publication_oid_index" UNIQUE, btree (oid)
    "pg_publication_pubname_index" UNIQUE, btree (pubname)
    

文档: pg_publication

pg_publication (PostgreSQL 11)

            Table "pg_catalog.pg_publication"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 pubname      | name    |           | not null | 
 pubowner     | oid     |           | not null | 
 puballtables | boolean |           | not null | 
 pubinsert    | boolean |           | not null | 
 pubupdate    | boolean |           | not null | 
 pubdelete    | boolean |           | not null | 
 pubtruncate  | boolean |           | not null | 
Indexes:
    "pg_publication_oid_index" UNIQUE, btree (oid)
    "pg_publication_pubname_index" UNIQUE, btree (pubname)
    

文档: pg_publication

pg_publication (PostgreSQL 10)

            Table "pg_catalog.pg_publication"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 pubname      | name    |           | not null | 
 pubowner     | oid     |           | not null | 
 puballtables | boolean |           | not null | 
 pubinsert    | boolean |           | not null | 
 pubupdate    | boolean |           | not null | 
 pubdelete    | boolean |           | not null | 
Indexes:
    "pg_publication_oid_index" UNIQUE, btree (oid)
    "pg_publication_pubname_index" UNIQUE, btree (pubname)
    

文档: pg_publication

更改历史记录

示例

postgres=# CREATE PUBLICATION test_publication
             FOR TABLE foo;
CREATE PUBLICATION

postgres=# SELECT * FROM pg_publication\gx
-[ RECORD 1 ]+-----------------
oid          | 91147
pubname      | test_publication
pubowner     | 10
puballtables | f
pubinsert    | t
pubupdate    | t
pubdelete    | t
pubtruncate  | t
pubviaroot   | f

postgres=# \dRp
                                     List of publications
       Name       |  Owner   | All tables | Inserts | Updates | Deletes | Truncates | Via root
------------------+----------+------------+---------+---------+---------+-----------+----------
 test_publication | postgres | f          | t       | t       | t       | t         | f
(1 row)

postgres=# \dRp+
                        Publication test_publication
  Owner   | All tables | Inserts | Updates | Deletes | Truncates | Via root
----------+------------+---------+---------+---------+-----------+----------
 postgres | f          | t       | t       | t       | t         | f
Tables:
    "public.foo"

类别

复制系统目录

另请参阅

pg_publication_relpg_publication_namespaceALTER PUBLICATIONCREATE PUBLICATIONDROP PUBLICATION

反馈

提交任何关于 "pg_publication" 的评论、建议或更正 此处