11.把文本文件的数据导入到Hive表中

先在hive里面创建一个表

create table  mydb2.t3(id int,name string,age int) row format delimited fields terminated by ','stored as textfile;

接下来创建数据文件

 把本地的数据文件导入到hive表中

LOAD DATA LOCAL INPATH '/opt/datas/a.txt' OVERWRITE INTO  TABLE  t3;

 

 接下来把hdfs上的文件导入到hive表中

现在在hdfs上创建目录,并把本地文件上传到hdfs

 在hive再创建一个表tt

create table  mydb2.tt(id int,name string,age int) row format delimited fields terminated by ','stored as textfile;

 把hdfs上的文件导入到hive的tt表里面

LOAD DATA  INPATH '/home/hadoop/testhive/a.txt' OVERWRITE INTO  TABLE  tt;

 

猜你喜欢

转载自www.cnblogs.com/braveym/p/10872946.html
今日推荐