Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
ALTER PUBLICATION
Prev UpSQL CommandsHome Next

ALTER PUBLICATION

ALTER PUBLICATION — change the definition of a publication

Synopsis

ALTER PUBLICATIONname ADDpublication_object [, ...]ALTER PUBLICATIONname SETpublication_object [, ...]ALTER PUBLICATIONname DROPpublication_object [, ...]ALTER PUBLICATIONname SET (publication_parameter [=value] [, ... ] )ALTER PUBLICATIONname OWNER TO {new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }ALTER PUBLICATIONname RENAME TOnew_namewherepublication_object is one of:    TABLE [ ONLY ]table_name [ * ] [ (column_name [, ... ] ) ] [ WHERE (expression ) ] [, ... ]    TABLES IN SCHEMA {schema_name | CURRENT_SCHEMA } [, ... ]

Description

The commandALTER PUBLICATION can change the attributes of a publication.

The first three variants change which tables/schemas are part of the publication. TheSET 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. TheADD andDROP 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 anALTER SUBSCRIPTION ... REFRESH PUBLICATION action on the subscribing side in order to become effective. Note also thatDROP TABLES IN SCHEMA will not drop any schema tables that were specified usingFOR TABLE/ADD TABLE, and the combination ofDROP with aWHERE clause is not allowed.

The fourth variant of this command listed in the synopsis can change all of the publication properties specified inCREATE PUBLICATION. 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 useALTER PUBLICATION. Adding a table to a publication additionally requires owning that table. TheADD TABLES IN SCHEMA andSET TABLES IN SCHEMA to a publication requires the invoking user to be a superuser. To alter the owner, you must be able toSET ROLE to the new owning role, and that role must haveCREATE privilege on the database. Also, the new owner of aFOR ALL TABLES orFOR 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.

Parameters

name

The name of an existing publication whose definition is to be altered.

table_name

Name of an existing table. IfONLY is specified before the table name, only that table is affected. IfONLY 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.

Optionally, a column list can be specified. SeeCREATE PUBLICATION for details. Note that a subscription having several publications in which the same table has been published with different column lists is not supported. SeeWarning: Combining Column Lists from Multiple Publications for details of potential problems when altering column lists.

If the optionalWHERE clause is specified, rows for which theexpression evaluates to false or null will not be published. Note that parentheses are required around the expression. Theexpression is evaluated with the role used for the replication connection.

schema_name

Name of an existing schema.

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

This clause alters publication parameters originally set byCREATE PUBLICATION. 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 (user_id, firstname), departments;

Change the set of columns published for a table:

ALTER PUBLICATION mypublication SET TABLE users (user_id, firstname, lastname), TABLE departments;

Add schemasmarketing andsales to the publicationsales_publication:

ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA marketing, sales;

Add tablesusers,departments and schemaproduction to the publicationproduction_publication:

ALTER PUBLICATION production_publication ADD TABLE users, departments, TABLES IN SCHEMA production;

Compatibility

ALTER PUBLICATION is aPostgres Pro extension.


Prev Up Next
ALTER PROFILE Home ALTER ROLE
pdfepub
Go to Postgres Pro Standard 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp