- 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
How do you get the last access (and/or write) time of a MySQL database?
To get the last access time, try the following syntax −
SELECT update_time FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'yourDatabaseName' AND table_name = 'yourTableName'
The above syntax gives the last access information about MyISAM engine type.
Here, our database is ‘business’ and we will be using the table with the name ‘twoprimarykeytabledemo'.
To get last access time of MySQL database, use the following query.
Case 1 − The query is as follows −
mysql> SELECT update_time -> FROM INFORMATION_SCHEMA.TABLES -> WHERE table_schema = 'business' -> AND table_name = 'twoprimarykeytabledemo';
The output is as follows −
+---------------------+ | UPDATE_TIME | +---------------------+ | 2018-11-21 16:51:50 | +---------------------+ 1 row in set (0.24 sec)
Case 2 −
mysql> SELECT update_time -> FROM INFORMATION_SCHEMA.TABLES -> WHERE table_schema = 'business' -> AND table_name = 'currenttimezone';
The output is as follows −
+---------------------+ | UPDATE_TIME | +---------------------+ | 2018-10-29 17:20:18 | +---------------------+ 1 row in set (0.20 sec)
Case 3 − If your table engine type is InnoDB, then you will get NULL.
The query is as follows −
mysql> SELECT update_time -> FROM INFORMATION_SCHEMA.TABLES -> WHERE table_schema = 'business' -> AND table_name = 'zerofilldemo';
The following is the output −
+-------------+ | UPDATE_TIME | +-------------+ | NULL | +-------------+ 1 row in set (0.09 sec)
- Related Articles
- Get the date/time of the last change to a MySQL database?
- C# Program to get the last access time of a file
- C# Program to get the last write time of a file
- What do you mean by database view and how do MySQL views work?
- How do I get the current time zone of MySQL?
- How to check the Date and time of Access (last modified) of a File using Java?
- Get the last record from a table in MySQL database with Java?
- How can we write PHP script to get the list of MySQL database?
- How to check file last access time using Python?
- How do you select from MySQL where last value in a string = x?
- How do you OR two MySQL LIKE statements?
- How do I access SQLite database instance on iPhone
- Access last inserted row in MySQL?
- What do you mean by default MySQL database for the user?
- How do I get the id after INSERT into MySQL database in Python?

Advertisements