postgresql_16:7.1.23.1 Description
PostgreSQL 16 > Reference > SQL Commands > ALTER PUBLICATION > Description
The command ALTER PUBLICATION can change the attributes of a publication.
The first three variants change which tables/schemas are part of the publication. The SET clause will replace the list of tables/schemas in the publication with the specified list; the existing tables/schemas that were present in the publication will be removed. The ADD and DROP clauses will add and remove one or more tables/schemas from the publication. Note that adding tables/schemas to a publication that is already subscribed to will require an ALTER SUBSCRIPTION ... REFRESH PUBLICATION action on the subscribing side in order to become effective. Note also that DROP TABLES IN SCHEMA will not drop any schema tables that were specified using FOR TABLE (see sql-createpublication-for-table)/ ADD TABLE.
The fourth variant of this command listed in the synopsis can change all of the publication properties specified in (see postgresql_16:7.1.75). Properties not mentioned in the command retain their previous settings.
The remaining variants change the owner and the name of the publication.
You must own the publication to use ALTER PUBLICATION. Adding a table to a publication additionally requires owning that table. The ADD TABLES IN SCHEMA and SET TABLES IN SCHEMA to a publication requires the invoking user to be a superuser. To alter the owner, you must be able to SET ROLE to the new owning role, and that role must have CREATE privilege on the database. Also, the new owner of a FOR ALL TABLES (see sql-createpublication-for-all-tables) or FOR TABLES IN SCHEMA (see sql-createpublication-for-tables-in-schema) publication must be a superuser. However, a superuser can change the ownership of a publication regardless of these restrictions.
Adding/Setting any schema when the publication also publishes a table with a column list, and vice versa is not supported.