前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >数据导入hive表和hive表中数据导出的方式

数据导入hive表和hive表中数据导出的方式

作者头像
用户4870038
发布2021-02-05 10:21:21
1.9K0
发布2021-02-05 10:21:21
举报
文章被收录于专栏:MyBatis入门案例-注解

数据导入表的方式 1、直接向分区表中插入数据

代码语言:javascript
复制
insert into table score3 partition(month ='201807') values ('001','002','100'); 

2、通过查询插入数据

代码语言:javascript
复制
(linux ) load data local inpath '/export/servers/hivedatas/score.csv' overwrite into table score 
partition(month='201806'); 
(HDFS) load data inpath '/export/servers/hivedatas/score.csv' overwrite into table score 
partition(month='201806'); 

3、多插入模式

代码语言:javascript
复制
insert overwrite table score_fifirst partition(month='201806') select s_id,c_id from score ;
insert overwrite table score_second partition(month = '201806') select c_id,s_score from score ; 

4、查询语句中创建表并加载数据(as select)

代码语言:javascript
复制
create table score5 as select * from score; 

5、创建表时通过location指定加载数据路径

代码语言:javascript
复制
create external table score6 (s_id string,c_id string,s_score int) row format delimited fifields terminated by '\t' 
location '/myscore6';

数据导出表的方式 1、将查询的结果导出到本地

代码语言:javascript
复制
insert overwrite local directory '/export/servers/exporthive/a' select * from score; 

2、将查询的结果格式化导出到本地

代码语言:javascript
复制
insert overwrite local directory '/export/servers/exporthive' row format delimited fifields terminated by '\t' 
collection items terminated by '#' select * from student; 

3、将查询的结果导出到HDFS上(没有local)

代码语言:javascript
复制
insert overwrite directory '/export/servers/exporthive' row format delimited fifields terminated by '\t' collection 
items terminated by '#' select * from score;

4、Hadoop命令导出到本地

代码语言:javascript
复制
hdfs dfs -get /export/servers/exporthive/000000_0 /export/servers/exporthive/local.txt; 

5、hive shell 命令导出

代码语言:javascript
复制
bin/hive -e "select * from yhive.score;" > /export/servers/exporthive/score.txt 

6、export导出到HDFS上(全表导出)

代码语言:javascript
复制
export table score to '/export/exporthive/score';

7、SQOOP导出

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/01/06 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
大数据
全栈大数据产品,面向海量数据场景,帮助您 “智理无数,心中有数”!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档