Hive資料匯入和匯出

2021-05-26 07:22:02 字數 1395 閱讀 3429

1.將select的結果放到乙個的的**中(首先要用create table建立新的**)

insert overwrite table test

select uid,name from test2;

2.將select的結果放到本地檔案系統中

insert overwrite local directory '/tmp/reg_3' select a.* from events a;

3.將select的結果放到hdfs檔案系統中

insert overwrite directory '/tmp/hdfs_out' select a.* from invites a where a.ds='';

load data [local] inpath 『/data/userdata』 [overwrite] into table user;

#建立表的時候直接指定路徑

create external table page_view(viewtime int, userid bigint,

page_url string, referrer_url string,

ip string comment 'ip address of the user',

country string comment 'country of origination')

comment 'this is the staging page view table'

row format delimited fields terminated by '44' lines terminated by '12'

stored as textfile

location '/user/data/staging/page_view';   #建立表之後也可以匯入資料到表中

#本機路徑(跳板機)

load data local inpath `/tmp/date.txt` overwrite into table page_view partition(pt='2008-06-08')

#hadoop路徑

load data inpath `/tmp/date.txt` overwrite into table page_view partition(pt='2008-06-08')

#上面overwrite關鍵會全表覆蓋,如果只是想附加資料,將overwrite去掉即可。   #新增乙個分割槽到表

alter table tmp_xx add partition (pt='100610') location '/group/mywork/hive/xx/pt=100610' ;

#當然你可以直接從從其它的表拖資料過來

insert overwrite table tmp_t1 select * from tmp_t2;

Hive 匯入匯出資料

將檔案中的資料載入到表中 load data local inpath examples files kv1.txt overwrite into table pokes 載入本地資料,同時給定分割槽資訊 load data local inpath examples files kv2.txt o...

hive資料匯入匯出

hive官方提供兩種匯入資料的方式 1 從表中匯入 insert overwrite table test select from test2 2 從檔案匯入 2.1 從本地檔案匯入 load data local inpath hadoop aa.txt overwrite into table ...

Hive資料的匯入和匯出

load data user huangxgc hive datas emp.txt overwrite into table default.emp 4 建立表時通過insert 載入 create table default emp like emp insert into select fro...