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
  • 做实验时需要临时从其他表里导入数据造一张新表,可以这样:
#在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)

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

猜你喜欢

转载自blog.csdn.net/leitouguan8655/article/details/82788696