I have 2 tables, an active table and an inactive table. I want to move rows from the active to the inactive table. My first thought was
insert into inactive select * from active where ... delete from active active where ...
However about .42 seconds later I noticed this will drop/duplicate rows if updates alter what the where clause selects.
In this case, I can easily prevent that but what should I do in cases where I can’t?
edit: From the answers it look like there isn’t an easy/trivial way to do this. I’m really surprised by this. I would think that there would be some substantial benefits to having it.
Status flags are your friend.
If you do this with Autocommit off, it will seize locks all over the place.
You can COMMIT after each step, if you want to do a little less locking.