设为首页 加入收藏

TOP

hbase语句汇总、sql sever语句汇总、mysql语句汇总
2019-05-07 13:47:25 】 浏览:66
Tags:hbase 语句 汇总 sql sever mysql

hbase

hbase客户端:dbvis-multi.exe
用db时不会写Hbase语句,有些语句怕自己忘记,记录在下面:

  • 查某个字段值取特定值时的记录
select * from "table" where "time"='201709'
  • 统计频数
select "aa",count("aa") from "table" group by "aa"
  • 查找时间在某个范围的记录
select * from "table" where "time" between '20170101' and '20171220'
select * from "table" where "time" >= '20171101' and "time" <= '20171220'
  • 插入一条语句
UPSERT INTO "table" ("pk", "nnnn") VALUES ('aaaa','hh');
  • 查找字数大于等于200的记录
select "content","time" from "table" where length("content")>=200
  • 字段里含有“哈哈哈”、name在某个范围内的十个记录
select * from "table" where "content" like '%哈哈哈%' and "name" in ('zzz','yyy') limit 10
  • 插入一条记录
INSERT INTO table (a,b) VALUES (null, 1);
  • 更新一条记录
update "table" set "type" = '7' where "type" = 'h'
  • 分组后降序排
select "aa"  from "table" order by "aa" desc
  • 表的复制
create table a_copy like a 
insert into a_copy select * from a
  • 删除记录
delete from a_copy where class = 'hhh'
  • 做实验时需要临时从其他表里导入数据造一张新表,可以这样:
#在xshell里进入hbase主节点的环境
 hbase shell
 #在shell里清空表: truncate “table1”
 truncate "table1"
 #在db里执行插入数据的语句(把table2里的前100行插入table1) 
 upsert into "table1" select * from "table2" limit 100

sql sever

  • 删除表
drop TABLE 哈哈哈

mysql

  • 查找当月的记录
select * from table where to_char(sysdate,'yyyy-mm')=to_char(hh,'yyyy-mm')
  • 查找某一年某一季度的记录
select * from table where to_char(hh,'yyyy')=2016 and to_char(hh,'mm') in (1,2,3)
  • 降序排
select * from table where yearNo=2017 order by updateTime desc

spark的dataframe写入mysql时,比如df有3列(q,w,e),但mysql表有四列(q,w,e,r),我们只要给mysql的表字段设置默认值就行了,如Null.–我自己的话。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇hbase统计表的行数 下一篇Hbase   snapshot

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目