hive匯入資料的方式

2021-10-07 02:52:54 字數 1443 閱讀 1242

load data

[local] inpath 'filepath'

[overwrite] into table tablename [partition (partcol1=val1, partcol2=val2 ...)]

解釋:

local:可選,表示從本地檔案系統中載入,而非hdfs

overwrite:可選,先刪除原來資料,然後再載入

partition:這裡是指將inpath中的所有資料載入到那個分割槽,並不會判斷待載入的資料中每一條記錄屬於哪個分割槽。

注意:load完了之後,會自動把inpath下面的源資料刪掉,其實就是將inpath下面的資料移動到/usr/hive/warehouse目錄下了

load data local inpath '/opt/mydata.csv' overwrite into table mydemo.gaga;
load data inpath 'user/tuoming/test/tt/student2.txt' into table temp_student;
create external table if not exists categories (  

category_id int,

category_department_id int,

category_name varchar(45)

) row format serde 'org.apache.hadoop.hive.serde2.opencsvserde'

with serdeproperties (

"separatorchar"=","

) location '/data/retail_db/categories'

;

create table if not exists default.dept_cats as select

*from dept;

insert into table mypart partition(gender='male'

) values(1,

'zs'

);

給靜態分割槽追加乙個表

insert into table mypart partition(gender='male'

)select

*from userinfos;

insert overwrite 覆蓋、全量表、拉鍊表

insert overwrite table mypart partition(gender='female'

)select userid,username from userinfos

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 資料在本地位置 into table table name 2.loadhdfs資料 增量匯入資料 在原來的資料後追加 load data inpath 資料在hdfs中的位置 into table table name 全量匯入資料 會覆蓋掉原本的資料...