Find out the creation date of a MySQL table


Sometimes it’s useful to know when a certain database table was created. For those cases the following statement can be used:

SELECT create_time
FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'DB_NAME'

In case you are interested in the creation time of a particular table, just add the appropiate WHERE-clause:

SELECT create_time
FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'DB_NAME'
AND table_name = 'TABLE_NAME'

+---------------------+
| create_time         |
+---------------------+
| 2011-12-22 12:32:34 |
+---------------------+
1 row in set (0.00 sec)

Update: As pointed out below in the comments, it is not possible to know the creation date of a database without access to the directory structure of MySQL.

Advertisements

9 thoughts on “Find out the creation date of a MySQL table

  1. Thanks a lot. I recommend this page very much because the query examples help / show how to find out when a MySQL database was created.

  2. This is good for tables, but what about the creation time for the database (as the title of your posting says)

  3. Hi,
    Maybe I did not get what you were trying to achieve, but … you started with

    > Sometimes it’s useful to know when a certain database was created

    then proceeded to explain how to see when a *table* was created instead. It would be nice to see the *database* creation date instead, as the title of your page suggests.

  4. So would be good to change the title of this page as other suggest. Since it will only show you table creation dates. False hope 😦

  5. There is noway you can get the creation date of the schema. The information_schema.schemata table does not have created time.

  6. Thanks for sharing this code, but as the other comments say, it is not helpful to find the database creation time. As far as I have understood, this task is not possible unless one has access to the database directory on the server. In that case, one could look at creation date of the single files (ex. db.opt).

  7. This is an article I wrote a long time ago. Because of the multiple comments I received I updated it’s title/contents to be more correct. Thank you for your feedback!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s