forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
58 lines
5.8 KiB
HTML
58 lines
5.8 KiB
HTML
<a name="mrs_01_1435"></a><a name="mrs_01_1435"></a>
|
|
|
|
<h1 class="topictitle1">REGISTER INDEX TABLE</h1>
|
|
<div id="body1595920212399"><div class="section" id="mrs_01_1435__sd8e4ffaa71fc4034a9e2882d7c664984"><h4 class="sectiontitle">Function</h4><p id="mrs_01_1435__a5196137f907243259747ce96c5c8b405">This command is used to register an index table with the primary table.</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_1435__s62a70620dabc4e4eb96778f71c580e7f"><h4 class="sectiontitle">Syntax</h4><p id="mrs_01_1435__a876a375878f34475b81778d30639af9e"><b><span class="cmdname" id="mrs_01_1435__cmdname163911923016">REGISTER INDEX TABLE</span></b> <i><span class="varname" id="mrs_01_1435__varname13194898613">indextable_name</span></i> ON <i><span class="varname" id="mrs_01_1435__varname15994132611617">db_name.maintable_name</span></i>;</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_1435__sd00174c8f3e8417ea0037e034192d094"><h4 class="sectiontitle">Parameter Description</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_1435__td330633f0f1a4e839893ee60997ac66b" frame="border" border="1" rules="all"><caption><b>Table 1 </b>REFRESH INDEX TABLE parameters</caption><thead align="left"><tr id="mrs_01_1435__r520a27852cb34cb7928beb87ae57c383"><th align="left" class="cellrowborder" valign="top" width="30.91%" id="mcps1.3.3.2.2.3.1.1"><p id="mrs_01_1435__a2d7b4ba625ae4e73b3de582488dc2354">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="69.08999999999999%" id="mcps1.3.3.2.2.3.1.2"><p id="mrs_01_1435__a13d327fe75f04ee5aa721ffef31b1687">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_01_1435__r29602039075d4ee29712ba3776de3028"><td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1435__aa52e22f2600e4f7cb864be20ae67a97f">db_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="69.08999999999999%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1435__a75965636f150489ab9dbf4e657309412">Database name. If this parameter is not specified, the current database is selected.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_1435__re6d39247ca1244249d7687ea10dcd0c8"><td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1435__a94889b6d62534a839457c1f3f6ecc741">indextable_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="69.08999999999999%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1435__a9cc3bd83b1044286b7a79068ee33df1e">Index table name.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_1435__row12412581684"><td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1435__p154112580813">maintable_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="69.08999999999999%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1435__p17416589816">Primary table name.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="mrs_01_1435__sa2d037069b6d4ccba70108f63dcd4897"><h4 class="sectiontitle">Precautions</h4><p id="mrs_01_1435__p1657072114332">Before running this command, run <strong id="mrs_01_1435__b13914357141110">REFRESH TABLE</strong> to register the primary table and secondary index table with the Hive metastore.</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_1435__s02de0ffe591b41d9b8435c03f68288f4"><h4 class="sectiontitle">Examples</h4><p id="mrs_01_1435__p187067211169"><strong id="mrs_01_1435__b2079089171613">create database </strong><strong id="mrs_01_1435__b1643111207261">productdb;</strong></p>
|
|
<p id="mrs_01_1435__p0706726163"><strong id="mrs_01_1435__b1795512241264">use productdb;</strong></p>
|
|
<p id="mrs_01_1435__p970613216166"><strong id="mrs_01_1435__b1695682412611">CREATE TABLE productSalesTable(a int,b string,c string) stored as carbondata;</strong></p>
|
|
<p id="mrs_01_1435__p1705329168"><strong id="mrs_01_1435__b169575249265">create index productNameIndexTable on table productSalesTable(c) as 'carbondata';</strong></p>
|
|
<p id="mrs_01_1435__p137057219168"><strong id="mrs_01_1435__b139573247264">insert into table productSalesTable select 1,'a','aaa';</strong></p>
|
|
<p id="mrs_01_1435__p57057241620"><strong id="mrs_01_1435__b895862420262">create database productdb2;</strong></p>
|
|
<p id="mrs_01_1435__p1370515211611">Run the <strong id="mrs_01_1435__b135716379442">hdfs</strong> command to copy <strong id="mrs_01_1435__b1026344834415">productSalesTable</strong> and <strong id="mrs_01_1435__b6403165384410">productNameIndexTable</strong> in the <strong id="mrs_01_1435__b151584714452">productdb</strong> database to the <strong id="mrs_01_1435__b19972131484516">productdb2 </strong>database.</p>
|
|
<p id="mrs_01_1435__p1970510220164"><strong id="mrs_01_1435__b179591624132616">refresh table productdb2.productSalesTable ;</strong></p>
|
|
<p id="mrs_01_1435__p177057261619"><strong id="mrs_01_1435__b3960824152619">refresh table productdb2.productNameIndexTable ;</strong></p>
|
|
<p id="mrs_01_1435__p37051220161"><strong id="mrs_01_1435__b10429173216269">explain select * from productdb2.productSalesTable where c = 'aaa';</strong> / The query command does not use an index table.</p>
|
|
<p id="mrs_01_1435__p1370522181610"><strong id="mrs_01_1435__b10962142413261">REGISTER INDEX TABLE productNameIndexTable ON productdb2.productSalesTable;</strong></p>
|
|
<p id="mrs_01_1435__p4705192151610"><strong id="mrs_01_1435__b536893912269">explain select * from productdb2.productSalesTable where c = 'aaa'; </strong> // The query command uses an index table.</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_1435__sc1e4d30b28cb4317b1b12496c7d2b1d6"><h4 class="sectiontitle">System Response</h4><p id="mrs_01_1435__a1d061e440570489199ac5d773bb2c76f">By running this command, the index table will be registered to the primary table.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_1424.html">DDL</a></div>
|
|
</div>
|
|
</div>
|
|
|