大数据笔记

Hive 2.3 - Hive数据导入导出

2019-10-25  本文已影响0人  No_七

1、导入

1.1 load

1.1.1 本地文件,复制本地的student.txt 到student05表:

hive (db01)> load data local inpath '/opt/datas/student.txt' into table student05;
image.png

1.1.2 HDFS上的文件,移动HDFS上 的文件 /student.txt’到student05表

hive (db01)> load data inpath '/student.txt' into table student04;
image.png

1.1.3 HDFS上的文件,移动HDFS上 的文件 /student.txt’到student01表,并重写表中原来的数据

hive (db01)>load data inpath '/student.txt' overwrite into table student01 ;
1.2 as 通常用于数据查询结果的保存
hive (db01)> create table student07 as select num,name from student01;
image.png
1.3 insert into 类似于as
hive (db01)> insert into table student04 select * from student01;
image.png
1.4 location
hive (db01)> create table student06(xxxx) location '/student1';
1.5 import

可参考 https://blog.csdn.net/dengwenqi123/article/details/81700015

2、导出

2.1 insert overwrite
hive (db01)> insert overwrite local directory '/opt/datas/hive' select * from student01;

导出的数据加上制表符 ’\t’,与建表时的 row format delimited fields terminated by '\t’ 相同

hive (db01)> insert overwrite local directory '/opt/datas/hive' row format delimited fields terminated by '\t' select * from student01;
image.png
2.2 get
bin/hdfs dfs -get '/student.txt' '/opt/datas/hive/warehouse/student.txt';
2.3 使用Linux命令导出

使用hive的-e -f参数,将输出重定向保存到本地文件

2.4 sqoop 框架

(后面会写 )

2.5 export
hive (db01)> export table student07 to '/student07';
image.png
上一篇 下一篇

猜你喜欢

热点阅读