Hive 中 DML(数据操作):
1.加载本地文件到 hive:
loda data local inpath '/ ' into table 库名.表名 ;
2.上传文件到HDFS:
dfs -put /文件路径 /HDFS路径 ;
3.加载HDFS数据:
load data inpath '/ ' into table 库名.表名 ;
4.加载数据覆盖原表中已有数据:
load data inpath '/ ' overwrite into table 库名.表名 ;
5.根据单张表查询结果插入:
insert ( into | overwrite ) table *** select *,* from *** ; ( into:追加,overwrite:覆盖 ) ;
6.根据查询结果创建表:
create table if not exists *** as select *,* from *** ;
7.创建表时制定加载数据路径:
create external table ***() location '/ ' ;
8.表的查询结果导出到本地:
insert overwrite local directory '/ ' select * from *** ;
9.表的查询结果导出到HDFS:
insert overwrite local directory '/ ' select * from *** ;
10.Hive Shell 命令导出:
hive -e ' select * from 库名.表名 ; ' > / ;
export 导出到 HDFS: export table 库名.表名 to '/ ' ;
11.import 导入数据:
import table *** from '/ ' ; ( 先执行export后才可执行import )
12.清除表中数据(不能删除外部表中数据):
truncate table *** ;