ALTER_PUBLICATION(7pg14)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ’– ALTER_PUBLICATION(7) πŸ’–

Okay bestie, welcome to the ALTER_PUBLICATION(7) page from the PostgreSQL 14.24 docs. This is the little command that changes the definition of a publication, and we’re gonna make it make sense. 🫢

✨ NAME ✨

ALTER_PUBLICATION β€” change the definition of a publication.

🌸 SYNOPSIS 🌸

Here’s the whole lineup, verbatim, no cap:

ALTER PUBLICATION name ADD TABLE [ ONLY ] table_name [ * ] [, ...]
ALTER PUBLICATION name SET TABLE [ ONLY ] table_name [ * ] [, ...]
ALTER PUBLICATION name DROP TABLE [ ONLY ] table_name [ * ] [, ...]
ALTER PUBLICATION name SET ( publication_parameter [= value] [, ... ] )
ALTER PUBLICATION name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER PUBLICATION name RENAME TO new_name

πŸ¦‹ DESCRIPTION πŸ¦‹

The command ALTER PUBLICATION can change the attributes of a publication. Main character energy, honestly. πŸ’…

The first three variants change which tables are part of the publication. The SET TABLE clause will replace the list of tables in the publication with the specified one. The ADD TABLE and DROP TABLE clauses will add and remove one or more tables from the publication. Note that adding tables 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. Like, the subscription side has to refresh to see the new table β€” iykyk. πŸŽ€

The fourth variant of this command listed in the synopsis can change all of the publication properties specified in CREATE PUBLICATION (CREATE_PUBLICATION(7)). Properties not mentioned in the command retain their previous settings. So whatever you don’t touch stays exactly where it was. ✨

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. To alter the owner, you must also be a direct or indirect member of the new owning role. The new owner must have CREATE privilege on the database. Also, the new owner of a FOR ALL TABLES publication must be a superuser. However, a superuser can change the ownership of a publication regardless of these restrictions. Big permissions vibe check β€” don’t skip it. πŸ”₯

πŸ’œ PARAMETERS πŸ’œ

  • name β€” the name of an existing publication whose definition is to be altered.
  • table_name β€” name of an existing table. If ONLY is specified before the table name, only that table is affected. If ONLY is not specified, the table and all its descendant tables (if any) are affected. Optionally, * can be specified after the table name to explicitly indicate that descendant tables are included.
  • SET ( publication_parameter [= value] [, ... ] ) β€” this clause alters publication parameters originally set by CREATE PUBLICATION (CREATE_PUBLICATION(7)). See there for more information.
  • new_owner β€” the user name of the new owner of the publication.
  • new_name β€” the new name for the publication.

🌈 EXAMPLES 🌈

Change the publication to publish only deletes and updates:

ALTER PUBLICATION noinsert SET (publish = 'update, delete');

Add some tables to the publication:

ALTER PUBLICATION mypublication ADD TABLE users, departments;

⭐ COMPATIBILITY ⭐

ALTER PUBLICATION is a PostgreSQL extension.

πŸ¦„ SEE ALSO πŸ¦„


Mwah πŸ’‹ β€” this ALTER_PUBLICATION(7) page is from PostgreSQL 14.24, dated 2026. Go forth and alter those publications, bestie. πŸ‘‘

πŸ“¦ where this page comes from