Watching a table for change in MySQL?

Another similar approach would be to add

add column Last_Modified TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP 

to each table and preface your select queries to compare the last request date/time with the max(Last_Modified).

Databases are typically pull sources and not push so you'll still need to programmatically probe for changes no matter what.


In MySQL there's no best way than to poll (you create a specific table to simplify the polling though), in other databases you can have triggers that have impact outside the database. In MySQL triggers can only do stuff inside the database itself (for instance, populating the helper table).

Tags:

Mysql

Database