Mysql是否显示按创建日期排序的数据库?
有没有办法通过命令获取按创建日期或上次更新日期排序的MySQL数据库列表?尝试此操作以显示所有数据库和创建时间 选择table_schema,从INFORMATION_schema.TABLES创建时间Mysql是否显示按创建日期排序的数据库?,mysql,Mysql,有没有办法通过命令获取按创建日期或上次更新日期排序的MySQL数据库列表?尝试此操作以显示所有数据库和创建时间 选择table_schema,从INFORMATION_schema.TABLES创建时间 注意:我还没有测试过这个试试这个,如果你想按更新日期订购,你可以按更新时间订购 SELECT table_schema, MAX(create_time) create_time, MAX(update_time) update_time FROM information_schema.tab
注意:我还没有测试过这个试试这个,如果你想按更新日期订购,你可以按更新时间订购
SELECT
table_schema,
MAX(create_time) create_time,
MAX(update_time) update_time
FROM information_schema.tables
Group by TABLE_SCHEMA
Order by create_time desc
信息\u架构数据库包含有关数据库的元数据:
SELECT distinct table_schema
FROM information_schema.tables
Order by update_time
如果要在最新创建日期之前从
信息\u架构
顺序中获取数据库名称列表,请检查以下代码:
SELECT table_schema, MAX(create_time) create_time, MAX(update_time) update_time
FROM information_schema.tables WHERE create_time IS NOT NULL
GROUP BY TABLE_SCHEMA
ORDER BY create_time DESC;
SELECT DISTINCT table_schema
FROM information_schema.tables
ORDER BY update_time
从上面的查询结果中,我看到create_time列有一些值为null的结果。我假设这些记录可能是在mysql安装程序中默认创建的,所以做一些漂亮的更改
为空创建时间记录上方的筛选器添加其中创建时间不为空
:
SELECT table_schema, MAX(create_time) create_time, MAX(update_time) update_time
FROM information_schema.tables WHERE create_time IS NOT NULL
GROUP BY TABLE_SCHEMA
ORDER BY create_time DESC;
注意:如果您只想得到表_架构的结果,而不想使用MAX()
和分组依据,则可以使用DISTINCT
为此,您需要使用以下代码:
SELECT table_schema, MAX(create_time) create_time, MAX(update_time) update_time
FROM information_schema.tables WHERE create_time IS NOT NULL
GROUP BY TABLE_SCHEMA
ORDER BY create_time DESC;
SELECT DISTINCT table_schema
FROM information_schema.tables
ORDER BY update_time
如果对此有任何疑问,请告诉我
我希望这能有所帮助。考虑以下模式和查询
模式
查询
您会发现innodb表将具有update\u time
作为NULL
可在手册的标题为:
从MySQL 5.7.2开始,UPDATE_TIME为
对以下InnoDB表执行的最后一次更新、插入或删除:
没有分区。以前,UPDATE_TIME为显示空值
InnoDB表
这很有效。再加上一个显示table_name
,而不显示group by和max(),您在2017年仍然表现出色!