insert into with as
时间: 2023-10-07 19:07:51 浏览: 125
在Hive中,可以使用"insert into"语句将数据插入到表中,也可以使用"with as"子查询来创建一个临时表。当同时使用"insert into"和"with as"时,需要将"insert into"放在"with as"子查询后面。这样可以先创建临时表,然后将临时表的数据插入到目标表中。
例如,可以使用以下语法来使用"insert into"和"with as":
WITH TEMP_A AS (SELECT * FROM table_a),
TEMP_B AS (SELECT * FROM TEMP_A WHERE column_x = 'xxx')
INSERT INTO table_b SELECT * FROM TEMP_B;
这个例子中,首先创建了一个名为TEMP_A的临时表,然后使用该临时表创建了TEMP_B临时表。最后,使用"insert into"将TEMP_B临时表的数据插入到名为table_b的目标表中。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Hive insert插入数据与with子查询](https://blog.csdn.net/sinat_23133783/article/details/120317168)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [Hive 中 insert into 与with as连用](https://blog.csdn.net/u010711495/article/details/114036125)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文