Oracle 表导入 Hive 表

156 阅读1分钟

一、需求

需要的数据在两个不同 Oracle 数据库中, 且其中一个数据库中的内容有一份一模一样的存在 hive 表中。

二、解决办法

将另一个 Oracle 表存入 hive 表中。

具体实现:

1. 将 Oracle 数据导出 CSV 文件:oracle_example.csv,并上传至服务器 /DATA 路径下;

2. 先根据原始 Oracle 表结构在 hive 中建立一个新表:

create table db.example (

A string,

B string,

C string,

D string,

E string,
)

row format delimited fields terminated by ','

stored as textfile;

 

3. 执行如下命令,将导出的CSV文件导入到创建的表里:

load data local inpath '/DATA/oracle_example.csv' into table db.example ;

 

以上,问题解决。