![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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