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

(1)數(shù)據(jù)準(zhǔn)備(/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;

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

load datalocalinpath ‘/home/sopdm/test.dat’ into table sopdm.wyp;

從HDFS上導(dǎo)入數(shù)據(jù)到Hive表

load data inpath ‘/user/sopdm/input/test_hdfs.dat’ into table sopdm.wyp;

從別的Hive表中導(dǎo)入數(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是追加

insertintotable 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表的同時導(dǎo)入查詢數(shù)據(jù)

create table sopdm.wyp3

asselect id,name,tel,age from sopdm.wyp where age=25;

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容