一.将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中
;