查找数据库中任何表的最后更新/插入/删除的实用方法?

发布于 2025-01-21 08:26:43 字数 918 浏览 0 评论 0 原文

OS:W10。

这个问题特别是关于Mariadb的可能性,特别是版本“ VER 15.1 Distrib 10.7.3-Mariadb”。

编辑
来自 so so soite 我发现从10.3.4 Mariadb中确实实现了“时间表”。尚不清楚这是否提供解决方案。

我想为数据库实现一种“最后修改”时间戳的方式,即,无论表现如何发生,它都显示了最后一个插入或删除或更新的时间。我发现 this ,看起来很有希望...但是随后在那里进行了有关Innodb和 Information_schema.update_time.update_time的一些评论。 使我做了一个实验。

与某些地方在InnoDB表中始终是 null 始终是在某些地方所主张的内容相反,我所拥有的似乎并非如此。不幸的是,每当服务器启动 dim 似乎是正确的时,有关此值的评论。

在其他地方,我读到的是,玛丽亚德(Mariadb)的新版本实际上是在实施了某种变化的历史上,从而脱离了Vanilla Mysql。

我目前正在研究这样的假设,即我必须为每个表实现 on_upate 触发器,然后获取每个表的值并找到最新的值,以确定“最后修改“整个数据库的时间。

此版本的MariadB还有其他可能性吗?

编辑
实际上,我提供了一个适合我用例

OS: W10.

This question is specifically about what's possible in MariaDB, specially version "Ver 15.1 Distrib 10.7.3-MariaDB".

Edit
From another SO site I have found that from 10.3.4 MariaDB does in fact implement "temporal tables". Not clear yet whether this provides a solution.

I want to implement a way of having a "last modified" timestamp for a database, i.e. which shows when the last INSERT or DELETE or UPDATE occurred, regardless of the table where it happened. I found this, which looked promising... but then some comments there about InnoDB and information_schema.tables.update_time led me to do an experiment.

Contrary to what is asserted in some places about update_time always being NULL in InnoDB tables, this does not seem to be the case with what I've got. Unfortunately, the comment there about this value being set to NULL whenever the server starts does appear to be true.

Elsewhere I read that newer versions of MariaDB, pulling away from vanilla MySQL, do in fact implement some sort of history of changes.

I'm currently working on the assumption that I shall have to implement an ON_UPATE trigger for every table, and then get values for each of these and find the most recent, in order to determine the "last modified" time for the whole database.

Is there any other possibility with this version of MariaDB?

Edit
In fact I have provided an answer which works for my use case on another SO site (when I added this link as an answer here that answer was then deleted by a mod - but in reality some might find it useful).

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

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

发布评论

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

评论(1

山有枢 2025-01-28 08:26:43

只需制作一个具有所有表名和时间戳列的表即可。
然后,在 on_upate 触发器上,只需更新tableName记录。

这样,您就有具有时间戳的中央桌子,不要做任何黑客。

保持简单。

使用 this

just make a table that has all the table names and a timestamp column.
then on the ON_UPATE trigger, just update the tablename record.

this way, you have central table which has the timestamps, dont do any hacks.

keep it simple.

use this

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