I have a partitioning script that essentially does the following:
1. drop table if exists a_old
2. rename table a to a_old
3. create table a like a_old
4. alter table a drop primary key, add primary key
5. alter table a partition by...
6. insert into a (select * from a_old)
7. drop table a_old
The problem is that for step 2, I need to specify a rollback. Basically, if the server goes down after step 1 and 2 , I want to specify arollback .
Now it can't be:
rename table a_old to a (because I am dropping a_old at the end)
But ideally I want
if a_old exists, please rename a_old to a, else do nothing during rollback.
But I could not get anything to do this. Would appreciate some help!