 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the creation time of recently created table in MySQL?
Following is the syntax −
select table_name, create_time from information_schema.TABLES where table_schema = 'yourDataBaseName' order by CREATE_TIME desc limit 1;
Let us create the first table (Time: 2019-06-10 16:40:51) −
mysql> create table DemoTable1 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int -> ); Query OK, 0 rows affected (0.59 sec)
We will now create the second table, let’s say after 5 minutes −
mysql> create table DemoTable2 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int -> ); Query OK, 0 rows affected (0.59 sec)
Now we will get the time of the latest created table in MySQL (i.e. DemoTable2 as it is the recently created table) −
mysql> select table_name, create_time -> from information_schema.TABLES -> where table_schema = 'web' -> order by CREATE_TIME desc -> limit 1;
Output
+--------------+---------------------+ | TABLE_NAME | CREATE_TIME | +--------------+---------------------+ | demotable2 | 2019-06-10 16:45:51 | +--------------+---------------------+ 1 row in set (0.01 sec)
Advertisements
 