-- 最近30天
select date_add(curdate(), interval(cast(help_topic_id as signed integer) - 30) day) day
from mysql.help_topic
where help_topic_id <= day(last_day(curdate()))
order by help_topic_id
-- 最近7天
select date_add(curdate(), interval(cast(help_topic_id as signed integer) - 6) day) day
from mysql.help_topic
where help_topic_id <= 6
order by help_topic_id
-- 一年内的每个月
select mid(date_add(curdate(), interval(cast(help_topic_id as signed integer) - 11) day) ,1,7) day
from mysql.help_topic
where help_topic_id <= 11
order by help_topic_id
--查看数据库大小:包含数据容量和索引容量
select table_schema as '数据库',sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables group by table_schema order by sum(data_length) desc, sum(index_length) desc;