导入数据到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');

这样就可以直接访问。

猜你喜欢

转载自blog.csdn.net/qq_16095837/article/details/79464932