MySql日常使用不到的语句

MySql 查询表字段数

SELECT COUNT(*) FROM information_schema.columns WHERE table_schema=‘test_cases’ AND table_name=‘cases_send’ ;
test_cases 为数据库名称
cases_send 为表名
列出表字段名称

Mysql(hive) 查询当月,某个小时之间的商户信息

获取表中4月每天1点到3点的商户号和商户名称:
hive版:
select merchant_no,merchant_name,count() cnt
from jh_all_data
where created_at >= ‘2023-04-01 00:00:00’
and hour(created_at) between 1 and 3
group by merchant_no,merchant_name
注意:其中created_at 为string类型
mysql版:
select merchant_no,merchant_name,count(
) cnt
from jh_all_data
where CREATED_AT >= DATE_FORMAT(20230401000000, ‘%Y-%m-%d %H:%i:%s’)
and hour(created_at) between 1 and 3
group by merchant_no,merchant_name

Mysql 获取当前数据库下有多少张表

SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES
WHERE table_schema = ‘数据库名称’ GROUP BY table_schema;

Mysql 获取当前数据库下有多少张表名为 'T_%'开头

SELECT * FROM information_schema.TABLES
where table_schema = ‘数据库名称’ AND TABLE_NAME LIKE ‘T_%’

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值