Hive DML数据操作

Hive DML数据操作

1.数据导入

load data [local] inpath '数据path' [overwrite] into table student [partition (col=x)]
--load 表示加载数据
--local 表示从本地加载数据到hive表,否则从HDFS加载到数据表
--inpath 表示加载数据的路径
--overwrite 表示是否覆盖表中已有数据,否则表示追加
--into table 表示追加到那张表
--partition 表示上传到指定分区

insert overwrite table table_name
select id, name from student where id < 1006

2.数据导出

--将查询结果导出到本地
insert overwrite [local] directory '/xxx/xxx' select * from table_name
--local表示是否将结果导入到本地,不加则表示导入到HDFS上


--将查询结果格式化导出到本地
insert overwrite local directory '/xxx/xxx' 
row format delimited fields terminated by '\t'
select * from table_name


3.查询语句(HiveSql的执行顺序)

--HiveSql语句的执行顺序

from
join on
[lateral views explode(col) tb_name as col_name] --炸裂函数
where
group by(可以使用select中的别名了)
聚集函数 count() avg() sum()
having
select --如果包含开窗函数,开窗函数通过表数据进行分区和排序,跟select中的字段是平衡关系,不          依赖查询字段
distinct
order by
limit
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值