介绍
export 和 import 主要用于两个 Hadoop 平台集群之间 Hive 表迁移
export导出
export table 表名 to 'hdfs 路径'
例子
将 student 表的数据导出到 hdfs的 /data/student 目录下
export table student to '/data/student4';
特点
与 insert overwrite directory 类似,但是不需要执行 MR 程序,所以速度特别快
import导入
import table 表名 from 'hdfs 路径';
注意:
表存在,但没有数据,可以导入成功
有上面的
_metadata文件- 表不存在,可以导入成功
'hdfs 路径':必须是export导出的路径
例子
import table student5 from '/data/student4';
然后通过 select 语句,验证数据是否导入成功
