- 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;
- 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;