Yang, Tong 3f5759eed2 MRS comp-lts 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>
2023-01-19 17:08:45 +00:00

61 lines
7.8 KiB
HTML

<a name="mrs_01_1445"></a><a name="mrs_01_1445"></a>
<h1 class="topictitle1">CREATE SECONDARY INDEX</h1>
<div id="body8662426"><div class="section" id="mrs_01_1445__en-us_topic_0000001219230727_sb8fd7fc95bb045a182a5198f84fd52e9"><h4 class="sectiontitle">Function</h4><p id="mrs_01_1445__en-us_topic_0000001219230727_a3918b03f1e7d4be59252f6676cea36e0">This command is used to create secondary indexes in the CarbonData tables.</p>
</div>
<div class="section" id="mrs_01_1445__en-us_topic_0000001219230727_sd2c2b6d9c1504b5487d4d9abb94ba7b2"><h4 class="sectiontitle">Syntax</h4><p id="mrs_01_1445__en-us_topic_0000001219230727_a4b4c27b093854632b507698a82ed541a"><b><span class="cmdname" id="mrs_01_1445__en-us_topic_0000001219230727_cmdname129321912131912">CREATE INDEX</span></b> <i><span class="varname" id="mrs_01_1445__en-us_topic_0000001219230727_vb8e3cb7c037340b1a03638e7cd1617b1">index_name</span></i></p>
<p id="mrs_01_1445__en-us_topic_0000001219230727_a10a0d4a55a744d599353e32f58b1e335"><b><span class="cmdname" id="mrs_01_1445__en-us_topic_0000001219230727_cmdname477111911910">ON TABLE</span></b> <i><span class="varname" id="mrs_01_1445__en-us_topic_0000001219230727_v1b8a1a32c5a64c868c253974de32ce27">[db_name.]table_name (col_name1, col_name2)</span></i></p>
<p id="mrs_01_1445__en-us_topic_0000001219230727_adf7f1fc91d2c4ce39fa69d7a31a12c2c"><b><span class="cmdname" id="mrs_01_1445__en-us_topic_0000001219230727_cmdname1671162351914">AS</span></b> <i><span class="varname" id="mrs_01_1445__en-us_topic_0000001219230727_vd5dd063631b6427081fc23ff5583322c">'carbondata</span></i>'</p>
<p id="mrs_01_1445__en-us_topic_0000001219230727_a0271a9ee6e3f40828ea425dfa51d0572"><b><span class="cmdname" id="mrs_01_1445__en-us_topic_0000001219230727_cmdname19729142621913">PROPERTIES</span></b> <i><span class="varname" id="mrs_01_1445__en-us_topic_0000001219230727_v6b051096ebda4e179177165423cf86b7">('table_blocksize'='256')</span></i>;</p>
</div>
<div class="section" id="mrs_01_1445__en-us_topic_0000001219230727_s8f4e64c8aaa64b358a92a4a4ab49ad08"><h4 class="sectiontitle">Parameter Description</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_1445__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_a024830b3bf5049a6a6baa531e07104f7">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_1445__en-us_topic_0000001219230727_r7ff21ade6c684db4b3db45dae82b6c28"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_a83a3d923380648c7b17aa5f94e5ffd12">Index table name. It consists of letters, digits, and special characters (_).</p>
</td>
</tr>
<tr id="mrs_01_1445__en-us_topic_0000001219230727_re566e80fa1c54ffd9f225cbaa7500910"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_abce1250ad4474de19de2c95ae345bed7">Database name. It consists of letters, digits, and special characters (_).</p>
</td>
</tr>
<tr id="mrs_01_1445__en-us_topic_0000001219230727_r74262e1f856541ddb2df29811e027d22"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_ae5c06732fb2b4193952848fef47b3b8e">Name of the database table. It consists of letters, digits, and special characters (_).</p>
</td>
</tr>
<tr id="mrs_01_1445__en-us_topic_0000001219230727_rd93310ce93694e6daa1a06c134318bbc"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__en-us_topic_0000001219230727_afaad81f732cc40b99adc41b5cccb9137"><span id="mrs_01_1445__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_r0da0efab0c854685b25c7cd72d77a7b5"><td class="cellrowborder" valign="top" width="20.380000000000003%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1445__en-us_topic_0000001219230727_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__en-us_topic_0000001219230727_ac28cd075d30a4d4a950b27eac123b16a">Block size of a data file. For details, see <a href="mrs_01_1425.html#mrs_01_1425__en-us_topic_0000001219230619_l053c6fa1a366488ea6410cb4bb4fc5d1">•Block Size</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mrs_01_1445__en-us_topic_0000001219230727_s8290f5aad4a74cd5b607a4205ad9cfb4"><h4 class="sectiontitle">Precautions</h4><p id="mrs_01_1445__en-us_topic_0000001219230727_afdc731c57ee24c1e900ede557ae8f91f"><strong id="mrs_01_1445__en-us_topic_0000001219230727_b9106172611414">db_name</strong> is optional.</p>
</div>
<div class="section" id="mrs_01_1445__en-us_topic_0000001219230727_sb4d59b85540647c7874df9e153384349"><h4 class="sectiontitle">Examples</h4><ul id="mrs_01_1445__en-us_topic_0000001219230727_u97e236620abb472eb27778d0967bde93"><li id="mrs_01_1445__en-us_topic_0000001219230727_lec0ea8a67dda4aa79e08c8662130041b"><b><span class="cmdname" id="mrs_01_1445__en-us_topic_0000001219230727_cmdname18381431161918">CREATE INDEX productNameIndexTable on table productdb.productSalesTable (productName,city) as 'carbondata';</span></b><p id="mrs_01_1445__en-us_topic_0000001219230727_ad21671cd18cf48bb821b37a5e81eb7cd">In this example, a secondary table named <span class="filepath" id="mrs_01_1445__en-us_topic_0000001219230727_f06e89ecec9884f6e81ba41eaeb953447"><b>productdb.productNameIndexTable</b></span> is created and index information of the provided column is loaded.</p>
</li><li id="mrs_01_1445__en-us_topic_0000001219230727_la92a3a0ea4fc4afea17ced80f5e3e9b0"><b><span class="cmdname" id="mrs_01_1445__en-us_topic_0000001219230727_cmdname19966203515197">CREATE INDEX t1_index1 on table t1 (c7_Datatype_Desc) AS 'carbondata' PROPERTIES('table_blocksize'='256');</span></b></li></ul>
</div>
<div class="section" id="mrs_01_1445__en-us_topic_0000001219230727_s1ad43c8d411844f2a7b087692de98193"><h4 class="sectiontitle">System Response</h4><p id="mrs_01_1445__en-us_topic_0000001219230727_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>