I need a script that can reverse sql queries like insert/create/add column ...
exemple :
input : INSERT INTO myTable VALUES (1, 1);
output : DELETE FROM myTable WHERE id=1;
I need a script that can reverse sql queries like insert/create/add column ...
exemple :
input : INSERT INTO myTable VALUES (1, 1);
output : DELETE FROM myTable WHERE id=1;
If you want to "reverse" operations, then use transactions.
This allows you to have a block of code that modifies the database. Then, if you decide that you don't want to keep all the changes -- say if an error occurs -- then you can ROLLBACK
the transaction, undoing all the changes.
Once the data has been committed to the database, SQL is persistent and remembers it. You can do other operations that have the effect of undoing the changes, but that requires appropriate application logic.