summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/sql-alterpublication.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/sgml/html/sql-alterpublication.html')
-rw-r--r--doc/src/sgml/html/sql-alterpublication.html112
1 files changed, 112 insertions, 0 deletions
diff --git a/doc/src/sgml/html/sql-alterpublication.html b/doc/src/sgml/html/sql-alterpublication.html
new file mode 100644
index 0000000..94a155a
--- /dev/null
+++ b/doc/src/sgml/html/sql-alterpublication.html
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ALTER PUBLICATION</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-alterprocedure.html" title="ALTER PROCEDURE" /><link rel="next" href="sql-alterrole.html" title="ALTER ROLE" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">ALTER PUBLICATION</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-alterprocedure.html" title="ALTER PROCEDURE">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-alterrole.html" title="ALTER ROLE">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-ALTERPUBLICATION"><div class="titlepage"></div><a id="id-1.9.3.25.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">ALTER PUBLICATION</span></h2><p>ALTER PUBLICATION — change the definition of a publication</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
+ALTER PUBLICATION <em class="replaceable"><code>name</code></em> ADD <em class="replaceable"><code>publication_object</code></em> [, ...]
+ALTER PUBLICATION <em class="replaceable"><code>name</code></em> SET <em class="replaceable"><code>publication_object</code></em> [, ...]
+ALTER PUBLICATION <em class="replaceable"><code>name</code></em> DROP <em class="replaceable"><code>publication_object</code></em> [, ...]
+ALTER PUBLICATION <em class="replaceable"><code>name</code></em> SET ( <em class="replaceable"><code>publication_parameter</code></em> [= <em class="replaceable"><code>value</code></em>] [, ... ] )
+ALTER PUBLICATION <em class="replaceable"><code>name</code></em> OWNER TO { <em class="replaceable"><code>new_owner</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
+ALTER PUBLICATION <em class="replaceable"><code>name</code></em> RENAME TO <em class="replaceable"><code>new_name</code></em>
+
+<span class="phrase">where <em class="replaceable"><code>publication_object</code></em> is one of:</span>
+
+ TABLE [ ONLY ] <em class="replaceable"><code>table_name</code></em> [ * ] [ ( <em class="replaceable"><code>column_name</code></em> [, ... ] ) ] [ WHERE ( <em class="replaceable"><code>expression</code></em> ) ] [, ... ]
+ TABLES IN SCHEMA { <em class="replaceable"><code>schema_name</code></em> | CURRENT_SCHEMA } [, ... ]
+</pre></div><div class="refsect1" id="id-1.9.3.25.5"><h2>Description</h2><p>
+ The command <code class="command">ALTER PUBLICATION</code> can change the attributes
+ of a publication.
+ </p><p>
+ The first three variants change which tables/schemas are part of the
+ publication. The <code class="literal">SET</code> 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
+ <code class="literal">ADD</code> and <code class="literal">DROP</code> 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
+ <code class="literal">ALTER SUBSCRIPTION ... REFRESH PUBLICATION</code> action on the
+ subscribing side in order to become effective. Note also that
+ <code class="literal">DROP TABLES IN SCHEMA</code> will not drop any schema tables
+ that were specified using <code class="literal">FOR TABLE</code>/
+ <code class="literal">ADD TABLE</code>, and the combination of <code class="literal">DROP</code>
+ with a <code class="literal">WHERE</code> clause is not allowed.
+ </p><p>
+ The fourth variant of this command listed in the synopsis can change
+ all of the publication properties specified in
+ <a class="xref" href="sql-createpublication.html" title="CREATE PUBLICATION"><span class="refentrytitle">CREATE PUBLICATION</span></a>. Properties not mentioned in the
+ command retain their previous settings.
+ </p><p>
+ The remaining variants change the owner and the name of the publication.
+ </p><p>
+ You must own the publication to use <code class="command">ALTER PUBLICATION</code>.
+ Adding a table to a publication additionally requires owning that table.
+ The <code class="literal">ADD TABLES IN SCHEMA</code> and
+ <code class="literal">SET TABLES IN SCHEMA</code> to a publication requires the
+ invoking user to be a superuser. To alter the owner, you must also be a
+ direct or indirect member of the new owning role. The new owner must have
+ <code class="literal">CREATE</code> privilege on the database. Also, the new owner
+ of a <code class="literal">FOR ALL TABLES</code> or <code class="literal">FOR TABLES IN SCHEMA</code>
+ publication must be a superuser. However, a superuser can
+ change the ownership of a publication regardless of these restrictions.
+ </p><p>
+ Adding/Setting any schema when the publication also publishes a table with a
+ column list, and vice versa is not supported.
+ </p></div><div class="refsect1" id="id-1.9.3.25.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
+ The name of an existing publication whose definition is to be altered.
+ </p></dd><dt><span class="term"><em class="replaceable"><code>table_name</code></em></span></dt><dd><p>
+ Name of an existing table. If <code class="literal">ONLY</code> is specified before the
+ table name, only that table is affected. If <code class="literal">ONLY</code> is not
+ specified, the table and all its descendant tables (if any) are
+ affected. Optionally, <code class="literal">*</code> can be specified after the table
+ name to explicitly indicate that descendant tables are included.
+ </p><p>
+ Optionally, a column list can be specified. See <a class="xref" href="sql-createpublication.html" title="CREATE PUBLICATION"><span class="refentrytitle">CREATE PUBLICATION</span></a> 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
+ <a class="xref" href="logical-replication-col-lists.html#LOGICAL-REPLICATION-COL-LIST-COMBINING" title="Warning: Combining Column Lists from Multiple Publications">Warning: Combining Column Lists from Multiple Publications</a> for details of
+ potential problems when altering column lists.
+ </p><p>
+ If the optional <code class="literal">WHERE</code> clause is specified, rows for
+ which the <em class="replaceable"><code>expression</code></em>
+ evaluates to false or null will not be published. Note that parentheses
+ are required around the expression. The
+ <em class="replaceable"><code>expression</code></em> is evaluated with
+ the role used for the replication connection.
+ </p></dd><dt><span class="term"><em class="replaceable"><code>schema_name</code></em></span></dt><dd><p>
+ Name of an existing schema.
+ </p></dd><dt><span class="term"><code class="literal">SET ( <em class="replaceable"><code>publication_parameter</code></em> [= <em class="replaceable"><code>value</code></em>] [, ... ] )</code></span></dt><dd><p>
+ This clause alters publication parameters originally set by
+ <a class="xref" href="sql-createpublication.html" title="CREATE PUBLICATION"><span class="refentrytitle">CREATE PUBLICATION</span></a>. See there for more information.
+ </p></dd><dt><span class="term"><em class="replaceable"><code>new_owner</code></em></span></dt><dd><p>
+ The user name of the new owner of the publication.
+ </p></dd><dt><span class="term"><em class="replaceable"><code>new_name</code></em></span></dt><dd><p>
+ The new name for the publication.
+ </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.25.7"><h2>Examples</h2><p>
+ Change the publication to publish only deletes and updates:
+</p><pre class="programlisting">
+ALTER PUBLICATION noinsert SET (publish = 'update, delete');
+</pre><p>
+ </p><p>
+ Add some tables to the publication:
+</p><pre class="programlisting">
+ALTER PUBLICATION mypublication ADD TABLE users (user_id, firstname), departments;
+</pre><p>
+ Change the set of columns published for a table:
+</p><pre class="programlisting">
+ALTER PUBLICATION mypublication SET TABLE users (user_id, firstname, lastname), TABLE departments;
+</pre><p>
+ Add schemas <code class="structname">marketing</code> and
+ <code class="structname">sales</code> to the publication
+ <code class="structname">sales_publication</code>:
+</p><pre class="programlisting">
+ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA marketing, sales;
+</pre><p>
+ </p><p>
+ Add tables <code class="structname">users</code>,
+ <code class="structname">departments</code> and schema
+ <code class="structname">production</code> to the publication
+ <code class="structname">production_publication</code>:
+</p><pre class="programlisting">
+ALTER PUBLICATION production_publication ADD TABLE users, departments, TABLES IN SCHEMA production;
+</pre></div><div class="refsect1" id="id-1.9.3.25.8"><h2>Compatibility</h2><p>
+ <code class="command">ALTER PUBLICATION</code> is a <span class="productname">PostgreSQL</span>
+ extension.
+ </p></div><div class="refsect1" id="id-1.9.3.25.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-createpublication.html" title="CREATE PUBLICATION"><span class="refentrytitle">CREATE PUBLICATION</span></a>, <a class="xref" href="sql-droppublication.html" title="DROP PUBLICATION"><span class="refentrytitle">DROP PUBLICATION</span></a>, <a class="xref" href="sql-createsubscription.html" title="CREATE SUBSCRIPTION"><span class="refentrytitle">CREATE SUBSCRIPTION</span></a>, <a class="xref" href="sql-altersubscription.html" title="ALTER SUBSCRIPTION"><span class="refentrytitle">ALTER SUBSCRIPTION</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-alterprocedure.html" title="ALTER PROCEDURE">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-alterrole.html" title="ALTER ROLE">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ALTER PROCEDURE </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> ALTER ROLE</td></tr></table></div></body></html> \ No newline at end of file