如何比较表中的数据(操作前后)?

发布于 2024-12-04 14:55:13 字数 35 浏览 1 评论 0原文

有没有免费的工具或方法可以了解数据库表中发生了什么变化?

Is there any free tool or a way to get to know what has changed in database's table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

醉南桥 2024-12-11 14:55:16

我过去曾非常成功地使用 Toad for MySQL(对于架构和数据)。我发现它也与 Oracle 兼容。

I have used Toad for MySQL very successfully in times past (for both the Schema and Data). I see it is also compatible with Oracle.

迷迭香的记忆 2024-12-11 14:55:16

试试liquibase,它提供了数据库的版本控制机制。

Try liquibase, it provides the version control mechanism for database.

沩ん囻菔务 2024-12-11 14:55:15

您可以在更新之前获取副本

CREATE TABLE t2 AS SELECT * FROM t1

运行更新

然后显示差异

使用它来显示更新:

SELECT * FROM t1
MINUS
SELECT * FROM t2

使用它来显示删除:

SELECT * FROM t2
WHERE NOT EXISTS(SELECT 1 FROM t1 WHERE t1.primary_key = t2.primary_key)

最后使用它来检查记录总数是否相同

SELECT count(*) FROM t1

SELECT count(*) FROM t2

注意:如果有其他会话更新 t1发现你的更新可能很棘手。

You could take a copy before the update

CREATE TABLE t2 AS SELECT * FROM t1

Run your update

Then to show the differences

use this to show updates:

SELECT * FROM t1
MINUS
SELECT * FROM t2

use this to show the deletes:

SELECT * FROM t2
WHERE NOT EXISTS(SELECT 1 FROM t1 WHERE t1.primary_key = t2.primary_key)

and finally this to check the total number of records are identical

SELECT count(*) FROM t1

SELECT count(*) FROM t2

Note: If there are other sessions updating t1 it could be tricky spotting your updates.

我一直都在从未离去 2024-12-11 14:55:15

触发器确实应该避免,但是......

如果您处于非生产环境中,您可以设置触发器来执行到新表的日志记录。您需要 5 个类似这样的字段:

LogTime DateTime;
Table   Varchar2(50); -- Table Name
Action  Char;         -- Insert, Update or Delete
OldRec  Blob;         -- Concatenate all your field Values
NewRec  Blob;         -- Ditto

这样做的好处是您可以将给定时间跨度的所有 OldRecs 和 NewRecs 选择到文本文件中。比较工具将帮助您突出显示您的更改。

有什么帮助吗?

Triggers really should be avoided but ...

If you are in a non-production environment you can set up a trigger to perform logging to a new table. You need 5 fields something like this:

LogTime DateTime;
Table   Varchar2(50); -- Table Name
Action  Char;         -- Insert, Update or Delete
OldRec  Blob;         -- Concatenate all your field Values
NewRec  Blob;         -- Ditto

The Beauty of this is that you can select all the OldRecs and NewRecs for a given timespan into text files. A comparison tool will assist by highlighting your changes for you.

Any help ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文