- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the date/time of the last change to a MySQL database?
You can get the date/time of the last change to a MySQL database with the help of INFORMATION_SCHEMA.TABLES. The syntax is as follows −
SELECT update_time FROM information_schema.tables WHERE table_schema = 'yourDatabaseName’' AND table_name = 'yourTableName’;
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table TblUpdate -> ( -> Id int not null auto_increment primary key, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.49 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into TblUpdate(Name) values('John'); Query OK, 1 row affected (0.18 sec) mysql> insert into TblUpdate(Name) values('Carol'); Query OK, 1 row affected (0.22 sec)
Now you can display all records from the table using select statement. The query is as follows −
mysql> select *from TblUpdate;
+----+-------+ | Id | Name | +----+-------+ | 1 | John | | 2 | Carol | +----+-------+ 2 rows in set (0.00 sec)
Now you can update the table using the following query −
mysql> update TblUpdate set Name = 'James' where Id=2; Query OK, 1 row affected (0.15 sec) Rows matched: 1 Changed: 1 Warnings: 0
Therefore, we just updated our table above. Now get the date/time of the last change to a MySQL database using the following query −
mysql> SELECT update_time -> FROM information_schema.tables -> WHERE table_schema = 'sample' -> AND table_name = 'TblUpdate' -> ;
The following is the output displaying we updated the database on 2019-02-09 22:49:44 −
+---------------------+ | UPDATE_TIME | +---------------------+ | 2019-02-09 22:49:44 | +---------------------+ 1 row in set (0.89 sec)
- How do you get the last access (and/or write) time of a MySQL database?
- Get last second of a date in MySQL?
- Get the first and last date of next month in MySQL?
- C# Program to get the last write time of a file
- C# Program to get the last access time of a file
- Get the last record from a table in MySQL database with Java?
- How to get the records of the last two days from the current date in MySQL?
- How to get the size of the tables of a MySQL database?
- How can we change the default MySQL database to the given database?
- Insert current date to the database in MySQL?
- How to get the creation date of a MySQL table?
- How to compare the first date and the last date from a MySQL column with date records?
- How to check the Date and time of Access (last modified) of a File using Java?
- Get the second last row of a table in MySQL?
- Change date format in MySQL database table to d/m/y