根据我的要求在sql中创建触发器

发布于 2024-09-29 03:49:27 字数 442 浏览 0 评论 0原文

以下是我的表,

table1
=========
id          col1            col2
=====================================
1          firstrow          firstrow2
2          secrow            secrow2

table2
===========
id         orignalvalue          updatedvalue
===============================================
2           secrow2               Secondrow2

当我的 table1 值更新时,我需要一个触发器,在 table2 中创建一行,其中包含 id、原始值和更新值...这就像一个 LOG 表。

The following is my tables

table1
=========
id          col1            col2
=====================================
1          firstrow          firstrow2
2          secrow            secrow2

table2
===========
id         orignalvalue          updatedvalue
===============================================
2           secrow2               Secondrow2

i need a trigger when my table1 values are updated,a row to be created in the table2 with the id,originalvalue and the updatevalue in it...This is just like an LOG table.

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

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

发布评论

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

评论(1

故笙诉离歌 2024-10-06 03:49:27

您基本上是在查看 AFTER UPDATE 触发器,将 OLDNEW 值插入到 table2 中,但并不知道您正在使用哪个数据库,语法可能有所不同,或者甚至可能不可能。

You're basically looking at an AFTER UPDATE trigger to insert the OLD and NEW values into table2 but without knowing which DB you're using, the syntax may differ or it might not even be possible.

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