匯入資料進入hive的6種方式
阿新 • • 發佈:2019-01-06
下面介紹幾種常用的匯入資料到hive的方式
- 載入本地檔案到hive
load data local inpath '/data/hive/student_info.txt' into table default.student_info
- 載入hdfs檔案到hive中
load data inpath '/data/hive/student_info.txt' into table default.student_info
- 載入資料覆蓋表中已有的資料
load data inpath '/data/hive/student_info.txt' overwrite into table default.student_info
- 建立表的時候通過insert 插入資料
create table default.student_info_c1 like student_info;
insert into table default.student_info_c1 select * from default.student_info;
- 建立表的時候通過location 載入
create table user_info_t1( id int ,name string ,hobby array<string> ,add map<String,string> ) STORED AS TEXTFILE row format delimited fields terminated by ',' collection items terminated by '-' map keys terminated by ':' LOCATION '/hive/data/ ';
- import 方法
import table student_info partition (country="china") from "/data/hive/import/"