

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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 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 Questions & Answers
- 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 to check the Date and time of Access (last modified) of a File using Java?
- How do I get the current time zone of MySQL?
- How do you OR two MySQL LIKE statements?
- How can we write PHP script to get the list of MySQL database?
- Get the last record from a table in MySQL database with Java?
- 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 get the purest form of Cocaine?
- How do you access jagged arrays in C#?
- What do you mean by default MySQL database for the user?
- How do you access the matched groups in a JavaScript regular expression?
Advertisements