1. 程式人生 > >匯入資料到hive表中的6種方式

匯入資料到hive表中的6種方式

資料匯入六種方式

1、載入本地檔案到hive表

語法




2、載入hdfs檔案到hive中


3、載入資料覆蓋表中已有的資料


4、建立表時通過select載入

create table if not exists default.dept_cats
as select * from dept;

5、建立表通過insert載入


6、建立表的時候通過location指定載入

外部表方式
create external table if not exists emp_partition(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int
)
partitioned by (month string)
row format delimited fields terminated by '\t'

load data local inpath '/opt/datas/emp.txt' into table default.emp_partition partition (month='201803');

這樣就可以直接訪問。