doc-exports/docs/dli/sqlreference/dli_08_0084.html
Su, Xiaomeng 76a5b1ee83 dli_sqlreference_20240227
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>
2024-03-27 22:02:33 +00:00

62 lines
7.1 KiB
HTML

<a name="dli_08_0084"></a><a name="dli_08_0084"></a>
<h1 class="topictitle1">Altering the Partition Location of a Table (Only OBS Tables Supported)</h1>
<div id="body8662426"><div class="section" id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_sde173422f44d41f3ab3188dbcf0b488b"><h4 class="sectiontitle">Function</h4><p id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_a0fc3849fe9ca46ab8de4084832fb87c0">This statement is used to modify the positions of table partitions.</p>
</div>
<div class="section" id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_sad8e5707c7a54e268ee1d5397a5612a0"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="dli_08_0084__en-us_topic_0114776178_screen15701112812447"><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="k">table_name</span>
<span class="w"> </span><span class="n">PARTITION</span><span class="w"> </span><span class="n">partition_specs</span>
<span class="w"> </span><span class="k">SET</span><span class="w"> </span><span class="k">LOCATION</span><span class="w"> </span><span class="n">obs_path</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_sf6d5fef5144840b9a0505c02fa8b84de"><h4 class="sectiontitle">Keywords</h4><ul id="dli_08_0084__ul85891167229"><li id="dli_08_0084__li145908169227">PARTITION: a specified partition</li><li id="dli_08_0084__li14590101622219">LOCATION: path of the partition</li></ul>
</div>
<div class="section" id="dli_08_0084__section104123045314"><h4 class="sectiontitle">Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0084__en-us_topic_0114776188_en-us_topic_0103084433_t2fa8597e0dde4884bd6412ac207ebea8" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters</caption><thead align="left"><tr id="dli_08_0084__en-us_topic_0114776188_en-us_topic_0103084433_r16c75fd8fdbf41c79f9aee82b032351c"><th align="left" class="cellrowborder" valign="top" width="18.490000000000002%" id="mcps1.3.4.2.2.3.1.1"><p id="dli_08_0084__en-us_topic_0114776188_en-us_topic_0103084433_a9dd69379a3f54904a9c510fb817659ad">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="81.51%" id="mcps1.3.4.2.2.3.1.2"><p id="dli_08_0084__en-us_topic_0114776188_en-us_topic_0103084433_a7ede0d62539542baa7e367cf902bf2b2">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_08_0084__row160712191411"><td class="cellrowborder" valign="top" width="18.490000000000002%" headers="mcps1.3.4.2.2.3.1.1 "><p id="dli_08_0084__p3608320149">table_name</p>
</td>
<td class="cellrowborder" valign="top" width="81.51%" headers="mcps1.3.4.2.2.3.1.2 "><p id="dli_08_0084__p160812219141">Table name</p>
</td>
</tr>
<tr id="dli_08_0084__row173647290145"><td class="cellrowborder" valign="top" width="18.490000000000002%" headers="mcps1.3.4.2.2.3.1.1 "><p id="dli_08_0084__p123641229111418">partition_specs</p>
</td>
<td class="cellrowborder" valign="top" width="81.51%" headers="mcps1.3.4.2.2.3.1.2 "><p id="dli_08_0084__p636492981417">Partition fields</p>
</td>
</tr>
<tr id="dli_08_0084__row1346183911611"><td class="cellrowborder" valign="top" width="18.490000000000002%" headers="mcps1.3.4.2.2.3.1.1 "><p id="dli_08_0084__p746133911612">obs_path</p>
</td>
<td class="cellrowborder" valign="top" width="81.51%" headers="mcps1.3.4.2.2.3.1.2 "><p id="dli_08_0084__p11461133901617">OBS path</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_s9177c17d7ab34b41930a5fd3597cf19b"><h4 class="sectiontitle">Precautions</h4><ul id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_u853f08e2bfd84c99ad4001dec808fc36"><li id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_l4d186d3604eb4a55b18ce17dbeceab6c">For a table partition whose position is to be modified, the table and partition must exist. Otherwise, an error is reported.</li><li id="dli_08_0084__en-us_topic_0114776178_li1083831119394">By default, the <span class="parmname" id="dli_08_0084__parmname251751061319"><b>partition_specs</b></span> parameter contains <strong id="dli_08_0084__b125173108137">()</strong>. For example: <b><span class="cmdname" id="dli_08_0084__en-us_topic_0114776178_cmdname1398714673114">PARTITION (dt='2009-09-09',city='xxx')</span></b></li><li id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_ld333dec5b11e44fa852e86164b2ca39c">The specified OBS path must be an absolute path. Otherwise, an error is reported.</li><li id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_li79266762013">If the path specified in the new partition contains subdirectories (or nested subdirectories), all file types and content in the subdirectories are considered partition records. Ensure that all file types and file content in the partition directory are the same as those in the table. Otherwise, an error is reported.</li></ul>
</div>
<div class="section" id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_s989da33459d14a78a0e8de3f79a55855"><h4 class="sectiontitle">Example</h4><p id="dli_08_0084__en-us_topic_0114776178_en-us_topic_0093946830_a918c1409e39e4df5b394aa3cfbc06910">To set the OBS path of partition <strong id="dli_08_0084__en-us_topic_0093946830_b84235270616653">dt='2008-08-08',city='xxx'</strong> in table <strong id="dli_08_0084__en-us_topic_0093946830_b8423527061670">student</strong> to <span class="filepath" id="dli_08_0084__en-us_topic_0093946830_filepath1575223095015"><b>obs://bucketName/fileName/student/dt=2008-08-08/city=xxx</b></span>, run the following statement:</p>
<div class="codecoloring" codetype="Sql" id="dli_08_0084__en-us_topic_0114776178_screen11831136144513"><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="n">PARTITION</span><span class="p">(</span><span class="n">dt</span><span class="o">=</span><span class="s1">'2008-08-08'</span><span class="p">,</span><span class="n">city</span><span class="o">=</span><span class="s1">'xxx'</span><span class="p">)</span>
<span class="w"> </span><span class="k">SET</span><span class="w"> </span><span class="k">LOCATION</span><span class="w"> </span><span class="s1">'obs://bucketName/fileName/student/dt=2008-08-08/city=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>