数据导入六种方式
1、加载本地文件到hive表
语法
![](https://i-blog.csdnimg.cn/blog_migrate/0203a2a7b674cfb0e231d2d2ac049e4a.webp?x-image-process=image/format,png)
![](https://i-blog.csdnimg.cn/blog_migrate/cf1a8db2f6fb23969d6f26937de36aac.webp?x-image-process=image/format,png)
![](https://i-blog.csdnimg.cn/blog_migrate/2d741faee9a9d4bf017f2dbeed73f3bf.webp?x-image-process=image/format,png)
2、加载hdfs文件到hive中
![](https://i-blog.csdnimg.cn/blog_migrate/0d4fdadda24a44e0da2974a728573c1b.webp?x-image-process=image/format,png)
3、加载数据覆盖表中已有的数据
![](https://i-blog.csdnimg.cn/blog_migrate/82d72ee0e612dc317546258995836932.webp?x-image-process=image/format,png)
4、创建表时通过select加载
create table if not exists default.dept_cats
as select * from dept;
5、创建表通过insert加载
![](https://i-blog.csdnimg.cn/blog_migrate/ccb401b004e453ac7e3a770c48174817.webp?x-image-process=image/format,png)
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');
这样就可以直接访问。