doc-exports/docs/dws/dev/dws_06_0208.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

36 lines
6.1 KiB
HTML

<a name="EN-US_TOPIC_0000001188429038"></a><a name="EN-US_TOPIC_0000001188429038"></a>
<h1 class="topictitle1">DROP TABLE</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188429038__s04633346cf72456db074e61b993fa111"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188429038__ab4165269429f4f0bb6373d4e25c9a243"><strong id="EN-US_TOPIC_0000001188429038__b461094329394">DROP TABLE</strong> deletes a specified table.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188429038__s30443e07b9934ae886f7a218b92b8d6e"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001188429038__ul1211593612505"><li id="EN-US_TOPIC_0000001188429038__li13821755185013">Only the table owner, schema owner, or a user granted with the DROP permission can run <strong id="EN-US_TOPIC_0000001188429038__b5961153815572">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_0000001188429038__b292851615611">TRUNCATE</strong> or <strong id="EN-US_TOPIC_0000001188429038__b139343166566">DELETE</strong>.</li><li id="EN-US_TOPIC_0000001188429038__li811523685014"><strong id="EN-US_TOPIC_0000001188429038__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></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188429038__s75899e6bac48419885f6deeaa11a13bf"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188429038__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>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188429038__s6e75d841c4ee49bda8ae5f2783d347e3"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001188429038__u3ca9d6cc3d564718bbd87186cf69ec15"><li id="EN-US_TOPIC_0000001188429038__l3568ac8a50794739a7766b4110864c55"><strong id="EN-US_TOPIC_0000001188429038__ad1fa59e549fb47b4b81a5f5733a9516d">IF EXISTS</strong><p id="EN-US_TOPIC_0000001188429038__a8641d5a28c2c477e952015c6e041e7cc">Sends a notice instead of an error if the specified table does not exist.</p>
</li><li id="EN-US_TOPIC_0000001188429038__l92219c9c05f24f8eb04775c02ef21085"><strong id="EN-US_TOPIC_0000001188429038__aa85b55aa38524776bd9fe61c99188bf5">schema</strong><p id="EN-US_TOPIC_0000001188429038__a29e67b8a6e894b21b3e52a3e5841b844">Specifies the schema name.</p>
</li><li id="EN-US_TOPIC_0000001188429038__l60c4c96892784f729249d114f1fa5808"><strong id="EN-US_TOPIC_0000001188429038__af37618ba12b542bd8bb42f2d4546a57e">table_name</strong><p id="EN-US_TOPIC_0000001188429038__a03953ad2ba284c83a845a2d7bec34352">Specifies the name of the table.</p>
</li><li id="EN-US_TOPIC_0000001188429038__l7aa1ae30df5e44a6b54502eb98347c59"><strong id="EN-US_TOPIC_0000001188429038__a95371b22572f432ba5d5ad52493dbba0">CASCADE | RESTRICT</strong><ul id="EN-US_TOPIC_0000001188429038__ub6ff53fcc6bd46e2afc8dbb19728e2c2"><li id="EN-US_TOPIC_0000001188429038__l3ac67876cd694b03819e44bc860af15b"><strong id="EN-US_TOPIC_0000001188429038__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_0000001188429038__l653944b58bb34bc4822f083f611eb981"><strong id="EN-US_TOPIC_0000001188429038__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_0000001188429038__s637909d8772b49a6a931a80f9b96c4b3"><h4 class="sectiontitle">Example</h4><p id="EN-US_TOPIC_0000001188429038__p1811511841420">Delete the <strong id="EN-US_TOPIC_0000001188429038__b6229227433349">warehouse_t1</strong> table:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188429038__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_0000001188429038__s027896f3fed6449595011f915ba6ea23"><h4 class="sectiontitle">Helpful Links</h4><p id="EN-US_TOPIC_0000001188429038__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>