Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/ref/alter_publication.sgml`
bc798af2187d545ceaa179302e8f97842c9b0c196e88bb180000000100000cac
 )</literal></term>
    <listitem>
     <para>
      This clause alters publication parameters originally set by
      <xref linkend="sql-createpublication"/>.  See there for more information.
     </para>
     <caution>
      <para>
       Altering the <literal>publish_via_partition_root</literal> parameter can
       lead to data loss or duplication at the subscriber because it changes
       the identity and schema of the published tables. Note this happens only
       when a partition root table is specified as the replication target.
      </para>
      <para>
       This problem can be avoided by refraining from modifying partition leaf
       tables after the <command>ALTER PUBLICATION ... SET</command> until the
       <link linkend="sql-altersubscription"><command>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</command></link>
       is executed and by only refreshing using the <literal>copy_data = off</literal>
       option.
      </para>
     </caution>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">new_owner</replaceable></term>
    <listitem>
     <para>
      The user name of the new owner of the publication.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">new_name</replaceable></term>
    <listitem>
     <para>
      The new name for the publication.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1>
  <title>Examples</title>

  <para>
   Change the publication to publish only deletes and updates:
<programlisting>
ALTER PUBLICATION noinsert SET (publish = 'update, delete');
</programlisting>
  </para>

  <para>
   Add some tables to the publication:
<programlisting>
ALTER PUBLICATION mypublication ADD TABLE users (user_id, firstname), departments;
</programlisting></para>

  <para>
   Change the set of columns published for a table:
<programlisting>
ALTER PUBLICATION mypublication SET TABLE users (user_id, firstname, lastname), TABLE departments;
</programlisting></para>

  <para>
   Add schemas <structname>marketing</structname> and
   <structname>sales</structname> to the publication
   <structname>sales_publication</structname>:
<programlisting>
ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA marketing, sales;
</programlisting>
  </para>

  <para>
   Add tables <structname>users</structname>,
   <structname>departments</structname> and schema
   <structname>production</structname> to the publication
   <structname>production_publication</structname>:
<programlisting>
ALTER PUBLICATION production_publication ADD TABLE users, departments, TABLES IN SCHEMA production;
</programlisting></para>
 </refsect1>

 <refsect1>
  <title>Compatibility</title>

  <para>
   <command>ALTER PUBLICATION</command> is a <productname>PostgreSQL</productname>
   extension.
  </para>
 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-createpublication"/></member>
   <member><xref linkend="sql-droppublication"/></member>
   <member><xref linkend="sql-createsubscription"/></member>
   <member><xref linkend="sql-altersubscription"/></member>
  </simplelist>
 </refsect1>
</refentry>

Title: ALTER PUBLICATION - Parameters and Examples
Summary
This section details the new_owner and new_name parameters for the ALTER PUBLICATION command. It then provides several examples of how to use ALTER PUBLICATION to modify publication settings, such as changing published actions, adding tables, modifying published columns, and adding schemas to a publication. It also includes compatibility information and related commands.