在sqlite3中,选择能否在插入事务中成功? [英] in sqlite3, can a select succeed within a transaction of insert?

查看:89
本文介绍了在sqlite3中,选择能否在插入事务中成功?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始一个事务,即将几条记录插入到一​​个表中。可以在提交事务之前从数据库中选择最新插入的记录吗?

I begin a transaction, which is to insert several records into a table. Can I select the latest inserted record out of the database before the transaction commit?

推荐答案

是。

在交易中,您的应用程序可以看到所有内容。

Inside a transaction, your application sees everything.

但是,没有其他交易看到更改的任何部分。

No other transaction, however, sees any part of the change.

交易的重点是使语句序列看起来像是对数据库的一次原子更改。

The point of a transaction is to make a sequence of statements appear to be one atomic change to the database.

如果您提交,则交易中的所有语句都将完成,其他所有人都可以看到影响。

If you commit, all statements in the transaction are finalized, and everyone else can see the effects.

如果回滚,则事务中的任何语句都不会完成,数据库也不会发生任何更改。

If you rollback, no statement in the transaction is finalized, and no change occurs to the database.

并非所有语句都可以成为事务的一部分,BTW。 DDL(例如Create和Drop)将结束任何先前的事务。

Not all statements can be part of a transaction, BTW. DDL (Create and Drop, for example) will end any previous transaction.

这篇关于在sqlite3中,选择能否在插入事务中成功?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