【Hive】数据导入

…衆ロ難τιáo~ 提交于 2020-02-08 12:31:36

Hive版本:Hive 1.1.0-cdh5.14.2

INSERT导出到目录

官方链接

Standard syntax:
INSERT OVERWRITE [LOCAL] DIRECTORY directory1
[ROW FORMAT row_format] [STORED AS file_format] (Note: Only available starting with Hive 0.11.0)
SELECT … FROM …
Hive extension (multiple inserts):
FROM from_statement
INSERT OVERWRITE [LOCAL] DIRECTORY directory1 select_statement1
[INSERT OVERWRITE [LOCAL] DIRECTORY directory2 select_statement2] …

举例如下:

1)导出到本地目录
insert overwrite local directory '/home/hadoop/hive/data_export/score'
row format delimited fields terminated by ','
select * from score;2)导出到hdfs目录
insert overwrite directory '/score'
row format delimited fields terminated by ','
select * from score;

Hive客户端导出

(1)hive -e “sql语句” > file
(2)hive -f sql文件 > file

举例如下:

hive -e 'select * from myhive.score;' > /home/hadoop/hive/data/score.txt

export导出表

官网链接

EXPORT TABLE tablename [PARTITION (part_column=“value”[, …])] TO ‘export_target_path’ [ FOR replication(‘eventid’) ]

举例如下:

注:只能导出到hdfs目录
export table department to 'hdfs_exports_location/department';
export table employee partition (emp_country="in", emp_state="ka") to 'hdfs_exports_location/employee';
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!