MySQL - 数据库中*数据*的更改跟踪?
我遇到一种情况,我需要跟踪 MySQL 数据库中数据的所有更改。
例如,我们在“客户”表中有一个字段,其中包含一个评级,表明与该客户开展业务的风险有多大。每当这个字段发生变化时,我都需要将其记录下来,这样我们就可以回过头来说“原来是 3,现在是 8”,例如。 MySQL 中是否有任何自动化方法来处理此问题,或者我是否必须将大量更改跟踪逻辑写入应用程序本身?
I have a situation where I need to keep track of all changes to the data in a MySQL database.
For example, we have a field in the "customers" table which will contain a rating that indicates how risky it is to do business with that customer. Whenever this field is changed, I need to have it logged so we can go back and say "well they were a 3 and now they are an 8," for example. Is there any automated way to handle this in MySQL or am I just going have to write tons of change tracking logic into the application itself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是触发器在 MySQL 内部设计的类型,假设您使用的是 5+ 版本的 MySQL。
This is the type of thing that triggers are designed for inside of MySQL assuming you're using a 5+ version of MySQL.