バージョンごとのドキュメント一覧

ALTER PUBLICATION

ALTER PUBLICATION <refpurpose>change the definition of a publication</refpurpose> — パブリケーションの定義を変更する

概要

ALTER PUBLICATION name ADD publication_object [, ...]
ALTER PUBLICATION name SET publication_object [, ...]
ALTER PUBLICATION name DROP publication_object [, ...]
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


<phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase>

ここでpublication_objectは以下のいずれかです。

    TABLE [ ONLY ] table_name [ * ] [ ( column_name [, ... ] ) ] [ WHERE ( expression ) ] [, ... ]
    TABLES IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ]

説明

<title>Description</title>

The command <command>ALTER PUBLICATION</command> can change the attributes of a publication. コマンドALTER PUBLICATIONはパブリケーションの属性を変更できます。

The first three variants change which tables/schemas are part of the publication. The <literal>SET</literal> 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 <literal>ADD</literal> and <literal>DROP</literal> 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 <literal>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</literal> action on the subscribing side in order to become effective. Note also that <literal>DROP TABLES IN SCHEMA</literal> will not drop any schema tables that were specified using <link linkend="sql-createpublication-for-table"><literal>FOR TABLE</literal></link>/ <literal>ADD TABLE</literal>, and the combination of <literal>DROP</literal> with a <literal>WHERE</literal> clause is not allowed. 最初の3つの構文では、パブリケーションにどのテーブル/スキーマが含まれるかを変更します。 SET句は、パブリケーションのテーブル/スキーマのリストを指定したリストで置き換えます。パブリケーション内の既存のテーブル/スキーマは削除されます。 ADD句とDROP句はパブリケーションに1つ以上のテーブル/スキーマを追加または削除します。 既にサブスクライブされているパブリケーションにテーブル/スキーマを追加した場合、それを有効にするにはサブスクライブしている側でALTER SUBSCRIPTION ... REFRESH PUBLICATIONの操作を行う必要があることに注意してください。 DROP TABLES IN SCHEMAFOR TABLE/ADD TABLEを使って指定されたスキーマテーブルを削除せず、WHERE句のついたDROPとの組み合わせは認められていないことにも注意してください。

The fourth variant of this command listed in the synopsis can change all of the publication properties specified in <xref linkend="sql-createpublication"/>. Properties not mentioned in the command retain their previous settings. このコマンドの概要に挙げられている4番目の構文では、CREATE PUBLICATIONで指定されたすべてのパブリケーションの属性を変更できます。 このコマンドで属性を指定しなかったものについては、以前の設定が保持されます。

The remaining variants change the owner and the name of the publication. 残りの構文では、パブリケーションの所有者および名前を変更します。

You must own the publication to use <command>ALTER PUBLICATION</command>. Adding a table to a publication additionally requires owning that table. The <literal>ADD TABLES IN SCHEMA</literal> and <literal>SET TABLES IN SCHEMA</literal> to a publication requires the invoking user to be a superuser. To alter the owner, you must be able to <literal>SET ROLE</literal> to the new owning role, and that role must have <literal>CREATE</literal> privilege on the database. Also, the new owner of a <link linkend="sql-createpublication-for-all-tables"><literal>FOR ALL TABLES</literal></link> or <link linkend="sql-createpublication-for-tables-in-schema"><literal>FOR TABLES IN SCHEMA</literal></link> publication must be a superuser. However, a superuser can change the ownership of a publication regardless of these restrictions. ALTER PUBLICATIONを使用するには、そのパブリケーションを所有していなければなりません。 パブリケーションにテーブルを追加するには、さらにそのテーブルを所有していることが必要です。 パブリケーションへのADD TABLES IN SCHEMASET TABLES IN SCHEMAには、実行するユーザーがスーパーユーザであることが必要です。 所有者を変更するには、新しい所有者ロールに対してSET ROLEができなければなりません。また、そのロールはデータベースにCREATE権限を持っていなければなりません。 また、FOR ALL TABLESFOR TABLES IN SCHEMAのパブリケーションの新しい所有者はスーパーユーザでなければなりません。 しかし、スーパーユーザはこれらの制限に関わらずパブリケーションの所有者を変更できます。

