Is there a way we could create a trigger
to automatically calculate how many times a certain record have been targeted with a UPDATE
command?
是否有一种方法可以创建一个触发器来自动计算某个记录被UPDATEcommand锁定的次数?
Does anyone ever achieved this? It could be useful for auditing. I personally use a table to manually add records every time my applications create or edit a record. But I do that like:
有人做到过吗?它可能对审计有用。每次我的应用程序创建或编辑记录时,我都会使用一个表手工添加记录。但我是这样做的:
try
Table1.Post;
finally
auditTable.Insert;
{...}
auditTable.post;
end;
The usability for this would come handy if we created a trigger to annotate on another table the user who did the changes, the moment, the IP and other information. I found only one example in web and it's here: MySQL Trigger after update only if row has changed
如果我们创建一个触发器来在另一个表上注释做了更改的用户、即时、IP和其他信息,那么可用性就会变得非常有用。我在web上只找到了一个例子,它在这里:只有当行发生更改时,才会更新后触发MySQL
By the rules, I would like to ask How could we trigger every table on a database except the audit page in order to register insertions and updates made on every other table?
根据规则,我想问的是,如何触发数据库上的每个表(除了审计页),以便注册在每个其他表上进行的插入和更新?
1 个解决方案
#1
2
You could use triggers as already suggested. You could also add an extra field to each table and update the count on each update. You could write the sql statement out to a text file....
您可以像前面提到的那样使用触发器。您还可以为每个表添加一个额外的字段,并在每次更新时更新计数。您可以编写sql语句到一个文本文件....
#1
2
You could use triggers as already suggested. You could also add an extra field to each table and update the count on each update. You could write the sql statement out to a text file....
您可以像前面提到的那样使用触发器。您还可以为每个表添加一个额外的字段,并在每次更新时更新计数。您可以编写sql语句到一个文本文件....