Can I rollback a SQLite transaction after it has been committed?

隐身守侯 提交于 2019-12-23 15:40:11

问题


Is there a way in SQLite to essentially undo the latest transaction after it has been committed?

I'd like to revert the database to the state before a transaction or savepoint. I've looked at the rollback command, but it looks like it is limited to rolling back a pending transaction.

Edit Could I create a savepoint named "Undo" and wait to release it before starting the next action, or rollback if I need to undo it?


回答1:


I am not sure if you are using JDBC 3.0. If you are then it supports savepoints. http://www.ibm.com/developerworks/java/library/j-jdbcnew/




回答2:


Other than doing an on-line backup prior to your transaction, I don't know that it supports a "time machine" to go backwards in time.

Can't you put some application logic in place to record enough to undo the applied operation in audit trail table(s)?




回答3:


I'm not an SQLite expert, but as far as I've tried, it's only possible to make savepoints inside transactions, but not the opposite.

And AFAIK, reading the online documentation, savepoints and transactions are essencially the same, the difference is the transaction stack in which the savepoints are written. You could open a certain number of savepoints (remembering the stack ordering) and, after checking it'a OK, make a transaction commit. I don't know if this will help you.



来源:https://stackoverflow.com/questions/4070306/can-i-rollback-a-sqlite-transaction-after-it-has-been-committed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!