Yang, Tong 6182f91ba8 MRS component operation guide_normal 2.0.38.SP20 version
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>
2022-12-09 14:55:21 +00:00

62 lines
6.5 KiB
HTML

<a name="mrs_01_1445"></a><a name="mrs_01_1445"></a>
<h1 class="topictitle1">CREATE SECONDARY INDEX</h1>
<div id="body1595920214232"><div class="section" id="mrs_01_1445__sb8fd7fc95bb045a182a5198f84fd52e9"><h4 class="sectiontitle">Function</h4><p id="mrs_01_1445__a3918b03f1e7d4be59252f6676cea36e0">This command is used to create secondary indexes in the CarbonData tables.</p>
</div>
<div class="section" id="mrs_01_1445__sd2c2b6d9c1504b5487d4d9abb94ba7b2"><h4 class="sectiontitle">Syntax</h4><p id="mrs_01_1445__a4b4c27b093854632b507698a82ed541a"><b><span class="cmdname" id="mrs_01_1445__cmdname129321912131912">CREATE INDEX</span></b> <i><span class="varname" id="mrs_01_1445__vb8e3cb7c037340b1a03638e7cd1617b1">index_name</span></i></p>
<p id="mrs_01_1445__a10a0d4a55a744d599353e32f58b1e335"><b><span class="cmdname" id="mrs_01_1445__cmdname477111911910">ON TABLE</span></b> <i><span class="varname" id="mrs_01_1445__v1b8a1a32c5a64c868c253974de32ce27">[db_name.]table_name (col_name1, col_name2)</span></i></p>
<p id="mrs_01_1445__adf7f1fc91d2c4ce39fa69d7a31a12c2c"><b><span class="cmdname" id="mrs_01_1445__cmdname1671162351914">AS</span></b> <i><span class="varname" id="mrs_01_1445__vd5dd063631b6427081fc23ff5583322c">'carbondata</span></i>'</p>
<p id="mrs_01_1445__a0271a9ee6e3f40828ea425dfa51d0572"><b><span class="cmdname" id="mrs_01_1445__cmdname19729142621913">PROPERTIES</span></b> <i><span class="varname" id="mrs_01_1445__v6b051096ebda4e179177165423cf86b7">('table_blocksize'='256')</span></i>;</p>
</div>
<div class="section" id="mrs_01_1445__s8f4e64c8aaa64b358a92a4a4ab49ad08"><h4 class="sectiontitle">Parameter Description</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_1445__tfa860801451c471c9e7be8c0a9c58366" frame="border" border="1" rules="all"><caption><b>Table 1 </b>CREATE SECONDARY INDEX parameters</caption><thead align="left"><tr id="mrs_01_1445__r80fcf2cfbdfd46369f18964a259a2478"><th align="left" class="cellrowborder" valign="top" width="20.380000000000003%" id="mcps1.3.3.2.2.3.1.1"><p id="mrs_01_1445__a937f76ef3424443f86abf8eba9a207e0">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="79.62%" id="mcps1.3.3.2.2.3.1.2"><p id="mrs_01_1445__a024830b3bf5049a6a6baa531e07104f7">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_1445__r7ff21ade6c684db4b3db45dae82b6c28"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__afe398ae29f4a4da8a8acb611f6659438">index_name</p>
</td>
<td class="cellrowborder" valign="top" width="79.62%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1445__a83a3d923380648c7b17aa5f94e5ffd12">Index table name. It consists of letters, digits, and special characters (_).</p>
</td>
</tr>
<tr id="mrs_01_1445__re566e80fa1c54ffd9f225cbaa7500910"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__aa5d57e46bc394ffbb0b1d7fa3dc7397e">db_name</p>
</td>
<td class="cellrowborder" valign="top" width="79.62%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1445__abce1250ad4474de19de2c95ae345bed7">Database name. It consists of letters, digits, and special characters (_).</p>
</td>
</tr>
<tr id="mrs_01_1445__r74262e1f856541ddb2df29811e027d22"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__aa6b7410f10c043619393f33af0440d8a">table_name</p>
</td>
<td class="cellrowborder" valign="top" width="79.62%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1445__ae5c06732fb2b4193952848fef47b3b8e">Name of the database table. It consists of letters, digits, and special characters (_).</p>
</td>
</tr>
<tr id="mrs_01_1445__rd93310ce93694e6daa1a06c134318bbc"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__afaad81f732cc40b99adc41b5cccb9137"><span id="mrs_01_1445__pe4f1b12bb0094bda8a939662cb1bf55f">col_name</span></p>
</td>
<td class="cellrowborder" valign="top" width="79.62%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1445__a97eab55cd1404539b852763e38150666">Name of a column in a table. Multiple columns are supported. It consists of letters, digits, and special characters (_).</p>
</td>
</tr>
<tr id="mrs_01_1445__r0da0efab0c854685b25c7cd72d77a7b5"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__a4af2a929a9c24387add4c5f90b904da9">table_blocksize</p>
</td>
<td class="cellrowborder" valign="top" width="79.62%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1445__ac28cd075d30a4d4a950b27eac123b16a">Block size of a data file. For details, see <a href="mrs_01_1425.html#mrs_01_1425__l053c6fa1a366488ea6410cb4bb4fc5d1">•Block Size</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mrs_01_1445__s8290f5aad4a74cd5b607a4205ad9cfb4"><h4 class="sectiontitle">Precautions</h4><p id="mrs_01_1445__afdc731c57ee24c1e900ede557ae8f91f"><strong id="mrs_01_1445__b9106172611414">db_name</strong> is optional.</p>
</div>
<div class="section" id="mrs_01_1445__sb4d59b85540647c7874df9e153384349"><h4 class="sectiontitle">Examples</h4><p id="mrs_01_1445__p119241022145814"><strong id="mrs_01_1445__b7148133422117">create table </strong><strong id="mrs_01_1445__b172891211102511">productdb.productSalesTable(id int,price int,productName string,city string) stored </strong><strong id="mrs_01_1445__b8289141110257">as </strong><strong id="mrs_01_1445__b1728919118257">carbondata;</strong></p>
<p id="mrs_01_1445__p5442121805810"><b><span class="cmdname" id="mrs_01_1445__cmdname18381431161918">CREATE INDEX productNameIndexTable on table productdb.productSalesTable (productName,city) as 'carbondata' ;</span></b></p>
<p id="mrs_01_1445__ad21671cd18cf48bb821b37a5e81eb7cd">In this example, a secondary table named <span class="filepath" id="mrs_01_1445__f06e89ecec9884f6e81ba41eaeb953447"><b>productdb.productNameIndexTable</b></span> is created and index information of the provided column is loaded.</p>
</div>
<div class="section" id="mrs_01_1445__s1ad43c8d411844f2a7b087692de98193"><h4 class="sectiontitle">System Response</h4><p id="mrs_01_1445__ac58eefec29914019b80400304ef63245">A secondary index table will be created. Index information related to the provided column will be loaded into the secondary index table. The success message will be recorded in system logs.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_1437.html">DML</a></div>
</div>
</div>