Home > Database > Mysql Tutorial > How to know when a MySQL table was last updated?

How to know when a MySQL table was last updated?

王林
Release: 2023-08-27 17:37:09
forward
1707 people have browsed it

如何知道 MySQL 表的最后更新时间?

We can know this by using the column name "UPDATED_TIME" of information_schema.tables with a WHERE clause.

Let's first create a table for our example.

mysql> create table MyISAMTableDemo
   -> (
   -> id int
   -> );
Query OK, 0 rows affected (0.56 sec)
Copy after login

Inserting some records into the table.

mysql> insert into MyISAMTableDemo values(1);
Query OK, 1 row affected (0.72 sec)

mysql> insert into MyISAMTableDemo values(2);
Query OK, 1 row affected (0.16 sec)
Copy after login

Understand the syntax of last updated time.

SELECT UPDATE_TIME
FROM   information_schema.tables
WHERE  TABLE_SCHEMA = 'yourDatabaseName'
AND TABLE_NAME = 'yourTableName';
Copy after login

Let's implement the following query to get the last update time.

mysql> SELECT UPDATE_TIME
   -> FROM   information_schema.tables
   -> WHERE  TABLE_SCHEMA = 'business'
   ->  AND TABLE_NAME = 'MyISAMTableDemo';
Copy after login

The following is the output.

+---------------------+
| UPDATE_TIME         |
+---------------------+
| 2018-11-01 19:00:02 |
+---------------------+
1 row in set (0.08 sec)
Copy after login

The above is the detailed content of How to know when a MySQL table was last updated?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template