Abdennour TOUMI
Abdennour TOUMI

Reputation: 93343

How to query the date of adding db to MySQL DBMS

MySQL provides many cmds(queries) such as :

>SHOW DATABASE; 
>use <db> ; 
>
>select * From <t>;
.....

Is there a query that allow us to know what is the exactly date of adding database in DBMS . For example:

>SHOW datecreation <db>;

Does mySQL support this feature? If no , What's the DBMS who can support

Upvotes: 0

Views: 52

Answers (2)

as HAL9000 said, in current versions you can query INFORMATION_SCHEMA.TABLES for created date. For older versions that dont have INFORMATION_SCHEMA you can check the create date of the folder of your database in MySQL data dir.

By default it is in

%ProgramData%\MySQL\MySQL Server <Your Version>\Data\<Your Database> for windows,

and I believe

/var/lib/mysql/<your database> on *NIX.

Upvotes: 1

BlitZ
BlitZ

Reputation: 12168

As for MySQL, you may try to dig some information from INFORMATION_SCHEMA database:

SELECT * FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `table_schema` = 'database-name';
-- information about tables in database

The oldest table there might give you suggestions when database was created.

As of databases, you may try query SCHEMATA table:

SELECT * FROM `INFORMATION_SCHEMA`.`SCHEMATA`; -- information about databases

However it is not containing actual database creation time.

Upvotes: 0

Related Questions