Hive導入導出方式

  • Hive中追加導入數據的4種方式是什麼?請寫出簡要語法
  1. 從本地導入: load data local inpath ‘/home/1.txt’ (overwrite)into table student;
  2. 從Hdfs導入: load data inpath ‘/user/hive/warehouse/1.txt’ (overwrite)into table student;
  3. 查詢導入: create table student1 as select * from student;(也可以具體查詢某項數據)
  4. 查詢結果導入:insert (overwrite)into table staff select * from track_log;
  • Hive導出數據有幾種方式?如何導出數據
  1. 用insert overwrite導出方式
    導出到本地:
insert overwrite local directory ‘/home/robot/1/2row format delimited fields terminated by ‘\t’ select * from staff;(遞歸創建目錄)

導出到HDFS

insert overwrite directory ‘/user/hive/1/2row format delimited fields terminated by ‘\t’ select * from staff;

  1. Bash shell覆蓋追加導出
$ bin/hive -e “select * from staff;> /home/z/backup.log
  1. Sqoop把hive數據導出到外部
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章