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>
67 lines
8.6 KiB
HTML
67 lines
8.6 KiB
HTML
<a name="dli_08_0354"></a><a name="dli_08_0354"></a>
|
|
|
|
<h1 class="topictitle1">Enabling or Disabling Multiversion Backup</h1>
|
|
<div id="body0000001209844553"><div class="section" id="dli_08_0354__en-us_topic_0156816309_en-us_topic_0093946741_s86887e0a86644c22b61a4c2ccc84025e"><h4 class="sectiontitle">Function</h4><p id="dli_08_0354__en-us_topic_0156816309_en-us_topic_0093946741_a9755a68b9d0d47668ac554151d03e0ce">DLI controls multiple versions of backup data for restoration. After the multiversion function is enabled, the system automatically backs up table data when you delete or modify the data using <strong id="dli_08_0354__b1798871681213">insert overwrite</strong> or <strong id="dli_08_0354__b161591819191220">truncate</strong>, and retains the data for a certain period. You can quickly restore data within the retention period. For details about the syntax related to the multiversion function, see <a href="dli_08_0349.html">Backing Up and Restoring Data of Multiple Versions</a>.</p>
|
|
<p id="dli_08_0354__p18220193723915">Currently, the multiversion function supports only OBS tables created using the Hive syntax. For details about the syntax for creating a table, see <a href="dli_08_0077.html">Creating an OBS Table Using the Hive Syntax</a>.</p>
|
|
</div>
|
|
<div class="section" id="dli_08_0354__en-us_topic_0156816309_en-us_topic_0093946741_sd6725bae42f0429e8bc6dfa2e92b9664"><h4 class="sectiontitle">Syntax</h4><ul id="dli_08_0354__ul199756384918"><li id="dli_08_0354__li597618316496">Enable the multiversion function.<pre class="screen" id="dli_08_0354__screen121651215164918"><strong id="dli_08_0354__b10266754135512">ALTER TABLE</strong> [db_name.]table_name
|
|
<strong id="dli_08_0354__b92911572550">SET TBLPROPERTIES</strong> ("dli.multi.version.enable"="true");</pre>
|
|
</li><li id="dli_08_0354__li8327101117490">Disable the multiversion function.<div class="codecoloring" codetype="Sql" id="dli_08_0354__screen178328855413"><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">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="n">UNSET</span><span class="w"> </span><span class="n">TBLPROPERTIES</span><span class="w"> </span><span class="p">(</span><span class="ss">"dli.multi.version.enable"</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<div class="p" id="dli_08_0354__p15415174511426">After multiversion is enabled, data of different versions is automatically stored in the OBS storage directory when <strong id="dli_08_0354__b8489102914176">insert overwrite</strong> or <strong id="dli_08_0354__b946532171714">truncate</strong> is executed. After multiversion is disabled, run the following statement to restore the multiversion backup data directory:<pre class="screen" id="dli_08_0354__screen7919173505414"><strong id="dli_08_0354__b81881838195519">RESTORE TABLE</strong> [db_name.]table_name <strong id="dli_08_0354__b288954115518">TO initial layout</strong>;</pre>
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0354__en-us_topic_0114776199_en-us_topic_0107972084_en-us_topic_0093946811_s85a6f8f752b14c12908d2303d618d510"><h4 class="sectiontitle">Keywords</h4><ul id="dli_08_0354__en-us_topic_0114776199_en-us_topic_0107972084_en-us_topic_0093946811_u6276390c1d994411a3ade99c0da8c0c0"><li id="dli_08_0354__en-us_topic_0114776199_en-us_topic_0107972084_en-us_topic_0093946811_lf20ccaa3b133495591e692c43a7287d9">SET TBLPROPERTIES: Used to set table properties and enable multiversion.</li><li id="dli_08_0354__en-us_topic_0114776199_en-us_topic_0107972084_en-us_topic_0093946811_lae91afc5a5e84024951de4cb76ee67c9">UNSET TBLPROPERTIES: Used to unset table properties and disable multiversion.</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0354__en-us_topic_0114776188_en-us_topic_0093946905_s95436b2cebbc4c34b0e6ca8427d4f1d9"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0354__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_0354__en-us_topic_0114776188_en-us_topic_0103084433_r16c75fd8fdbf41c79f9aee82b032351c"><th align="left" class="cellrowborder" valign="top" width="16.23%" id="mcps1.3.4.2.2.3.1.1"><p id="dli_08_0354__en-us_topic_0114776188_en-us_topic_0103084433_a9dd69379a3f54904a9c510fb817659ad">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="83.77%" id="mcps1.3.4.2.2.3.1.2"><p id="dli_08_0354__en-us_topic_0114776188_en-us_topic_0103084433_a7ede0d62539542baa7e367cf902bf2b2">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0354__en-us_topic_0114776188_en-us_topic_0103084433_r8ab7399810eb42b7abf51ae705c6cf83"><td class="cellrowborder" valign="top" width="16.23%" headers="mcps1.3.4.2.2.3.1.1 "><p id="dli_08_0354__en-us_topic_0114776188_en-us_topic_0103084433_a1cdeda4790a8452d8619c797147bf9cf">db_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="83.77%" headers="mcps1.3.4.2.2.3.1.2 "><p id="dli_08_0354__en-us_topic_0114776188_en-us_topic_0103084433_p4729195274115">Database name that contains letters, digits, and underscores (_). It cannot contain only digits or start with an underscore (_).</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0354__row160712191411"><td class="cellrowborder" valign="top" width="16.23%" headers="mcps1.3.4.2.2.3.1.1 "><p id="dli_08_0354__p3608320149">table_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="83.77%" headers="mcps1.3.4.2.2.3.1.2 "><p id="dli_08_0354__p160812219141">Table name</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0354__en-us_topic_0156816309_section256972552612"><h4 class="sectiontitle">Precautions</h4><p id="dli_08_0354__p1383514122310">Currently, the multiversion function supports only OBS tables created using the Hive syntax. For details about the syntax for creating a table, see <a href="dli_08_0077.html">Creating an OBS Table Using the Hive Syntax</a>.</p>
|
|
</div>
|
|
<div class="section" id="dli_08_0354__en-us_topic_0156816309_section53871537273"><h4 class="sectiontitle">Example</h4><ul id="dli_08_0354__ul1514073665620"><li id="dli_08_0354__li11140183645614">Modify the <strong id="dli_08_0354__b15261471497">test_table</strong> table to enable multiversion.<div class="codecoloring" codetype="Sql" id="dli_08_0354__screen052633935610"><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">ALTER</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">test_table</span><span class="w"> </span>
|
|
<span class="k">SET</span><span class="w"> </span><span class="n">TBLPROPERTIES</span><span class="w"> </span><span class="p">(</span><span class="ss">"dli.multi.version.enable"</span><span class="o">=</span><span class="ss">"true"</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</li><li id="dli_08_0354__li6526103914569">Modify the <strong id="dli_08_0354__b11283410185016">test_table</strong> table to disable multiversion.<div class="codecoloring" codetype="Sql" id="dli_08_0354__screen197517454576"><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">ALTER</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">test_table</span><span class="w"> </span>
|
|
<span class="n">UNSET</span><span class="w"> </span><span class="n">TBLPROPERTIES</span><span class="w"> </span><span class="p">(</span><span class="ss">"dli.multi.version.enable"</span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<div class="p" id="dli_08_0354__p10392161120587">Restore the multiversion backup data directory.<pre class="screen" id="dli_08_0354__screen15999112395812">RESTORE TABLE test_table TO initial layout;</pre>
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0262.html">Modifying a Table</a></div>
|
|
</div>
|
|
</div>
|
|
|