hive数据库的一些应用

1、创建表格create table usr_info(mob string,reason string,tag string) row format delimited fields terminated by '\t' stored as textfile;
2、将本地文件上传到创建表格中load data local inpath'/home/one.txt' overwrite into table usr_info;
3、修改表格中某个列的属性或列名alter table usr_info change mob mobile int;
4、删除表格drop table usr_info;
5、
  表名aaa
  id
  1
  2
  3
  表名bbb
  id
  1
  2
  4
left join 左关联(向左对齐,右边表格没有的为null)
例(
select 
  aaa.* 
  ,bbb.* 
from 
  aaa 
left join 
  bbb 
on(aaa.id=bbb.id)

)
得到
  1 1
  2 2
  3 null
right join 右关联(向右对齐,左边表格没有的为null)
得到
  1 1
  2 2
  null 4
full join 全关联
得到
  1 1
  2 2
  3 null
  null 4
join 内关联
得到
  1 1
  2 2
6、desc 降序,asc升序
7、举例

hive -e"
select 
pt
,min(amt) as min_money
,max(amt) as max_money
,count(distinct amt) as money_cnt
,sum(amt) as sum_money
from 
usr_pay
where pt<='2015-09-14' and pt>='2015-09-13'
group by pt
having min(amt)>10
order by pt desc"

8、 表格a union all b
要求列数、列名、列的顺序必须一致,最后得到的是结果的简单罗列(不去重)
9、order by rand()将前面得到的结果随机排序

10、if(one,two,three)用法 含义为如果one是真,取two,否则取three

11、case when one then two when three then four else five end as tag 用法含义同上

12、nvl(mob,1)用法 含义为如果mob是空,将它置为1

转载于:https://www.cnblogs.com/dudumiaomiao/p/4813141.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值