应用场景:
数据迁移:Hive中的数据表要迁移到另一套集群上,使用导入导出命令操作
官网语法:
EXPORT TABLE tablename [PARTITION (part_column="value"[, ...])]
TO 'export_target_path' [ FOR replication('eventid') ]
IMPORT [[EXTERNAL] TABLE new_or_original_tablename [PARTITION (part_column="value"[, ...])]]
FROM 'source_path'
[LOCATION 'import_target_path']
简单表的导入导出:
export table emp to '/user/hive/warehouse/exp_emp';
#导出的数据包括"_metadata"和"data"两个目录
import from '/user/hive/warehouse/exp_emp';
简单表的导出、改名导入:
export table emp to '/user/hive/warehouse/exp_emp';
import table rename_emp from '/user/hive/warehouse/exp_emp';