MySQL 触发循环

发布于 2024-08-31 18:48:22 字数 219 浏览 3 评论 0原文

我正在经历整理别人代码的痛苦堆积过程。

因此,我决定重新创建一个新数据库与旧数据库并存,然后使用触发器在两个表之间传输数据。

现在我有一个问题,它循环 IE

每个表上的触发器来更新另一个表。一旦一个更新,它应该更新另一个,但由于两个表都有触发器,它只会循环,这会导致问题。

他们有办法阻止这种情况发生吗?

希望这是有道理的,并希望您能提供建议。

I am going through the pain stacking process of sorting out someone else code.

So I am decided to recreate a new database to sit alongside the old one then to use triggers to transfer data between both tables.

Now I have an issue with a it looping IE

A trigger on each table to update the other. Once one updates it should update the other but as both tables have triggers it just will loop which will cause an issue.

Is their a way to stop this from happening ?

Hope this makes sense and hope you can advise.

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

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

发布评论

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

评论(1

场罚期间 2024-09-07 18:48:22

您应该在一个数据库中创建条目并使用触发器将该数据复制到第二个数据库。话虽如此,您使用检查数据是否存在并退出触发器。基本上,如果记录存在,则不执行任何操作。这个网站有一个很好的教程:

http://www.databasedesign-resource.com/mysql -triggers.html

您可能还想阅读 mySQL 手册中的触发器:

http://dev.mysql.com/doc/refman/5.0/en/triggers.hthl

You should be making entries in one db and using the trigger to copy that data to the second db. Having said that you use a check for the existence of the data and exit the trigger. Basically an if record exist do nothing. This site has a good tutorial:

http://www.databasedesign-resource.com/mysql-triggers.html

You may aloso want to read up on triggers in the mySQL manual:

http://dev.mysql.com/doc/refman/5.0/en/triggers.hthl

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