hive 匯出資料
阿新 • • 發佈:2019-01-24
hive有三種匯出資料的方式
》匯出資料到本地
》匯出資料到hdfs
》匯出資料到另一個表
匯出資料到本地檔案系統insert overwrite local directory '[desFile]' select * from [srcFile];
例: insert overwrite local directory '/home/wyp/wyp' select * from wyp;
這資料是匯出到本地檔案系統(/home/wyp/wyp),將會在本地目錄下生成檔案,這個因為是mapreduce跑的,所以生成的檔名是part-00000這種的匯出資料到hdfs(少了一個local)insert overwrite local directory '匯出資料到另一個hive表中[desFile]' select * from [srcFile]; 例: insert overwrite directory 'hdfs://路徑' select * from wyp;
insert into table descTable partition (age='25') select id, name, tel from srcTable;在0.11.0之前的版本,如果是匯出資料到檔案中,是不能指定列之間的分隔符的,採用的時候預設的分隔符‘~A’在0.11.0或之後的版本可以指定其列的分隔符,下面sql
insert overwrite local directory '如果是map型別可以用下面語句來分割map的key和value[localPath]' row format delimited fields terminated by '\t' select * from test;
insert overwrite local directory './test-04' row format delimited FIELDS TERMINATED BY '\t' COLLECTION ITEMS TERMINATED BY ',' MAP KEYS TERMINATED BY ':' select * from src;