Ok here’s the scenario:
we have 1 database that has a table we’d like to keep as small as possible. we need to replicate the data in it based on the primary key to another table.
the catch is after we’re finished with the rows (probably a daily process) we will delete the rows from the original database, but keep the data in the new table.
example
10 rows in table A -> 10 rows replicated to table B – total 10 rows in table B
end of day cron deletes all from table A
10 rows in table A -> 10 rows replicated to table B – total 20 rows in table B
my question: is there a way to replicate from A to B without A sending deletes ?
If you are deleting rows, I am assuming they are not here in table A, so what would you be sending them to table B?
If by deleting you mean ‘marked as deleted’, then simply filter by that condition in your
REPLACEstatement.After reading your comment, I understood your problem thusly:
If A has 10 and B has 0, at first replication B will have 10 and A will have 0 (because you will delete them).
At next replication, A will have 5 and these won’t be present in B, so you simply copy all from A to B, so B has 15 (again A will be deleted).
If however, you only want to replicate a subset of rows from A, then you need to apply that filter first (for
REPLACE).REPLACEwill do this for you – except delete the rows from you source table, which you’ll have to do manually. It will keep B updated always.