简体   繁体   English

提交后可以回滚SQLite事务吗?

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

Is there a way in SQLite to essentially undo the latest transaction after it has been committed? 有没有一种方法可以在SQLite提交后基本上撤消最新的事务?

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. 我查看了rollback命令,但看起来它仅限于回滚挂起的事务。

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? 编辑我是否可以创建名为“撤消”的保存点并等待在开始下一个操作之前释放它,或者如果我需要撤消它则回滚?

I am not sure if you are using JDBC 3.0. 我不确定您是否使用JDBC 3.0。 If you are then it supports savepoints. 如果你那么它支持保存点。 http://www.ibm.com/developerworks/java/library/j-jdbcnew/ http://www.ibm.com/developerworks/java/library/j-jdbcnew/

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)? 难道你不能放置一些应用程序逻辑来记录足以撤消审计跟踪表中的应用操作吗?

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. 我不是SQLite专家,但据我所知,它只能在事务中创建保存点,而不是相反。

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. 阅读在线文档,保存点和事务的AFAIK本质上是相同的,区别在于写入保存点的事务堆栈。 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. 我不知道这对你有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM