如何從表中導出資料呢?
如果資料檔案恰好是需要的格式,隻需要拷貝檔案或檔案夾
1、使用 insert…directory …
insert overwrite local directory ‘/tmp/xxq/sudent.txt’
select * from student ;
一個或多個檔案被寫入到/tmp/xxq/sudent.txt,具體個數取決于調用的reducer個數
不管源表中資料是怎麼存儲的,hive會将所有的字段序列化成字元串寫入到檔案中
檔案名是000000_0,如果有多個reducer寫輸出,還有000000_1
指定多個輸出檔案夾目錄:
from student
insert overwrite directory ‘/tmp/xxq/student1’
select *
insert overwrite directory ‘/tmp/xxq/student2’
select *;