關於hive資料匯入的小實驗

2021-09-21 13:37:59 字數 917 閱讀 1854

首先在自己本地路徑編寫2個資料檔案:

pv.txt:

1,111

2,111

1,222

user.txt:

111,25

111,18

222,32

然後hive中直接建立對應的2個表pv和users:

create table pv(

pageid string,

userid string)

row format delimited fields terminated by 『,』;

create table users(

userid string,

age string)

row format delimited fields terminated by 『,』;

然後資料匯入到2個表:(這裡注意因為是從本地匯入所以有local關鍵字,有local是複製,沒有local代表從hdfs中匯入,是移動不是複製)

load data local inpath 『/root/mytest/pv.txt』 into table pv;

load data local inpath 『/root/mytest/user.txt』 into table users;

然後寫hivesql進行實驗:

select pv.pageid,users.age

from pv

join users

on (pv.userid=users.userid);

結果正確

關於hive資料匯入方式的總結

從本地匯入資料到hive load data local inpath home hive tb dw cu three type list dtal dat overwrite into table csap.tb dw cu three type list dtal partition stat...

hive的資料匯入

hive的資料匯入 使用load語句 load data local inpath filepath overwrite into table tablename partition partcol1 val1,partcol2 val2,將student1.txt資料匯入表t2 load data...

HIVE資料匯入

1.text資料檔案匯出text資料表中 資料格式 建立相應的資料表 create table if not exists text table id int,count int comment table desc partitioned by date int row format delimi...