TXT格式文件插入Hive

1 Hive操作

1.1 创建数据库

create database if not exists myhive;
use myhive;

1.2 创建表

row format delimited fields terminated by ',':指定字段之间的分隔符
stored as textfile:指定文件存储格式
create table if not exists test(XXX int,XXX string) row format delimited fields terminated by ',' stored as textfile;

1.3 导入txt文件到表

load data local inpath '/test.txt' into table test;

1.4 查询结果并保存

1.4.1 导出到本地

insert overwrite local directory "/test/out/" row format delimited fields terminated by "\t" select * from test;

1.4.2 导出到hdfs

insert overwrite directory "/test/out/" row format delimited fields terminated by "\t" select * from test;

 

posted @ 2020-11-30 00:15  MoooJL  阅读(555)  评论(0编辑  收藏  举报