CREATE PUBLICATION CREATE PUBLICATION 7 SQL - Language Statements CREATE PUBLICATION define a new publication CREATE PUBLICATION name [ FOR TABLE table_name [, ...] | FOR ALL TABLES ] [ WITH ( option [, ... ] ) ] where option can be: PUBLISH INSERT | NOPUBLISH INSERT | PUBLISH UPDATE | NOPUBLISH UPDATE | PUBLISH DELETE | NOPUBLISH DELETE 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. See 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. FOR ALL TABLES Marks the publication as one that replicates changes for all tables in the database, including tables created in the future. PUBLISH INSERT NOPUBLISH INSERT These clauses determine whether the new publication will send the INSERT operations to the subscribers. PUBLISH INSERT is the default. PUBLISH UPDATE NOPUBLISH UPDATE These clauses determine whether the new publication will send the UPDATE operations to the subscribers. PUBLISH UPDATE is the default. PUBLISH DELETE NOPUBLISH DELETE These clauses determine whether the new publication will send the DELETE operations to the subscribers. PUBLISH DELETE is the default. Notes If neither FOR TABLE nor FOR 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 the CREATE privilege for the current database. (Of course, superusers bypass this check.) To add a table to a publication, the invoking user must have SELECT privilege on given table. The FOR ALL TABLES clause requires superuser. The tables added to a publication that publishes UPDATE and/or DELETE operations must have REPLICA IDENTITY defined. Otherwise those operations will be disallowed on those tables. For an INSERT ... ON CONFLICT command, the publication will publish the operation that actually results from the command. So depending of the outcome, it may be published as either INSERT or UPDATE, or it may not be published at all. TRUNCATE and other DDL operations are not published. Examples Create a simple publication that just publishes all DML for tables in it: CREATE PUBLICATION mypublication; Create an insert-only publication: CREATE PUBLICATION insert_only WITH (NOPUBLISH UPDATE, NOPUBLISH DELETE); Compatibility CREATE PUBLICATION is a PostgreSQL extension. See Also