- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
MySQL query to get the last created table name (most recent)?
You can use the concept INFORMATION_SCHEMA.TABLES for this. Let us first create a table. This would be our most recent table −
mysql> create table DemoTable1323 -> ( -> FirstName varchar(10) -> ); Query OK, 0 rows affected (0.43 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1323 values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1323 values('David'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1323 values('Bob'); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable1323;
This will produce the following output:
+-----------+ | FirstName | +-----------+ | Chris | | David | | Bob | +-----------+ 3 rows in set (0.00 sec)
Following is the query to get the last created table name −
mysql> select table_name,create_time AS `Time` from information_schema.tables where table_schema = 'web' order by create_time desc limit 1;
This will produce the following output:
+---------------+---------------------+ | TABLE_NAME | Time | +---------------+---------------------+ | demotable1323 | 2019-09-18 22:03:24 | +---------------+---------------------+ 1 row in set (0.02 sec)
- Related Articles
- MongoDB query to select 10 most recent documents without changing order?
- How to Get the most recent file in a directory in Linux?
- Display record with most recent time in MySQL
- How to get the color of the most recent plotted line in Python?
- How to get the creation time of recently created table in MySQL?
- Get Last Entry in a MySQL table?
- MySQL query to fetch date more recent than 14 days?
- How can we find the most recent and most oldest date from a table with the help of MySQL MAX() and MIN() functions?
- MySQL query to get substrings (only the last three characters) from strings?
- Get the second last row of a table in MySQL?
- How to get the second last record from a table in MySQL?
- MySQL query to display columns name first name, last name as full name in a single column?
- How to get the first and last record of the table in MySQL?
- Query MySQL table and fetch rows posted before the last 3 days?
- MySQL query to get a substring from a string except the last three characters?

Advertisements