Hive匯入資料的6種方式

2021-09-27 13:53:18 字數 1100 閱讀 3143

下面介紹幾種常用的匯入資料到hive的方式 

1. 載入本地檔案到hive

load data local inpath '/data/hive/student_info.txt' into table default.student_info
2. 載入hdfs檔案到hive中

load data inpath '/data/hive/student_info.txt' into table default.student_info
3. 載入資料覆蓋表中已有的資料

load data inpath '/data/hive/student_info.txt' overwrite into table default.student_info
4. 建立表的時候通過insert 插入資料

create table default.student_info_c1 like student_info;

insert into table default.student_info_c1 select * from default.student_info;

5.  建立表的時候通過location 載入

create table user_info_t1(

id int

,name string

,hobby array,add map)

stored as textfile

row format delimited

fields terminated by ','

collection items terminated by '-'

map keys terminated by ':'

location '/hive/data/ ';

6. import 方法

import table student_info partition (country="china") from "/data/hive/import/"

hive 匯入資料的方式

load data local inpath linux filepath into table tablename 應用場景 常見的情況,一般用於日誌檔案的直接匯入 load data inpath hdfs filepath into table tablename 應用場景 本地資料儲存檔案比...

hive 匯入資料的方式

load data local inpath home hadoop data test1.txt into table test1 此處的檔案是從linux中的路徑中取的檔案插入到test1表中去的 load data inpath input test1.txt into table test1...

hive匯入資料的方式

load data local inpath filepath overwrite into table tablename partition partcol1 val1,partcol2 val2 解釋 local 可選,表示從本地檔案系統中載入,而非hdfs overwrite 可選,先刪除原...