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

时间:2021-10-05 23:58:39

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?

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

3 个解决方案

#1


2  

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/

我不确定您是否使用JDBC 3.0。如果您是,那么它支持保存点。 http://www.ibm.com/developerworks/java/library/j-jdbcnew/

#2


1  

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


0  

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. 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.

阅读在线文档,保存点和事务的AFAIK基本上是相同的,区别在于写入保存点的事务堆栈。您可以打开一定数量的保存点(记住堆栈排序),并在检查完确定后,进行事务提交。我不知道这是否会对你有所帮助。

#1


2  

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/

我不确定您是否使用JDBC 3.0。如果您是,那么它支持保存点。 http://www.ibm.com/developerworks/java/library/j-jdbcnew/

#2


1  

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


0  

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. 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.

阅读在线文档,保存点和事务的AFAIK基本上是相同的,区别在于写入保存点的事务堆栈。您可以打开一定数量的保存点(记住堆栈排序),并在检查完确定后,进行事务提交。我不知道这是否会对你有所帮助。