hive 导入数据的方式

1.加载本地文件到hive 拷贝文件

load data local inpath 'linux_filepath' into table tablename;

->应用场景:常见的情况,一般用于日志文件的直接导入

2.加载HDFS文件到hive  移动文件

load data inpath 'hdfs_filepath' into table tablename;

->应用场景:本地数据存储文件比较大的情况

3.覆盖表中的数据

load data local inpath 'linux_filepath' overwrite into table tablename;

->应用场景:一般用于临时表数据的导入

4.创建表时通过select 加载数据

create table tmp2_table2 as select * from tmp2_table;


->应用场景:常用于临时表反复使用,作为数据分析结果的保存。

5.创建表时通过location加载数据

create table tmp2_table3(col_comment....) location 'hdfs_filepath';

->应用场景:固定的数据采集时指定hdfs的数据目录

6.创建表以后,时通过insert加载数据

insert into|override table tbname select * ...
create table tmp2_table4(
num string,
name string
)
row format delimited fields terminated by '\t'
stored as textfile;
insert into table tmp2_table4 select * from tmp2_table;


->用于数据分析结果的导入或者存储

猜你喜欢

转载自blog.csdn.net/dengwenqi123/article/details/81700015
今日推荐