Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
CREATE PUBLICATION
Prev UpSQL CommandsHome Next

CREATE PUBLICATION

CREATE PUBLICATION — define a new publication

Synopsis

CREATE PUBLICATIONname    [ FOR TABLE [ ONLY ]table_name [ * ] [, ...]      | FOR ALL TABLES ]    [ WITH (publication_parameter [=value] [, ... ] ) ]

Description

CREATE PUBLICATION adds a new publication into the current database. The publication name must be distinct from the name of any existing publication in the current database.

A publication is essentially a group of tables whose data changes are intended to be replicated through logical replication. SeeSection 31.1 for details about how publications fit into the logical replication setup.

Parameters

name

The name of the new publication.

FOR TABLE

Specifies a list of tables to add to the publication. IfONLY is specified before the table name, only that table is added to the publication. IfONLY is not specified, the table and all its descendant tables (if any) are added. Optionally,* can be specified after the table name to explicitly indicate that descendant tables are included.

Only persistent base tables can be part of a publication. Temporary tables, unlogged tables, foreign tables, materialized views, regular views, and partitioned tables cannot be part of a publication. To replicate a partitioned table, add the individual partitions to the publication.

FOR ALL TABLES

Marks the publication as one that replicates changes for all tables in the database, including tables created in the future.

WITH (publication_parameter [=value] [, ... ] )

This clause specifies optional parameters for a publication. The following parameters are supported:

publish (string)

This parameter determines which DML operations will be published by the new publication to the subscribers. The value is comma-separated list of operations. The allowed operations areinsert,update,delete, andtruncate. The default is to publish all actions, and so the default value for this option is'insert, update, delete, truncate'.

Notes

If neitherFOR TABLE norFOR ALL TABLES is specified, then the publication starts out with an empty set of tables. That is useful if tables are to be added later.

The creation of a publication does not start replication. It only defines a grouping and filtering logic for future subscribers.

To create a publication, the invoking user must have theCREATE privilege for the current database. (Of course, superusers bypass this check.)

To add a table to a publication, the invoking user must have ownership rights on the table. TheFOR ALL TABLES clause requires the invoking user to be a superuser.

The tables added to a publication that publishesUPDATE and/orDELETE operations must haveREPLICA IDENTITY defined. Otherwise those operations will be disallowed on those tables.

For anINSERT ... ON CONFLICT command, the publication will publish the operation that results from the command. Depending on the outcome, it may be published as eitherINSERT orUPDATE, or it may not be published at all.

COPY ... FROM commands are published asINSERT operations.

DDL operations are not published.


Prev Up Next
CREATE PROCEDURE Home CREATE ROLE
epubpdf
Go to PostgreSQL 11
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp