1<!--
2doc/src/sgml/ref/drop_subscription.sgml
3PostgreSQL documentation
4-->
5
6<refentry id="sql-dropsubscription">
7 <indexterm zone="sql-dropsubscription">
8  <primary>DROP SUBSCRIPTION</primary>
9 </indexterm>
10
11 <refmeta>
12  <refentrytitle>DROP SUBSCRIPTION</refentrytitle>
13  <manvolnum>7</manvolnum>
14  <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
16
17 <refnamediv>
18  <refname>DROP SUBSCRIPTION</refname>
19  <refpurpose>remove a subscription</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23<synopsis>
24DROP SUBSCRIPTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
25</synopsis>
26 </refsynopsisdiv>
27
28 <refsect1>
29  <title>Description</title>
30
31  <para>
32   <command>DROP SUBSCRIPTION</command> removes a subscription from the
33   database cluster.
34  </para>
35
36  <para>
37   A subscription can only be dropped by a superuser.
38  </para>
39
40  <para>
41   <command>DROP SUBSCRIPTION</command> cannot be executed inside a
42   transaction block if the subscription is associated with a replication
43   slot.  (You can use <command>ALTER SUBSCRIPTION</command> to unset the
44   slot.)
45  </para>
46 </refsect1>
47
48 <refsect1>
49  <title>Parameters</title>
50
51  <variablelist>
52   <varlistentry>
53    <term><replaceable class="parameter">name</replaceable></term>
54    <listitem>
55     <para>
56      The name of a subscription to be dropped.
57     </para>
58    </listitem>
59   </varlistentry>
60
61   <varlistentry>
62    <term><literal>CASCADE</literal></term>
63    <term><literal>RESTRICT</literal></term>
64
65    <listitem>
66     <para>
67      These key words do not have any effect, since there are no dependencies
68      on subscriptions.
69     </para>
70    </listitem>
71   </varlistentry>
72
73  </variablelist>
74 </refsect1>
75
76 <refsect1>
77  <title>Notes</title>
78
79  <para>
80   When dropping a subscription that is associated with a replication slot on
81   the remote host (the normal state), <command>DROP SUBSCRIPTION</command>
82   will connect to the remote host and try to drop the replication slot as
83   part of its operation.  This is necessary so that the resources allocated
84   for the subscription on the remote host are released.  If this fails,
85   either because the remote host is not reachable or because the remote
86   replication slot cannot be dropped or does not exist or never existed,
87   the <command>DROP SUBSCRIPTION</command> command will fail.  To proceed in
88   this situation, disassociate the subscription from the replication slot by
89   executing <literal>ALTER SUBSCRIPTION ... SET (slot_name = NONE)</literal>.
90   After that, <command>DROP SUBSCRIPTION</command> will no longer attempt any
91   actions on a remote host.  Note that if the remote replication slot still
92   exists, it should then be dropped manually; otherwise it will continue to
93   reserve WAL and might eventually cause the disk to fill up.  See
94   also <xref linkend="logical-replication-subscription-slot"/>.
95  </para>
96
97  <para>
98   If a subscription is associated with a replication slot, then <command>DROP
99   SUBSCRIPTION</command> cannot be executed inside a transaction block.
100  </para>
101 </refsect1>
102
103 <refsect1>
104  <title>Examples</title>
105
106  <para>
107   Drop a subscription:
108<programlisting>
109DROP SUBSCRIPTION mysub;
110</programlisting></para>
111 </refsect1>
112
113 <refsect1>
114  <title>Compatibility</title>
115
116  <para>
117   <command>DROP SUBSCRIPTION</command> is a <productname>PostgreSQL</productname>
118   extension.
119  </para>
120 </refsect1>
121
122 <refsect1>
123  <title>See Also</title>
124
125  <simplelist type="inline">
126   <member><xref linkend="sql-createsubscription"/></member>
127   <member><xref linkend="sql-altersubscription"/></member>
128  </simplelist>
129 </refsect1>
130</refentry>
131