SQL语句用法记录

2022-11-24  本文已影响0人  朲跡坂硚灀2016

1.查询mysql数据库哪些表存在更新

select update_time,table_namefrom information_schema.tables t where t.table_schema = 'table_name' order by t.update_time desc;

2.mysql开启/关闭安全模式

# 开启

SET SQL_SAFE_UPDATES = 1;

# 关闭

SET SQL_SAFE_UPDATES = 0;

3.按照某一字段值进行排名

SELECT id, @rank := @rank + 1 as rank FROM table a, (SELECT @rank := 0) b ORDER BY id DESC;

4.时间差函数TIMESTAMPDIFF(unit,begin,end)

unit-微秒(microsecond)/秒(second)/分钟(minute)/小时(hour)/天(day)/周(week)/月(month)/季(quarter)/年(year)

SELECT now(), problem_register_date,TIMESTAMPDIFF( hour, problem_register_date,now()) '间隔时间',invalid_status,data_transfer_status,a.* FROM table_name a;

上一篇下一篇

猜你喜欢

热点阅读