以编程方式检测对表行的更改

时间:2022-09-20 09:49:07

Is there a way to programmatically detect if a certain row has changed in a database table?

有没有办法以编程方式检测数据库表中某个行是否已更改?

I want my application to know the instant that a table row has been modified. I can always do a standard query update loop, yet I was wondering if there was a better easier way that I am overlooking.

我希望我的应用程序知道表行被修改的瞬间。我总是可以做一个标准的查询更新循环,但我想知道是否有一个更容易让我忽略的方式。

1 个解决方案

#1


5  

The only mechanism currently supported by MySQL is a trigger. You can set a trigger to happen when an update occurs, and use that trigger to do something to notify your application using sys_exec() or similar.

MySQL目前支持的唯一机制是触发器。您可以设置在发生更新时触发,并使用该触发器执行某些操作以使用sys_exec()或类似方法通知您的应用程序。

Note that the update trigger only catches when an update is made through SQL, not otherwise (such as APIs, NDB, for example).

请注意,更新触发器仅在通过SQL进行更新时捕获,而不是(例如,API,NDB等)。

#1


5  

The only mechanism currently supported by MySQL is a trigger. You can set a trigger to happen when an update occurs, and use that trigger to do something to notify your application using sys_exec() or similar.

MySQL目前支持的唯一机制是触发器。您可以设置在发生更新时触发,并使用该触发器执行某些操作以使用sys_exec()或类似方法通知您的应用程序。

Note that the update trigger only catches when an update is made through SQL, not otherwise (such as APIs, NDB, for example).

请注意,更新触发器仅在通过SQL进行更新时捕获,而不是(例如,API,NDB等)。