For example, the data is like this:
例如,数据是这样的:
[id][name]
[ID] [名]
at 10:00, the data is like this:
在10:00,数据是这样的:
[1][John]
[1] [约翰]
at 11:00, the user edit the data change to this:
在11:00,用户编辑数据更改为:
[1][Johnson]
[1] [约翰逊]
So, user use the alter command to change the data, but it is possible for the database query back the data on 10:00 in MySQL? Thanks.
因此,用户使用alter命令来更改数据,但是数据库查询可能会在10月10日恢复数据吗?谢谢。
2 个解决方案
#1
2
What you are talking about is versioning. Having time stamp and version number would help but storing multiple records in same table with same id would cause a decrease in data integrity - what about a trigger on the table and insert into some form of audit table?
你在说什么是版本控制。拥有时间戳和版本号会有所帮助,但是在具有相同id的同一个表中存储多个记录会导致数据完整性降低 - 如何在表上触发并插入某种形式的审计表?
#2
0
In general you have two options:
一般来说,您有两种选择:
-
Add a colum version with a timestamp and expand the primary key to your currient PK and the version. To grep the data you just need to select the least version e.g. with max. Or add another colum with a bit value for the newest version. This should be faster to select.
添加带有时间戳的colum版本,并将主键扩展到currient PK和版本。要格式化数据,您只需选择最少版本,例如最大或者为最新版本添加另一个具有位值的列。这应该更快选择。
-
Create a table with historical values. To implement this you need to add a trigger to the orginal table on update and copy the old value in your history table. So you can see all changes.
创建一个包含历史值的表。要实现此功能,您需要在更新时向原始表添加触发器,并复制历史记录表中的旧值。所以你可以看到所有的变化。
#1
2
What you are talking about is versioning. Having time stamp and version number would help but storing multiple records in same table with same id would cause a decrease in data integrity - what about a trigger on the table and insert into some form of audit table?
你在说什么是版本控制。拥有时间戳和版本号会有所帮助,但是在具有相同id的同一个表中存储多个记录会导致数据完整性降低 - 如何在表上触发并插入某种形式的审计表?
#2
0
In general you have two options:
一般来说,您有两种选择:
-
Add a colum version with a timestamp and expand the primary key to your currient PK and the version. To grep the data you just need to select the least version e.g. with max. Or add another colum with a bit value for the newest version. This should be faster to select.
添加带有时间戳的colum版本,并将主键扩展到currient PK和版本。要格式化数据,您只需选择最少版本,例如最大或者为最新版本添加另一个具有位值的列。这应该更快选择。
-
Create a table with historical values. To implement this you need to add a trigger to the orginal table on update and copy the old value in your history table. So you can see all changes.
创建一个包含历史值的表。要实现此功能,您需要在更新时向原始表添加触发器,并复制历史记录表中的旧值。所以你可以看到所有的变化。