如何获取 MySQL 表的创建日期?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11868656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:26:46  来源:igfitidea点击:

How do I get the creation date of a MySQL table?

mysqlsqlsql-serverdatabase

提问by Matt Hintzke

I was wondering if it is possible to get the date that a specific table in a database was created. My employer would like to add this feature and I have been unable to find a solution with Google.

我想知道是否有可能获得数据库中特定表的创建日期。我的雇主想添加此功能,但我一直无法通过 Google 找到解决方案。

I figured SO is the next best place to look.

我认为 SO 是下一个最好的地方。

回答by Daniel Li

You would query the information_schemafor the create_timeof the table.

您将查询information_schemacreate_time表。

For instance:

例如:

SELECT create_time FROM INFORMATION_SCHEMA.TABLES
  WHERE table_schema = 'your_schema'
  AND table_name = 'your_table'

Reference: http://dev.mysql.com/doc/refman/5.0/en/tables-table.html

参考http: //dev.mysql.com/doc/refman/5.0/en/tables-table.html

回答by Dr. Nitin Reddy Katkam

I know that this is an old question but I wanted to suggest an alternative approach that doesn't involve having to directly query the information_schema tables for anyone who looks up this question later for reference.

我知道这是一个老问题,但我想建议一种替代方法,该方法不需要为以后查找此问题以供参考的任何人直接查询 information_schema 表。

You can obtain information about the tables using "show table status". It gives you plenty of information including the storage engine being used, the create time, the update time, and the number of rows.

您可以使用“show table status”获取有关表的信息。它为您提供了大量信息,包括正在使用的存储引擎、创建时间、更新时间和行数。

You can filter the results based on the name of the table, as follows:

可以根据表名过滤结果,如下:

show table status where name = 'your-table-name'