codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!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>DROP SUBSCRIPTION</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-dropstatistics.html" title="DROP STATISTICS" /><link rel="next" href="sql-droptable.html" title="DROP TABLE" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">DROP SUBSCRIPTION</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-dropstatistics.html" title="DROP STATISTICS">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 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-droptable.html" title="DROP TABLE">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-DROPSUBSCRIPTION"><div class="titlepage"></div><a id="id-1.9.3.133.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">DROP SUBSCRIPTION</span></h2><p>DROP SUBSCRIPTION — remove a subscription</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">3DROP SUBSCRIPTION [ IF EXISTS ] <em class="replaceable"><code>name</code></em> [ CASCADE | RESTRICT ]4</pre></div><div class="refsect1" id="id-1.9.3.133.5"><h2>Description</h2><p>5 <code class="command">DROP SUBSCRIPTION</code> removes a subscription from the6 database cluster.7 </p><p>8 To execute this command the user must be the owner of the subscription.9 </p><p>10 <code class="command">DROP SUBSCRIPTION</code> cannot be executed inside a11 transaction block if the subscription is associated with a replication12 slot. (You can use <code class="command">ALTER SUBSCRIPTION</code> to unset the13 slot.)14 </p></div><div class="refsect1" id="id-1.9.3.133.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>15 The name of a subscription to be dropped.16 </p></dd><dt><span class="term"><code class="literal">CASCADE</code><br /></span><span class="term"><code class="literal">RESTRICT</code></span></dt><dd><p>17 These key words do not have any effect, since there are no dependencies18 on subscriptions.19 </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.133.7"><h2>Notes</h2><p>20 When dropping a subscription that is associated with a replication slot on21 the remote host (the normal state), <code class="command">DROP SUBSCRIPTION</code>22 will connect to the remote host and try to drop the replication slot (and23 any remaining table synchronization slots) as24 part of its operation. This is necessary so that the resources allocated25 for the subscription on the remote host are released. If this fails,26 either because the remote host is not reachable or because the remote27 replication slot cannot be dropped or does not exist or never existed,28 the <code class="command">DROP SUBSCRIPTION</code> command will fail. To proceed29 in this situation, first disable the subscription by executing30 <code class="literal">ALTER SUBSCRIPTION ... DISABLE</code>, and then disassociate31 it from the replication slot by executing32 <code class="literal">ALTER SUBSCRIPTION ... SET (slot_name = NONE)</code>.33 After that, <code class="command">DROP SUBSCRIPTION</code> will no longer attempt any34 actions on a remote host. Note that if the remote replication slot still35 exists, it (and any related table synchronization slots) should then be36 dropped manually; otherwise it/they will continue to37 reserve WAL and might eventually cause the disk to fill up. See38 also <a class="xref" href="logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-SLOT" title="31.2.1. Replication Slot Management">Section 31.2.1</a>.39 </p><p>40 If a subscription is associated with a replication slot, then <code class="command">DROP41 SUBSCRIPTION</code> cannot be executed inside a transaction block.42 </p></div><div class="refsect1" id="id-1.9.3.133.8"><h2>Examples</h2><p>43 Drop a subscription:44</p><pre class="programlisting">45DROP SUBSCRIPTION mysub;46</pre></div><div class="refsect1" id="id-1.9.3.133.9"><h2>Compatibility</h2><p>47 <code class="command">DROP SUBSCRIPTION</code> is a <span class="productname">PostgreSQL</span>48 extension.49 </p></div><div class="refsect1" id="id-1.9.3.133.10"><h2>See Also</h2><span class="simplelist"><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-dropstatistics.html" title="DROP STATISTICS">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-droptable.html" title="DROP TABLE">Next</a></td></tr><tr><td width="40%" align="left" valign="top">DROP STATISTICS </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> DROP TABLE</td></tr></table></div></body></html>