Hive定位:ETL(数据仓库)工具
将数据从来源端经过抽取(extract)、转换(transform)、加载(load)至目的端的工具,如像:kettle
有关Hive数据导入导出mysql的问题请查看《如何利用sqoop将hive数据导入导出数据到mysql》
DML
批量插入/批量导入
LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)]
注:filepath可以是hdfs路径或者是S3路径,如hdfs://namenode:9000/user/hive/project/data1
1.从本地文件导入到表
load data local inpath 'test.txt' into table test;
2.从hdfs导入到表
load data inpath '/home/test/add.txt' into table test;
3.从表查询中导入到表
insert into table test select id, name, tel from test;
4.将查询数据导入到多个表
from source_table
insert into table test select id, name, tel from dest1_table select src.* where src.id < 100
insert into table test select id, name, tel from dest2_table select src.* where src.id < 100
insert into table test select id, name, tel from dest3_table select src.* where src.id < 100;
5.建表时导入
create table test4 as select id, name, tel from test;
指定分隔符导出数据
insert overwrite local directory '/home/hadoop/export_hive'
row format delimited