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

50 lines
6.1 KiB
HTML

<a name="mrs_01_1441"></a><a name="mrs_01_1441"></a>
<h1 class="topictitle1">INSERT INTO CARBON TABLE</h1>
<div id="body1595920213284"><div class="section" id="mrs_01_1441__s3635a0acb90b4993bd3ec49d72d184b2"><h4 class="sectiontitle">Function</h4><p id="mrs_01_1441__a7c198bf2c3ac40b08c49397d79368b0e">This command is used to add the output of the SELECT command to a Carbon table.</p>
</div>
<div class="section" id="mrs_01_1441__s98d94c476c89464283380c169a39c3db"><h4 class="sectiontitle">Syntax</h4><p id="mrs_01_1441__a04c70312121e425d972d400525860f0b"><b><span class="cmdname" id="mrs_01_1441__cmdname7702135371710">INSERT INTO [CARBON TABLE] [select query]</span></b>;</p>
</div>
<div class="section" id="mrs_01_1441__sbe8fcdf864854703a0baa12e58c48821"><h4 class="sectiontitle">Parameter Description</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_1441__t5be4c9a0e84a470c83ccef495498b366" frame="border" border="1" rules="all"><caption><b>Table 1 </b>INSERT INTO parameters</caption><thead align="left"><tr id="mrs_01_1441__r64ddb93f079344a8b87ad9ed751070ea"><th align="left" class="cellrowborder" valign="top" width="23.68%" id="mcps1.3.3.2.2.3.1.1"><p id="mrs_01_1441__aea60f327d33f4b879bb9a6f9526f4be9"><strong id="mrs_01_1441__b115152011115419">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="76.32%" id="mcps1.3.3.2.2.3.1.2"><p id="mrs_01_1441__aef70568549f840e59d0ff2e8888670e3"><strong id="mrs_01_1441__b14876151212540">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_1441__rc8314c90829b48509b421a7f14c2f54b"><td class="cellrowborder" valign="top" width="23.68%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1441__a234e6b2a720445778d4b07df52d737cd">CARBON TABLE</p>
</td>
<td class="cellrowborder" valign="top" width="76.32%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1441__a7ef19cdd66af46f0bee9be1785d45d61">Name of the CarbonData table to be inserted</p>
</td>
</tr>
<tr id="mrs_01_1441__r63d4d2ba87054461a5ed6e7e7a35ea93"><td class="cellrowborder" valign="top" width="23.68%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_1441__afa6af8dbad144471a00645e139a6d203">select query</p>
</td>
<td class="cellrowborder" valign="top" width="76.32%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_1441__af0b7e6dfb2b94576840eaf41dfa3bc8e">SELECT query on the source table (CarbonData, Hive, and Parquet tables are supported)</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mrs_01_1441__s6025d975533d475d8af0cfa213d22c18"><h4 class="sectiontitle">Precautions</h4><ul id="mrs_01_1441__u9ef5cd8074bb4d5aa999ddd3e6c5e76e"><li id="mrs_01_1441__la4acf75df3ac4d0599dc607651641f21">A table has been created.</li><li id="mrs_01_1441__l21ff843cee064c829db3389cd4e3f121">You must belong to the data loading group in order to perform data loading operations. By default, the data loading group is named <span class="parmname" id="mrs_01_1441__p15d0b5e5b8bb469cb593c0231c4ea4da"><b>ficommon</b></span>.</li><li id="mrs_01_1441__lef49913a6a844580975b2510477c0b59">CarbonData tables cannot be overwritten.</li><li id="mrs_01_1441__lcaae8960743149e893a46a81bce7f10a">The data type of the source table and the target table must be the same. Otherwise, data in the source table will be regarded as bad records.</li><li id="mrs_01_1441__la2b4aeb3e90c4860a5976b2fe78f8a8d">The <b><span class="cmdname" id="mrs_01_1441__cmdname13779192132914">INSERT INTO</span></b> command does not support partial success. If bad records exist, the command fails.</li><li id="mrs_01_1441__l4b15368df97f4466a54b2612d760e3e2">When you insert data of the source table to the target table, you cannot upload or update data of the source table.<p id="mrs_01_1441__a52e4e7c073de4c5e854ddae5a38febcb"><a name="mrs_01_1441__l4b15368df97f4466a54b2612d760e3e2"></a><a name="l4b15368df97f4466a54b2612d760e3e2"></a>To enable data loading or updating during the INSERT operation, set the following parameter to <span class="parmvalue" id="mrs_01_1441__p8d95f10fd83b42dbbfe245a72df51c4f"><b>true</b></span>.</p>
<p id="mrs_01_1441__af51452500bbd4baea63edab07c7973b1"><span class="parmname" id="mrs_01_1441__p7fab2bcb461c4444b857dc4b048e2682"><b>carbon.insert.persist.enable</b></span>=<span class="parmvalue" id="mrs_01_1441__pb2efaf56748b470ca9787576c841fcc7"><b>true</b></span></p>
<p id="mrs_01_1441__a1772d279bd694670b52daccb72ac48d3">By default, the preceding parameters are set to <span class="parmvalue" id="mrs_01_1441__pa0f77f28c6ef4e5b8c15d4f8a4cc1c7c"><b>false</b></span>.</p>
<div class="note" id="mrs_01_1441__n352a3aea389a446bb9ac04149a6054fc"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_1441__a4f86b614984e4f5fb3e805802f9c4fae">Enabling this property will reduce the performance of the INSERT operation.</p>
</div></div>
</li></ul>
</div>
<div class="section" id="mrs_01_1441__s5774072650ef43f4acf8b5bf8a6b75ea"><h4 class="sectiontitle">Example</h4><p id="mrs_01_1441__p17635116101911"><strong id="mrs_01_1441__b8842925101917">create table </strong><strong id="mrs_01_1441__b1328216508250">carbon01(a int,b string,c string) stored as carbondata;</strong></p>
<p id="mrs_01_1441__p10635191661917"><strong id="mrs_01_1441__b19573449162512">insert into table </strong><strong id="mrs_01_1441__b7283165017254">carbon01 values(1,'a','aa'),(2,'b','bb'),(3,'c','cc');</strong></p>
<p id="mrs_01_1441__p206350164194"><strong id="mrs_01_1441__b18574104916252">create table </strong><strong id="mrs_01_1441__b028315002515">carbon02(a int,b string,c string) stored as carbondata;</strong></p>
<p id="mrs_01_1441__p186351216181916"><strong id="mrs_01_1441__b12576349122514">INSERT INTO </strong><strong id="mrs_01_1441__b9284195010252">carbon02 select * from carbon01 where a &gt; 1;</strong></p>
</div>
<div class="section" id="mrs_01_1441__s089e7b6ebc3a401c93534dbe58a8ed83"><h4 class="sectiontitle">System Response</h4><p id="mrs_01_1441__abfe2a72f74b942ae8a2f3a2a73926ff7">Success or failure will be recorded in the driver 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>