forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
33 lines
6.4 KiB
HTML
33 lines
6.4 KiB
HTML
<a name="EN-US_TOPIC_0000001188429082"></a><a name="EN-US_TOPIC_0000001188429082"></a>
|
|
|
|
<h1 class="topictitle1">DROP DATABASE</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188429082__s697aa3df92a44c0d8e0500f4e44517a0"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188429082__aba3e4df8aa944a77b7df8aeaa5dcfa4d"><strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0085033012_b6195187085843">DROP DATABASE</strong> deletes a database.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188429082__s90d714726f90480d9686a860c140abc6"><h4 class="sectiontitle">Important Notes</h4><ul id="EN-US_TOPIC_0000001188429082__u74efbb14ede84d67998c0622e5c10f52"><li id="EN-US_TOPIC_0000001188429082__l8d289dd959b14e0b9f6441029a4cdcb9">Only the owner of a database or a system administrator has the permission to run the <strong id="EN-US_TOPIC_0000001188429082__b842352706153144">DROP DATABASE</strong> command. </li><li id="EN-US_TOPIC_0000001188429082__la937071daf234601800c9ff3797a3b95"><strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0085033012_b2093261785843">DROP DATABASE</strong> does not take effect for the three preinstalled system databases (<strong id="EN-US_TOPIC_0000001188429082__b61624540232"></strong><strong id="EN-US_TOPIC_0000001188429082__b15162165414234"><span id="EN-US_TOPIC_0000001188429082__text394662671816">gaussdb</span></strong>, <strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0085033012_b1782042785843">TEMPLATE0</strong>, and <strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0085033012_b2616612285843">TEMPLATE1</strong>) because they are protected. To check databases in the current service, run the <strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0058965699_b3416850685843">\l</strong> command of <strong id="EN-US_TOPIC_0000001188429082__b842352706103428">gsql</strong>.</li><li id="EN-US_TOPIC_0000001188429082__l18382c74f96d4a64b3bfff3a78b11b09">This command cannot be run while the database to be deleted is associated with a user. You can check the current database connections in the <strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0085033012_b1618559785843">v$session</strong> view.</li><li id="EN-US_TOPIC_0000001188429082__l6c9cf38314864f6f93308eae010e665d"><strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0085033012_b3596498985843">DROP DATABASE</strong> cannot be run inside a transaction block.</li><li id="EN-US_TOPIC_0000001188429082__lfe02e2b5f2cb49e398292bfb7ef0c2ee">If <strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0085033012_b84235270612413">DROP DATABASE</strong> fails to be run and is rolled back, run <strong id="EN-US_TOPIC_0000001188429082__en-us_topic_0085033012_b842352706124125">DROP DATABASE IF EXISTS</strong>.</li><li id="EN-US_TOPIC_0000001188429082__li11814553124819"><strong id="EN-US_TOPIC_0000001188429082__b3586104020343">DROP DATABASE</strong> cannot be undone.</li><li id="EN-US_TOPIC_0000001188429082__li1570819591185">If a "database is being accessed by other users" error is displayed when you run <strong id="EN-US_TOPIC_0000001188429082__b3673104293410">DROP DATABASE</strong>, it might be that threads cannot respond to signals in a timely manner during the <strong id="EN-US_TOPIC_0000001188429082__b12674154273416">CLEAN CONNECTION</strong> process. As a result, connections are not completely cleared. In this case, you need to run <strong id="EN-US_TOPIC_0000001188429082__b1167464215347">CLEAN CONNECTION</strong> again.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188429082__s7d32ead441b24238bab5dc867d4447ab"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188429082__sc6c4df2a62bf4dae87cb08ea290cb366"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">IF</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="n">database_name</span><span class="w"> </span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188429082__s707395a6e9654c799e7cfca146acedbb"><h4 class="sectiontitle">Parameters</h4><ul id="EN-US_TOPIC_0000001188429082__u38dbfcc927574131bb9558b593175b75"><li id="EN-US_TOPIC_0000001188429082__l76c9ab68ef47481cbe3d66f01a084a46"><strong id="EN-US_TOPIC_0000001188429082__ac0e9e72573634aad86d996c5f0bfd613">IF EXISTS</strong><p id="EN-US_TOPIC_0000001188429082__aadcbc68db8fe439c9eca3712be81a2cf">Sends a notice instead of an error if the specified database does not exist.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188429082__l9133852aa4df4cde9cfe07d90251bb56"><strong id="EN-US_TOPIC_0000001188429082__a073d4392fd9f47f786f2b4f1995b218e">database_name</strong><p id="EN-US_TOPIC_0000001188429082__a21a3999031954de5958d84c80a2cf140">Specifies the name of the database to be deleted.</p>
|
|
<p id="EN-US_TOPIC_0000001188429082__af5ded341c06f43768408f8b49e656946">Value range: A string indicating an existing database name.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188429082__s978b01ce04e145bcb72aa8ab2ea66785"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188429082__p1505411801">Delete the database named <strong id="EN-US_TOPIC_0000001188429082__b126647254733613">music</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188429082__screen174219517598"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">music</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188429082__s416517273dbc45888af2e7ed91ad3941"><h4 class="sectiontitle">Links</h4><p id="EN-US_TOPIC_0000001188429082__a8b0f755fa0f34d76b9af700c40befe65"><a href="dws_06_0156.html">CREATE DATABASE</a>, <a href="dws_06_0120.html">ALTER DATABASE</a></p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0118.html">DDL Syntax</a></div>
|
|
</div>
|
|
</div>
|
|
|