forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
62 lines
8.2 KiB
HTML
62 lines
8.2 KiB
HTML
<a name="dli_08_0083"></a><a name="dli_08_0083"></a>
|
|
|
|
<h1 class="topictitle1">Deleting a Partition</h1>
|
|
<div id="body8662426"><div class="section" id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_see77d47bd5ee4527b743ba74f2f8de11"><h4 class="sectiontitle">Function</h4><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_a56c2c81b26f1481c8c3f5e2aa2e3e541">Deletes one or more partitions from a partitioned table.</p>
|
|
</div>
|
|
<div class="section" id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_sa2e42a3b9c40499d8aece88e300172e2"><h4 class="sectiontitle">Precautions</h4><ul id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_ueef317bd7b7d4848b71d76390b8e3a60"><li id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_l83f3cefa18f84ac88190411ea31bd488">The table in which partitions are to be deleted must exist. Otherwise, an error is reported.</li><li id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_l9d84b14aa0b049908b6b0b24edb3094f">The to-be-deleted partition must exist. Otherwise, an error is reported. To avoid this error, add <strong id="dli_08_0083__b659623551211">IF EXISTS</strong> in this statement.</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_sdbfe5a0630ef4b47aea744c8c3d7fa27"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="dli_08_0083__en-us_topic_0114776177_screen797416436315"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span>
|
|
<span class="normal">3</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="p">[</span><span class="n">db_name</span><span class="p">.]</span><span class="k">table_name</span>
|
|
<span class="w"> </span><span class="k">DROP</span><span class="w"> </span><span class="p">[</span><span class="k">IF</span><span class="w"> </span><span class="k">EXISTS</span><span class="p">]</span>
|
|
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="n">partition_spec1</span><span class="p">[,</span><span class="n">PARTITION</span><span class="w"> </span><span class="n">partition_spec2</span><span class="p">,...];</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0083__en-us_topic_0114776176_en-us_topic_0093946763_s4722556def8545d097cf905b9261c45d"><h4 class="sectiontitle">Keyword</h4><ul id="dli_08_0083__ul48718578292"><li id="dli_08_0083__li4871155782917">DROP: deletes a partition.</li><li id="dli_08_0083__li1287105772917">IF EXISTS: The partition to be deleted must exist. Otherwise, an error is reported.</li><li id="dli_08_0083__li1342780414">PARTITION: specifies the partition to be deleted</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0083__en-us_topic_0114776177_section860512913615"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_t2fa8597e0dde4884bd6412ac207ebea8" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_r16c75fd8fdbf41c79f9aee82b032351c"><th align="left" class="cellrowborder" valign="top" width="20.52%" id="mcps1.3.5.2.2.3.1.1"><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_a9dd69379a3f54904a9c510fb817659ad">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="79.47999999999999%" id="mcps1.3.5.2.2.3.1.2"><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_a7ede0d62539542baa7e367cf902bf2b2">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_r8ab7399810eb42b7abf51ae705c6cf83"><td class="cellrowborder" valign="top" width="20.52%" headers="mcps1.3.5.2.2.3.1.1 "><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_a1cdeda4790a8452d8619c797147bf9cf">db_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="79.47999999999999%" headers="mcps1.3.5.2.2.3.1.2 "><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_p4729195274115">Database name that contains letters, digits, and underscores (_). It cannot contain only digits and cannot start with an underscore (_).</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_r36540eab62c64ec4babb57549d5776e7"><td class="cellrowborder" valign="top" width="20.52%" headers="mcps1.3.5.2.2.3.1.1 "><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_aa0912c807a254106a3a033e8ccb9e95e">table_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="79.47999999999999%" headers="mcps1.3.5.2.2.3.1.2 "><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_ae05b93123b5b41ff91b2875680e77dac">Table name of a database that contains letters, digits, and underscores (_). It cannot contain only digits and cannot start with an underscore (_). The matching rule is <strong id="dli_08_0083__b162571212504">^(?!_)(?![0-9]+$)[A-Za-z0-9_$]*$</strong>. If special characters are required, use single quotation marks ('') to enclose them.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_r360f5784fda14ac1b1a3ff638aaa5b26"><td class="cellrowborder" valign="top" width="20.52%" headers="mcps1.3.5.2.2.3.1.1 "><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_p4561757995919">partition_specs</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="79.47999999999999%" headers="mcps1.3.5.2.2.3.1.2 "><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0103084434_p3787647395919">Partition information, in the format of "key=value", where <strong id="dli_08_0083__b12430518141211">key</strong> indicates the partition field and <strong id="dli_08_0083__b843021811122">value</strong> indicates the partition value. In a table partitioned using multiple fields, if you specify all the fields of a partition name, only the partition is deleted; if you specify only some fields of a partition name, all matching partitions will be deleted. By default, the <span class="parmname" id="dli_08_0083__parmname1459716235125"><b>partition_specs</b></span> parameter contains <strong id="dli_08_0083__b85971223181219">()</strong>. For example: <b><span class="cmdname" id="dli_08_0083__en-us_topic_0114776177_cmdname1398714673114">PARTITION (dt='2009-09-09',city='xxx')</span></b></p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_sbd247a258fdd490a988c980dd33504e6"><h4 class="sectiontitle">Example</h4><p id="dli_08_0083__en-us_topic_0114776177_en-us_topic_0093946793_a07d135d6e32641898620af93b0a267c2">To delete the <strong id="dli_08_0083__b15924164019126">dt = '2008-08-08', city = 'xxx'</strong> partition in the <strong id="dli_08_0083__b129247400120">student</strong> table, run the following statement:</p>
|
|
<div class="codecoloring" codetype="Sql" id="dli_08_0083__en-us_topic_0114776177_screen361074812321"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span>
|
|
<span class="normal">3</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">student</span>
|
|
<span class="w"> </span><span class="k">DROP</span>
|
|
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="p">(</span><span class="n">dt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'2008-08-08'</span><span class="p">,</span><span class="w"> </span><span class="n">city</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'xxx'</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0080.html">Syntax for Partitioning a Table</a></div>
|
|
</div>
|
|
</div>
|
|
|