简体   繁体   English

PHP / MYSQL-备份第二次更改的mysql数据

[英]PHP/MYSQL - Backing up mysql data that changes by the second

I have a mysql table (A) that's taking in hundreds to thousands of inserts per second. 我有一个mysql表(A),每秒接收数百到数千个插入。 Every 15 minutes I'd like to move all that data to table (B) and delete all the data from (A) without interrupting/missing the new rows going in. 我想每15分钟将所有数据移到表(B)并从(A)中删除所有数据,而不会中断/丢失进入的新行。

Suggestions? 建议? Tips? 提示?

You could copy the rows, and then delete only those rows that were copied: 您可以复制行,然后仅删除已复制的行:

insert into B (keycol, col1, col2)
select keycol, col1, col2 from A

Then delete rows in A that are already in B: 然后删除A中已经在B中的行:

delete A
from A
inner join B on A.key = B.key

Alternative syntax: 替代语法:

delete from A
where exists (
    select * from B where A.key = B.key
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM