doc-exports/docs/dws/dev/dws_06_0204.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
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>
2024-05-16 07:24:04 +00:00

34 lines
5.5 KiB
HTML

<a name="EN-US_TOPIC_0000001233628597"></a><a name="EN-US_TOPIC_0000001233628597"></a>
<h1 class="topictitle1">DROP SCHEMA</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001233628597__sd9cce01767634d859a2812aa716cc926"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001233628597__ae5579d7851244a4c94e4f9820d6199a2"><strong id="EN-US_TOPIC_0000001233628597__b84235270694532">DROP SCHEMA</strong> deletes a schema in a database.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233628597__s0243b556f698484e9e2eb9d414274203"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001233628597__uefaeb88792084008b75c664b9d37a6a6"><li id="EN-US_TOPIC_0000001233628597__li55461250029">Only the owner of a schema or a user granted with the DROP permission for the schema or a system administrator has the permission to execute the <strong id="EN-US_TOPIC_0000001233628597__b151749971822017">Drop SCHEMA</strong> statement.</li><li id="EN-US_TOPIC_0000001233628597__li27761259161618">Do not delete the schemas with the beginning of <strong id="EN-US_TOPIC_0000001233628597__b09611850142719">pg_temp</strong> or <strong id="EN-US_TOPIC_0000001233628597__b179611650122713">pg_toast_temp</strong>. They are internal system schemas, and deleting them may cause unexpected errors.</li><li id="EN-US_TOPIC_0000001233628597__li49261829121713">A user cannot delete the schema in use. To delete the schema in use, switch to another schema.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001233628597__se5314fab51384bbf84cdede70c33e797"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233628597__sc9988e8b24a441ee9a5cecee8e581464"><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">SCHEMA</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="k">schema_name</span><span class="w"> </span><span class="p">[,</span><span class="w"> </span><span class="p">...]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">CASCADE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">RESTRICT</span><span class="w"> </span><span class="p">];</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001233628597__s594063b1d7594b30b3f414d2f4987c80"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001233628597__u885b796d936542dea950ade97878c347"><li id="EN-US_TOPIC_0000001233628597__l2a75bc5c87d246209b9d053c81fdf28d"><strong id="EN-US_TOPIC_0000001233628597__a99d9abecf7294e78aa399c88f72f8310">IF EXISTS</strong><p id="EN-US_TOPIC_0000001233628597__afa821e84f7eb4c8e9c3d1631103b1ff4">Sends a notice instead of an error if the specified schema does not exist.</p>
</li><li id="EN-US_TOPIC_0000001233628597__l729ec35f243a413096a572d0b57b1940"><strong id="EN-US_TOPIC_0000001233628597__a679f0bea00b94f54b248c6414fa84423">schema_name</strong><p id="EN-US_TOPIC_0000001233628597__a33509743c89243a3843fc6ffbff37e22">Specifies the name of a schema.</p>
<p id="EN-US_TOPIC_0000001233628597__a86d467a7343f40c19c54ef1ad1397655">Value range: An existing schema name.</p>
</li><li id="EN-US_TOPIC_0000001233628597__lbf0cc66764bf496da5e8b825c85ddac0"><strong id="EN-US_TOPIC_0000001233628597__a4d156c5017614b96a48ec0e2bce7e8b0">CASCADE | RESTRICT</strong><ul id="EN-US_TOPIC_0000001233628597__u42dcc1249c74494bb0b258b1e5f32bef"><li id="EN-US_TOPIC_0000001233628597__lb98a64f0ae08492aa1ffeb59a177a1ef"><strong id="EN-US_TOPIC_0000001233628597__en-us_topic_0058965787_b842352706195636">CASCADE</strong>: automatically deletes all objects that are contained in the schema to be deleted.</li><li id="EN-US_TOPIC_0000001233628597__led3e17d8ca6d4c2c86152540a5291341"><strong id="EN-US_TOPIC_0000001233628597__en-us_topic_0058965787_b842352706195646">RESTRICT</strong>: refuses to delete the schema that contains any objects. This is the default.</li></ul>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001233628597__s45876b9c4f8343b08a05c469d97a0cd0"><h4 class="sectiontitle">Example</h4><p id="EN-US_TOPIC_0000001233628597__p1571613413369">Delete the <strong id="EN-US_TOPIC_0000001233628597__b114391794333639">ds_new</strong> schema:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233628597__screen334517452493"><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">SCHEMA</span><span class="w"> </span><span class="n">ds_new</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001233628597__s737fbcda683644dd8eea29954b8ef3ea"><h4 class="sectiontitle">Links</h4><p id="EN-US_TOPIC_0000001233628597__ad8b7aaa2f4ca424b898da45067a7fbb6"><a href="dws_06_0136.html">ALTER SCHEMA</a>, <a href="dws_06_0173.html">CREATE SCHEMA</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>