hive中有关表的数据导入或者落实相关文件的几种方式

一.将hive表中数据导入指定文件:

1.将hive表中的数据导入到HDFS的文件

insert overwrite directory '/root/table_to_file'
row format delimited fields terminated by ','    --默认为csv文件格式
select * from table_name;

2、将hive表中的数据导入到本地磁盘

insert overwrite local directory '/root/table_to_file'
row format delimited fields terminated by ','    --默认为csv文件格式
select * from table_name;

二、将指定文件数据导入指定hive表中

1.将HDFS文件加载到指定hive表中

load data inpath '/root/HDFS_to_table'  into table table_name partition(date='2019-07-01');

2.将本地文件加载到hive表中

load data local inpath '/root/local_to_table' into table table_name partition(date='2019-07-01');

三,将指定hive表中的数据导入指定hive表中

1.第一种方式,创建hive表时指定语句导入

--第一种
create table table_name as select * from other_table_name;
--第二种
create table table_name like other_table_name;

2.第二种方式,将创建完成的hive表指定导入别的hive表数据

insert into table table_name partition(date='2019-07-01') select * from others_table;

四,将一个hive中的表导入多个表中

from from_table
insert into to_table_1 select id --将from_table中的id 导入到to_table_1表中
insert into to_table_2 select name --将from_table中的name 导入到to_table_2中
; 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值