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>
63 lines
8.4 KiB
HTML
63 lines
8.4 KiB
HTML
<a name="mrs_01_2330"></a><a name="mrs_01_2330"></a>
|
|
|
|
<h1 class="topictitle1">Hive SQL</h1>
|
|
<div id="body32001227"><p id="mrs_01_2330__en-us_topic_0263894577_p48701244">Hive SQL supports all features of Hive-<span id="mrs_01_2330__en-us_topic_0263894577_text5019438691856">3.1.0</span>. For details, see <a href="https://cwiki.apache.org/confluence/display/hive/languagemanual" target="_blank" rel="noopener noreferrer">https://cwiki.apache.org/confluence/display/hive/languagemanual</a>.</p>
|
|
<p id="mrs_01_2330__en-us_topic_0263894577_p35658012"><a href="#mrs_01_2330__en-us_topic_0263894577_tab1">Table 1</a> describes the extended Hive statements provided by .</p>
|
|
|
|
<div class="tablenoborder"><a name="mrs_01_2330__en-us_topic_0263894577_tab1"></a><a name="en-us_topic_0263894577_tab1"></a><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_2330__en-us_topic_0263894577_tab1" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Extended Hive statements</caption><thead align="left"><tr id="mrs_01_2330__en-us_topic_0263894577_row1132111"><th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.3.2.5.1.1"><p id="mrs_01_2330__en-us_topic_0263894577_p24592149">Extended Syntax</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.3.2.5.1.2"><p id="mrs_01_2330__en-us_topic_0263894577_p45807089">Syntax Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.3.2.5.1.3"><p id="mrs_01_2330__en-us_topic_0263894577_p19386696">Syntax Example</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.3.2.5.1.4"><p id="mrs_01_2330__en-us_topic_0263894577_p26818564">Example Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_01_2330__en-us_topic_0263894577_row24820109"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.1 "><p id="mrs_01_2330__en-us_topic_0263894577_p64271818">CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name (col_name data_type [COMMENT col_comment], ...) [ROW FORMAT row_format] [STORED AS file_format] | STORED BY 'storage.handler.class.name' [WITH SERDEPROPERTIES (...) ] ...... [TBLPROPERTIES ("groupId"=" group1 ","locatorId"="locator1")] ...;</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.2 "><p id="mrs_01_2330__en-us_topic_0263894577_p38634788">The statement is used to create a Hive table and specify locators on which table data files locate. For details, see <a href="mrs_01_0953.html">Using HDFS Colocation to Store Hive Tables</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.3 "><p id="mrs_01_2330__en-us_topic_0263894577_p46146710">CREATE TABLE tab1 (id INT, name STRING) row format delimited fields terminated by '\t' stored as RCFILE TBLPROPERTIES("groupId"=" group1 ","locatorId"="locator1");</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.4 "><p id="mrs_01_2330__en-us_topic_0263894577_p46896054">The statement is used to create table <strong id="mrs_01_2330__en-us_topic_0263894577_b192661110154512">tab1</strong> and specify locator1 on which the table data of <strong id="mrs_01_2330__en-us_topic_0263894577_b92721610194518">tab1</strong> locates.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2330__en-us_topic_0263894577_row19411308"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.1 "><p id="mrs_01_2330__en-us_topic_0263894577_p28812104">CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name (col_name data_type [COMMENT col_comment], ...) [ROW FORMAT row_format] [STORED AS file_format] | STORED BY 'storage.handler.class.name' [WITH SERDEPROPERTIES (...) ] ... [TBLPROPERTIES (<strong id="mrs_01_2330__en-us_topic_0263894577_b57982344">'column.encode.columns'</strong>='col_name1,col_name2'| '<strong id="mrs_01_2330__en-us_topic_0263894577_b52079048">column.encode.indices</strong>'='col_id1,col_id2', <strong id="mrs_01_2330__en-us_topic_0263894577_b66058249">'column.encode.classname'</strong>='encode_classname')]...;</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.2 "><p id="mrs_01_2330__en-us_topic_0263894577_p49117947">The statement is used to create a hive table and specify the table encryption column and encryption algorithm. For details, see <a href="mrs_01_0954.html">Using the Hive Column Encryption Function</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.3 "><p id="mrs_01_2330__en-us_topic_0263894577_p37959091">create table encode_test(id INT, name STRING, phone STRING, address STRING) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES ('column.encode.indices'='2,3', 'column.encode.classname'='org.apache.hadoop.hive.serde2.SMS4Rewriter') STORED AS TEXTFILE;</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.4 "><p id="mrs_01_2330__en-us_topic_0263894577_p54787541">The statement is used to create table <strong id="mrs_01_2330__en-us_topic_0263894577_b480211816494">encode_test</strong> and specify that column 2 and column 3 will be encrypted using the <strong id="mrs_01_2330__en-us_topic_0263894577_b17803418114912">org.apache.hadoop.hive.serde2.SMS4Rewriter</strong> encryption algorithm class during data insertion.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2330__en-us_topic_0263894577_row23325828"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.1 "><p id="mrs_01_2330__en-us_topic_0263894577_p10343879">REMOVE TABLE <em id="mrs_01_2330__en-us_topic_0263894577_i25986055">hbase_tablename</em> [WHERE where_condition];</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.2 "><p id="mrs_01_2330__en-us_topic_0263894577_p61925061205326">The statement is used to delete data that meets criteria from the Hive on HBase table. For details, see <a href="mrs_01_0956.html">Deleting Single-Row Records from Hive on HBase</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.3 "><p id="mrs_01_2330__en-us_topic_0263894577_p6421510">remove table hbase_table1 where id = 1;</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.4 "><p id="mrs_01_2330__en-us_topic_0263894577_p50380316">The statement is used to delete data that meets the criterion of "id = 1" from the table.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_2330__en-us_topic_0263894577_row50769665"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.1 "><p id="mrs_01_2330__en-us_topic_0263894577_p18702178">CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name (col_name data_type [COMMENT col_comment], ...) [ROW FORMAT row_format] <strong id="mrs_01_2330__en-us_topic_0263894577_b34101881">STORED AS inputformat 'org.apache.hadoop.hive.contrib.fileformat.SpecifiedDelimiterInputFormat'</strong> outputformat 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat';</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.2 "><p id="mrs_01_2330__en-us_topic_0263894577_p10789009">The statement is used to create a hive table and specify that the table supports customized row delimiters. For details, see <a href="mrs_01_0955.html">Customizing Row Separators</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.3 "><p id="mrs_01_2330__en-us_topic_0263894577_p13450690">create table blu(time string, num string, msg string) row format delimited fields terminated by ',' <strong id="mrs_01_2330__en-us_topic_0263894577_b53947353">stored as inputformat 'org.apache.hadoop.hive.contrib.fileformat.SpecifiedDelimiterInputFormat'</strong> outputformat 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat';</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.3.2.5.1.4 "><p id="mrs_01_2330__en-us_topic_0263894577_p7659482">The statement is used to create table <strong id="mrs_01_2330__en-us_topic_0263894577_b93855604911100">blu</strong> and set <strong id="mrs_01_2330__en-us_topic_0263894577_b198024684711100">inputformat</strong> to <strong id="mrs_01_2330__en-us_topic_0263894577_b99448478811100">SpecifiedDelimiterInputFormat</strong> so that the query row delimiter can be specified during the query.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_0581.html">Using Hive</a></div>
|
|
</div>
|
|
</div>
|
|
|