日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Hive几种数据导入方式

發(fā)布時間:2025/3/18 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Hive几种数据导入方式 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

2019獨角獸企業(yè)重金招聘Python工程師標準>>>

1.從本地文件系統(tǒng)中導入數(shù)據(jù)到hive表

(1)數(shù)據(jù)準備(/home/sopdm/test.dat):

1,wyp,25,13188888888 2,test,30,13899999999 3,zs,34,89931412

(2)首先創(chuàng)建表 use sopdm; drop table if exists sopdm.wyp; create table if not exists sopdm.wyp(id int,name string,age int,tel string) row format delimited fields terminated by ',' stored as textfile;

(3)從本地文件系統(tǒng)中導入數(shù)據(jù)到Hive表

load data local inpath ‘/home/sopdm/test.dat’ into table sopdm.wyp;

(4)可以到wyp表的數(shù)據(jù)目錄下查看,如下命令

dfs -ls /user/sopdm/hive/warehouse/sopdm.db/wyp;

2.從HDFS上導入數(shù)據(jù)到Hive表

(1)現(xiàn)在hdfs中創(chuàng)建一個input目錄存放HDFS文件 hadoop fs -mkdir input; 或 hadoop fs -mkdir /user/sopdm/input;

(2)把本地文件上傳到HDFS中,并重命名為test_hdfs.dat hadoop fs -put /home/sopdm/test.dat /user/sopdm/input/test_hdfs.dat;

(3)查看文件 dfs -cat /user/sopdm/input/test_hdfs.dat;

(4)將內(nèi)容導入hive表中

--拷貝“本地數(shù)據(jù)”到“hive”使用:load data local… --轉(zhuǎn)移“HDFS”到“hive”(必須同一個集群)使用:load data… load data inpath ‘/user/sopdm/input/test_hdfs.dat’ into table sopdm.wyp;

3.從別的Hive表中導入數(shù)據(jù)到Hive表中

create table if not exists sopdm.wyp2(id int,name string,tel string) row format delimited fields terminated by ',' stored as textfile;

--overwrite是覆蓋,into是追加 insert into table sopdm.wyp2 select id,name,tel from sopdm.wyp;

--多表插入 --高效方式-查詢語句插入多個分區(qū) from sopdm.wyp w insert overwrite table sopdm.wyp2 select w.id,w.name,w.tel where w.age=25 insert overwrite table sopdm.wyp2 select w.id,w.name,w.tel where w.age=27;

4.創(chuàng)建Hive表的同時導入查詢數(shù)據(jù)

create table sopdm.wyp3 as select id,name,tel,age from sopdm.wyp where age=25;

5.使用sqoop從關(guān)系數(shù)據(jù)庫導入數(shù)據(jù)到Hive表 這個放在sqoop總結(jié)中去講解。

轉(zhuǎn)載于:https://my.oschina.net/u/2381604/blog/799451

總結(jié)

以上是生活随笔為你收集整理的Hive几种数据导入方式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。