总结:
- 本地文件导入到Hive表–
load data local inpath '路径' into/overwrite table 表名
- HDFS文件导入到Hive表
load data inpath 'hdfs路径' into/overwrite table 表名
- Hive表导入到Hive表
(select 或者insert )
- 创建表的过程中从其他表导入
create table ... as select xxx from 其他表
- 从其他表导入
insert into/overwrite table 表名 select xxx from 其他表
- 指定数据库目录在HDFS上的地址
location 'hdfs路径'
load会搬移数据,location是指定数据
1、加载本地文件到hive表
语法
2、加载hdfs文件到hive中
3、通过select加载
create table if not exists default.dept_cats
as select * from dept;
4、通过insert加载
5、创建表的时候通过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');