Files
doc-exports/docs/dws/dev/dws_06_0304.html
luhuayi 177cd61a57 DWS DEVG 910.211 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: luhuayi <luhuayi@huawei.com>
Co-committed-by: luhuayi <luhuayi@huawei.com>
2025-05-05 07:44:03 +00:00

60 lines
7.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<a name="EN-US_TOPIC_0000001764516310"></a><a name="EN-US_TOPIC_0000001764516310"></a>
<h1 class="topictitle1">Partition Management Function</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_section9462151915274"><a name="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_section9462151915274"></a><a name="en-us_topic_0000001444998754_section9462151915274"></a><h4 class="sectiontitle">proc_add_partition (relname regclass, boundaries_interval interval)</h4><p id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_p148471314103918">Description: Adds partitions to a table with the automatic partition creation function enabled.</p>
<p id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_p17847111413916">Return type: void</p>
<p id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_p17847914183913">Note: When the function is executed, multiple partitions with time range as <strong id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_b67582920494356">boundaries_interval</strong> are created based on the existing partition boundary until <strong id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_b41472659194356">new_part_boundary now_time &gt;= 29 * boundaries_interval</strong>. Then, an extra partition is created to ensure that at least a new partition is created when the function is executed.</p>
<p id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_p28471614153910">Example:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_screen78471314163918"><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>
<span class="normal">4</span>
<span class="normal">5</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">call</span><span class="w"> </span><span class="n">proc_add_partition</span><span class="p">(</span><span class="s1">'my_schema.my_table'</span><span class="p">,</span><span class="w"> </span><span class="nb">interval</span><span class="w"> </span><span class="s1">'1 day'</span><span class="p">);</span>
<span class="w"> </span><span class="n">proc_add_partition</span>
<span class="c1">--------------------</span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_section9128833152714"><a name="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_section9128833152714"></a><a name="en-us_topic_0000001444998754_section9128833152714"></a><h4 class="sectiontitle">proc_drop_partition (relname regclass, older_than interval)</h4><p id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_p3490183952212">Description: Deletes partitions from a table with the automatic partition deletion function enabled.</p>
<p id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_p104908393225">Return type: void</p>
<p id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_p897954015365">Note: When this function is executed, all partitions in the table are traversed and the partitions whose boundary is smaller than <strong id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_b91990307294356">now_time - older_than</strong> are deleted. If all partitions meet the deletion condition, the table is truncated with one partition kept.</p>
<p id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_p18490539142211">Example:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516310__en-us_topic_0000001444998754_screen104901396223"><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>
<span class="normal">4</span>
<span class="normal">5</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">call</span><span class="w"> </span><span class="n">proc_drop_partition</span><span class="p">(</span><span class="s1">'my_schema.my_table'</span><span class="p">,</span><span class="w"> </span><span class="nb">interval</span><span class="w"> </span><span class="s1">'7 day'</span><span class="p">);</span>
<span class="w"> </span><span class="n">proc_drop_partition</span>
<span class="c1">--------------------</span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001764516310__section10461121411299"><h4 class="sectiontitle">pg_partition_management_time(table_name, time)</h4><p id="EN-US_TOPIC_0000001764516310__p946251413292">Description: Modifies the execution time of the partition scheduling task that automatically adds or removes partitions. The default time is when the auto-increment partition table was created. This function is supported only by 8.3.0 and later versions.</p>
<p id="EN-US_TOPIC_0000001764516310__p430446143215">Return value: <strong id="EN-US_TOPIC_0000001764516310__b2728737731758">SUCCESS</strong>, which indicates that the time is successfully modified.</p>
<p id="EN-US_TOPIC_0000001764516310__p206191436103319">Parameter:</p>
<ul id="EN-US_TOPIC_0000001764516310__ul156235317336"><li id="EN-US_TOPIC_0000001764516310__li3563953103314"><strong id="EN-US_TOPIC_0000001764516310__b869445017113">table_name</strong> indicates the name of the auto-increment partitioned table. The type is Name.</li><li id="EN-US_TOPIC_0000001764516310__li1956313533332"><strong id="EN-US_TOPIC_0000001764516310__b1317174671316">time</strong> indicates the time when the data switching task is scheduled. The type is Time.</li></ul>
<p id="EN-US_TOPIC_0000001764516310__p1846281410298">Example:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764516310__screen12462161442916"><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>
<span class="normal">4</span>
<span class="normal">5</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">call</span><span class="w"> </span><span class="n">pg_partition_management_time</span><span class="p">(</span><span class="s1">'partition_management_time'</span><span class="p">,</span><span class="s1">'3:00'</span><span class="p">);</span>
<span class="w"> </span><span class="n">pg_partition_management_time</span><span class="w"> </span>
<span class="c1">------------------------------</span>
<span class="w"> </span><span class="n">SUCCESS</span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</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="dws_06_0058.html">Database Object Functions</a></div>
</div>
</div>