ALTER PUBLICATION

An SQL command for modifying a publication

ALTER PUBLICATION is a DDL command for modifying a publication.

ALTER PUBLICATION was added in PostgreSQL 10.

Change history

Examples

Example usage for ALTER PUBLICATION:

postgres=# ALTER PUBLICATION test_publication RENAME TO foo;
ALTER PUBLICATION

Adding a table to an existing publication:

postgres=# ALTER PUBLICATION misc_publication ADD TABLE bar;
ALTER PUBLICATION

It is not possible to add tables to, or drop tables from a publication which was defined as "FOR ALL TABLES":

postgres=# ALTER PUBLICATION test_publication ADD TABLE bar;
ERROR:  publication "test_publication" is defined as FOR ALL TABLES
DETAIL:  Tables cannot be added to or dropped from FOR ALL TABLES publications.

postgres=# ALTER PUBLICATION test_publication DROP TABLE foo;
ERROR:  publication "test_publication" is defined as FOR ALL TABLES
DETAIL:  Tables cannot be added to or dropped from FOR ALL TABLES publications.

Attempting to alter a non-existent publication:

postgres=# ALTER PUBLICATION foo RENAME TO bar;
ERROR:  publication "foo" does not exist

Categories

DDL, Logical replication, SQL command

See also

CREATE PUBLICATION, DROP PUBLICATION, pg_publication, pg_publication_rel