Adding/Setting any schema when the publication also publishes a table with a column list, and vice versa is not supported. パブリケーションが列リストを持つテーブルもパブリッシュする場合、またはその逆の場合のスキーマの追加/設定はサポートされていません。

パラメータ

<title>Parameters</title>
name

The name of an existing publication whose definition is to be altered. 定義の変更の対象となる既存のパブリケーションの名前です。

table_name

Name of an existing table. If <literal>ONLY</literal> is specified before the table name, only that table is affected. If <literal>ONLY</literal> is not specified, the table and all its descendant tables (if any) are affected. Optionally, <literal>*</literal> can be specified after the table name to explicitly indicate that descendant tables are included. 既存のテーブルの名前です。 テーブル名の前にONLYが指定されたときは、そのテーブルだけが影響を受けます。 テーブル名の前にONLYが指定されていないときは、そのテーブルとそのすべての子テーブル(あれば)が影響を受けます。 オプションでテーブル名の後に*を指定して、子テーブルが含まれることを明示的に示すことができます。

Optionally, a column list can be specified. See <xref linkend="sql-createpublication"/> for details. Note that a subscription having several publications in which the same table has been published with different column lists is not supported. See <xref linkend="logical-replication-col-list-combining"/> for details of potential problems when altering column lists. オプションで、列リストを指定できます。 詳細はCREATE PUBLICATIONを参照してください。 同じテーブルが異なる列リストでパブリッシュされた複数のパブリケーションを持つサブスクリプションはサポートされていないことに注意してください。 列リストを変更するときに発生する可能性のある問題の詳細は警告: 複数のパブリケーションからの列リストの統合を参照してください。

If the optional <literal>WHERE</literal> clause is specified, rows for which the <replaceable class="parameter">expression</replaceable> evaluates to false or null will not be published. Note that parentheses are required around the expression. The <replaceable class="parameter">expression</replaceable> is evaluated with the role used for the replication connection. オプションのWHERE句が指定されている場合、expressionが偽またはNULLと評価される行はパブリッシュされません。 式を括弧で囲む必要があることに注意してください。 expressionは、レプリケーション接続に使用されるロールで評価されます。

schema_name

Name of an existing schema. 既存のスキーマの名前。

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

This clause alters publication parameters originally set by <xref linkend="sql-createpublication"/>. See there for more information. この句では、元はCREATE PUBLICATIONにより設定されたパブリケーションのパラメータを変更します。 詳細な情報はそちらを参照してください。

new_owner

The user name of the new owner of the publication. パブリケーションの新しい所有者のユーザ名です。

new_name

The new name for the publication. パブリケーションの新しい名前です。

<title>Examples</title>

Change the publication to publish only deletes and updates: deleteとupdateのみをパブリッシュするようにパブリケーションを変更します。

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 schemas <structname>marketing</structname> and <structname>sales</structname> to the publication <structname>sales_publication</structname>: パブリケーションsales_publicationにスキーマmarketingsalesを追加します。

ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA marketing, sales;

Add tables <structname>users</structname>, <structname>departments</structname> and schema <structname>production</structname> to the publication <structname>production_publication</structname>: パブリケーションproduction_publicationにテーブルusersdepartments、スキーマproductionを追加します。

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

互換性

<title>Compatibility</title>

<command>ALTER PUBLICATION</command> is a <productname>PostgreSQL</productname> extension. ALTER PUBLICATIONPostgreSQLの拡張です。

関連項目

<title>See Also</title> CREATE PUBLICATION, DROP PUBLICATION, CREATE SUBSCRIPTION, ALTER SUBSCRIPTION