MySQL 数据库变更日志(如何制作一个?)
嘿我想知道是否可以维护 mysql 数据库的变更日志?我有 6 个表,想知道是否有一种有效的方法来为每个表制作影子表来表示所做的更改。我不确定我是否解释得很好,但这是一个例子:
操作:表“users”user=john,密码='password' 后台操作:表“users_shadow”user=john,密码='password'action=added
然后,如果密码更改。表 user 仅更改该行的密码,但后台 talbe 中的操作在新行“users_shadow” user=john 中显示,密码='password1' action=passwordmodified”
所以现在我在影子表中有 2 行用户 john ,其中我可以查看对该表所做的所有修改。
抱歉,有点难以解释,但这可能吗?
Hey I was wondering if it was possible to maintain a changelog for a mysql database? I have 6 tables and was wondering if there was an efficient way to make shadow tables for each one that will denote the changes made. Im not sure if I am explaining it well but heres an example:
Action: Table "users" user=john with password = 'password'
Action in background: Table "users_shadow" user=john with password = 'password' action=added
Then if the password changes. The table user only changes the password for that row but the action in background talbe says in new row "users_shadow" user=john with password='password1' action=passwordmodified"
So now I have 2 rows with user john in the shadow table where I can look and see all modifications made to that table.
Sorry, kinda hard to explain, but is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这绝对是可能的——只需要代码。也就是说,根据您想要的目的, 二进制日志可能已经满足您的需求。在编写自己的日志记录代码之前,请先阅读它们。
This is definitely possible -- it just requires code. That said, depending on what you want this for, the binary logs may already meet your needs. Read up on them before you write your own logging code.