将数据从一个 MySQL 表传输到另一个表
我有一个数据库,其中有一个notice_current表和一个notices_archive表。作为用户注销过程的一部分,我想将所有相关通知从当前表移至存档。
在我的 PHP 应用程序代码中,我当前正在进行一个事务,在其中复制通知,然后如果复制中没有错误,则删除 notifications_current 表中的行。然而,我想知道 MySQL 是否有一些固有的函数或方法来简单地将通知从一个表推送到另一个表。如果是这样,就会发现这比我目前的实施更有效。
I have a database that has a notice_current table and a notices_archive table. As part of a user logout process, I want to move all of their associated notices from the current table to the archive.
In my PHP application code I am currently making a transaction where I copy the notices over, and then delete the rows in the notices_current table if there were no errors in the copying. However, I am wondering if MySQL has some innate function or method for simply pushing notices from one table to another. If so, it would see that this would be more effective than my current implementation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有一个内置函数可以实现此目的,但如果您当前正在迭代所有行,那么这样的方法可能会更有效:
There's not a single built-in function for this, but if you're currently iterating over all of the rows, then something like this might be a lot more efficient:
你可以使用 phpmyadmin 工具来做到这一点。
转到 phpmy admin 然后选择您的源数据库并单击操作选项卡并选择复制并设置参数,然后让 phpmyadmin 完成他的工作:D
u can use phpmyadmin tools to do this.
goto phpmy admin then select your source db and click on operation tab and select copy and set the parameters then let phpmyadmin to do his job :D