คุณสามารถดูวันที่/เวลาการเปลี่ยนแปลงล่าสุดได้ผ่าน INFORMATION_SCHEMA.TABLES ไวยากรณ์มีดังนี้:
SELECT update_time FROM information_schema.tables WHERE table_schema = 'yourDatabaseName' AND table_name = 'yourTableName';
มาสร้างตารางเพื่อทดสอบ:
mysql> create table TblUpdate ( Id int not null auto_increment primary key, Name varchar(20) ); Query OK, 0 rows affected (0.49 sec)
แทรกข้อมูล:
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)แสดงข้อมูล:
mysql> select * from TblUpdate;
ผลลัพธ์
+----+-------+ | Id | Name | +----+-------+ | 1 | John | | 2 | Carol | +----+-------+ 2 rows in set (0.00 sec)
อัปเดตตาราง:
mysql> update TblUpdate set Name = 'James' where Id=2; Query OK, 1 row affected (0.15 sec) Rows matched: 1 Changed: 1 Warnings: 0
ดูวันที่/เวลาการเปลี่ยนแปลงล่าสุด:
mysql> SELECT update_time FROM information_schema.tables WHERE table_schema = 'sample' AND table_name = 'TblUpdate';
ผลลัพธ์แสดงว่าอัปเดตเมื่อ 2019-02-09 22:49:44:
+---------------------+ | UPDATE_TIME | +---------------------+ | 2019-02-09 22:49:44 | +---------------------+ 1 row in set (0.89 sec)