hive导入/导出实操案例

  1. Import 数据到指定 Hive 表中
    注意:先用 export 导出后,再将数据导入。
hive (default)> import table student2 partition(month='201709')
from '/user/hive/warehouse/export/student';

2.数据导出Insert 导出
(1)将查询的结果导出到本地

hive (default)> insert overwrite local directory
'/opt/module/datas/export/student'  select * from student;

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

hive(default)>insert overwrite local directory
'/opt/module/datas/export/student1'
 ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
select * from student;

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

hive (default)> insert overwrite directory
'/user/hadoop/student2'
 ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
 select * from student;

3.Hadoop 命令导出到本地

hive (default)> dfs -get
/user/hive/warehouse/student/month=201709/000000_0
/opt/module/datas/export/student3.txt;
  1. Hive Shell 命令导出
    基本语法:(hive -f/-e 执行语句或者脚本 > file)
[hadoop@hadoop102 hive]$ bin/hive -e 'select * from
default.student;' >/opt/module/datas/export/student4.txt;

5.Export 导出到 HDFS 上

(defahiveult)> export table default.student to
'/user/hive/warehouse/export/student';

6.清除表中数据(Truncate)
注意:Truncate 只能删除管理表,不能删除外部表中数据

hive (default)> truncate table student;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值