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>
57 lines
5.6 KiB
HTML
57 lines
5.6 KiB
HTML
<a name="EN-US_TOPIC_0000001621382957"></a><a name="EN-US_TOPIC_0000001621382957"></a>
|
|
|
|
<h1 class="topictitle1">Modifying the Lifecycle of a Table</h1>
|
|
<div id="body0000001621382957"><div class="section" id="EN-US_TOPIC_0000001621382957__section790729122517"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001621382957__p12404835192510">This section describes how to modify the lifecycle of an existing partitioned or non-partitioned table.</p>
|
|
<p id="EN-US_TOPIC_0000001621382957__p15788211542">When the lifecycle function is enabled for the first time, the system scans tables or partitions, scans table data files in the path, and updates <strong id="EN-US_TOPIC_0000001621382957__b14321145614516">LAST_ACCESS_TIME</strong> of tables or partitions. The time required depends on the number of partitions and files.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001621382957__section137638135514"><h4 class="sectiontitle">Constraints and Limitations</h4><ul id="EN-US_TOPIC_0000001621382957__ul162161589267"><li id="EN-US_TOPIC_0000001621382957__li18263433152214">The table lifecycle function currently only supports creating tables and versioning tables using Hive and Datasource syntax.</li><li id="EN-US_TOPIC_0000001621382957__li753534652018">The unit of the lifecycle is in days. The value should be a positive integer.</li><li id="EN-US_TOPIC_0000001621382957__li15403171564215">The lifecycle can be set only at the table level. The lifecycle specified for a partitioned table applies to all partitions of the table.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001621382957__section1367443102618"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="EN-US_TOPIC_0000001621382957__screen1262812316225">ALTER TABLE table_name
|
|
SET TBLPROPERTIES("dli.lifecycle.days"='N')</pre>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001621382957__section95506239263"><h4 class="sectiontitle">Keywords</h4><p id="EN-US_TOPIC_0000001621382957__p1050713615110"><strong id="EN-US_TOPIC_0000001621382957__b87751012134711">TBLPROPERTIES</strong>: Table properties, which can be used to extend the lifecycle of a table.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001621382957__section183213010264"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001621382957__table17157258112919" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0000001621382957__row415885852911"><th align="left" class="cellrowborder" valign="top" width="32.48324832483248%" id="mcps1.3.5.2.2.4.1.1"><p id="EN-US_TOPIC_0000001621382957__p815815822916">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="11.571157115711571%" id="mcps1.3.5.2.2.4.1.2"><p id="EN-US_TOPIC_0000001621382957__p18158058172910">Mandatory</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="55.94559455945595%" id="mcps1.3.5.2.2.4.1.3"><p id="EN-US_TOPIC_0000001621382957__p315835822919">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001621382957__row7158135862917"><td class="cellrowborder" valign="top" width="32.48324832483248%" headers="mcps1.3.5.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001621382957__p6158358122915">table_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.571157115711571%" headers="mcps1.3.5.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001621382957__p694292614358">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="55.94559455945595%" headers="mcps1.3.5.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001621382957__p17158115842914">Name of the table whose lifecycle needs to be modified</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001621382957__row8158175852916"><td class="cellrowborder" valign="top" width="32.48324832483248%" headers="mcps1.3.5.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001621382957__p81586587293">dli.lifecycle.days</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.571157115711571%" headers="mcps1.3.5.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001621382957__p31581058182912">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="55.94559455945595%" headers="mcps1.3.5.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001621382957__p171581958102919">Lifecycle duration after the modification. The value must be a positive integer, in days.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001621382957__section1333184072615"><h4 class="sectiontitle">Example</h4><ul id="EN-US_TOPIC_0000001621382957__ul0966135267"><li id="EN-US_TOPIC_0000001621382957__li696619352610">Example 1: Enable the lifecycle function for the <strong id="EN-US_TOPIC_0000001621382957__b1113514055012">test_lifecycle_exists</strong> table and set the lifecycle to 50 days.<pre class="screen" id="EN-US_TOPIC_0000001621382957__screen33943553383">alter table test_lifecycle_exists
|
|
SET TBLPROPERTIES("dli.lifecycle.days"='50');</pre>
|
|
</li><li id="EN-US_TOPIC_0000001621382957__li03483132261">Example 2: Enable the lifecycle function for an existing partitioned or non-partitioned table for which lifecycle is not set, for example, for the <strong id="EN-US_TOPIC_0000001621382957__b11509191395319">test_lifecycle_exists</strong> table, and set the lifecycle to 50 days.<pre class="screen" id="EN-US_TOPIC_0000001621382957__screen348591216432">alter table test_lifecycle_exists
|
|
SET TBLPROPERTIES(
|
|
"dli.lifecycle.days"='50',
|
|
"dli.table.lifecycle.status"='enable'
|
|
);</pre>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0000001571023676.html">Table Lifecycle Management</a></div>
|
|
</div>
|
|
</div>
|
|
|