forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: luhuayi <luhuayi@huawei.com> Co-committed-by: luhuayi <luhuayi@huawei.com>
37 lines
7.7 KiB
HTML
37 lines
7.7 KiB
HTML
<a name="EN-US_TOPIC_0000001764516446"></a><a name="EN-US_TOPIC_0000001764516446"></a>
|
|
|
|
<h1 class="topictitle1">DROP TABLE</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001764516446__s04633346cf72456db074e61b993fa111"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001764516446__ab4165269429f4f0bb6373d4e25c9a243"><strong id="EN-US_TOPIC_0000001764516446__b461094329394">DROP TABLE</strong> deletes a specified table.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001764516446__s30443e07b9934ae886f7a218b92b8d6e"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001764516446__ul1211593612505"><li id="EN-US_TOPIC_0000001764516446__li811523685014"><strong id="EN-US_TOPIC_0000001764516446__b10394942873349">DROP TABLE</strong> forcibly deletes a specified table. After a table is deleted, any indexes that exist for the table will be deleted; any functions or stored procedures that use this table cannot be run. Deleting a partitioned table also deletes all partitions in the table.</li><li id="EN-US_TOPIC_0000001764516446__li125027327819">Only the table owner, schema owner, or a user granted with the DROP permission can run <strong id="EN-US_TOPIC_0000001764516446__b11658155643719">DROP TABLE</strong> on a table. A system administrator has this permission by default. To delete all the rows in a table but retain the table definition, use <strong id="EN-US_TOPIC_0000001764516446__b9591558163712">TRUNCATE</strong> or <strong id="EN-US_TOPIC_0000001764516446__b660358173715">DELETE</strong>.</li></ul>
|
|
<div class="danger" id="EN-US_TOPIC_0000001764516446__note32813374387"><span class="dangertitle"><img src="public_sys-resources/danger_3.0-en-us.png"> </span><div class="dangerbody"><ul id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_ul6239105613382"><li id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_li192395564382">Be cautious when using <strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_b1332191241917">DROP OBJECT</strong> (e.g., <strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_b73801714121912">DATABASE</strong>, <strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_b168131731919">USER/ROLE</strong>, <strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_b173251219181915">SCHEMA</strong>, <strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_b20822222121915">TABLE</strong>, <strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_b1285618254191">VIEW</strong>) as it may cause data loss, especially with <strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_b1268313437197">CASCADE</strong> deletions. Always back up data before proceeding.</li><li id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_li1816975863817">For more information about development and design specifications, see "GaussDB(DWS) Development and Design Proposal" in the <em id="EN-US_TOPIC_0000001764516446__en-us_topic_0000001188429082_i10745134741317">Data Warehouse Service (DWS) Developer Guide</em>.</li></ul>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001764516446__s75899e6bac48419885f6deeaa11a13bf"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516446__s1e8b545cb6894f7e8496416bb64b07c5"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">TABLE</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="w"> </span><span class="err">{</span><span class="w"> </span><span class="p">[</span><span class="k">schema</span><span class="p">.]</span><span class="k">table_name</span><span class="w"> </span><span class="err">}</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><span class="w"> </span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001764516446__s6e75d841c4ee49bda8ae5f2783d347e3"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001764516446__u3ca9d6cc3d564718bbd87186cf69ec15"><li id="EN-US_TOPIC_0000001764516446__l3568ac8a50794739a7766b4110864c55"><strong id="EN-US_TOPIC_0000001764516446__ad1fa59e549fb47b4b81a5f5733a9516d">IF EXISTS</strong><p id="EN-US_TOPIC_0000001764516446__a8641d5a28c2c477e952015c6e041e7cc">Sends a notice instead of an error if the specified table does not exist.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516446__l92219c9c05f24f8eb04775c02ef21085"><strong id="EN-US_TOPIC_0000001764516446__aa85b55aa38524776bd9fe61c99188bf5">schema</strong><p id="EN-US_TOPIC_0000001764516446__a29e67b8a6e894b21b3e52a3e5841b844">Specifies the schema name.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516446__l60c4c96892784f729249d114f1fa5808"><strong id="EN-US_TOPIC_0000001764516446__af37618ba12b542bd8bb42f2d4546a57e">table_name</strong><p id="EN-US_TOPIC_0000001764516446__a03953ad2ba284c83a845a2d7bec34352">Specifies the name of the table.</p>
|
|
</li><li id="EN-US_TOPIC_0000001764516446__l7aa1ae30df5e44a6b54502eb98347c59"><strong id="EN-US_TOPIC_0000001764516446__a95371b22572f432ba5d5ad52493dbba0">CASCADE | RESTRICT</strong><ul id="EN-US_TOPIC_0000001764516446__ub6ff53fcc6bd46e2afc8dbb19728e2c2"><li id="EN-US_TOPIC_0000001764516446__l3ac67876cd694b03819e44bc860af15b"><strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0058965805_b842352706195927">CASCADE</strong>: automatically deletes objects (such as views) that depend on the table to be deleted.</li><li id="EN-US_TOPIC_0000001764516446__l653944b58bb34bc4822f083f611eb981"><strong id="EN-US_TOPIC_0000001764516446__en-us_topic_0058965805_b842352706101857">RESTRICT</strong> (default): refuses to delete the table if any objects depend on it. This is the default.</li></ul>
|
|
</li></ul>
|
|
</div>
|
|
|
|
<div class="section" id="EN-US_TOPIC_0000001764516446__s637909d8772b49a6a931a80f9b96c4b3"><h4 class="sectiontitle">Example</h4><p id="EN-US_TOPIC_0000001764516446__p1811511841420">Delete the <strong id="EN-US_TOPIC_0000001764516446__b6229227433349">warehouse_t1</strong> table:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516446__screen107382102912"><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">TABLE</span><span class="w"> </span><span class="n">tpcds</span><span class="p">.</span><span class="n">warehouse_t1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001764516446__s027896f3fed6449595011f915ba6ea23"><h4 class="sectiontitle">Helpful Links</h4><p id="EN-US_TOPIC_0000001764516446__a663c6981f3ef4d208bff844de1c173ff"><a href="dws_06_0142.html">ALTER TABLE</a>, <a href="dws_06_0276.html">12.101-RENAME TABLE</a>, and <a href="dws_06_0177.html">CREATE TABLE</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>
|
|
|