1.将查询结果插入Hive表语法结构:
1.1.基本模式插入:
INSERT OVERWRITE TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1 FROM from_statement
1.2.多插入模式:
FROM from_statement
INSERT OVERWRITE TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1
[INSERT OVERWRITE TABLE tablename2 [PARTITION ...] select_statement2] ...
1.3.自动分区模式:
INSERT OVERWRITE TABLE tablename PARTITION (partcol1[=val1], partcol2[=val2] ...) select_statement FROM from_statement
2.导出表结构:
方式1:查询结果导入到一张新的Hive表中:create table t_temp as select * from t_test;
方式2:查询结果导入到一张已存在的Hive表中:insert into table t_temp select * from t_p;
2.1.导出数据到本地: INSERT OVERWRITE [LOCAL] DIRECTORY directory1 SELECT ... FROM ...
2.2.导出数据到HDFS: