⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lang_transaction.html

📁 SQLite is a software library that implements a self-contained, serverless, zero-configuration, trans
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>SQLite Query Language: BEGIN TRANSACTION</title><style type="text/css">body {    margin: auto;    font-family: "Verdana" "sans-serif";    padding: 8px 1%;}a { color: #45735f }a:visited { color: #734559 }.logo { position:absolute; margin:3px; }.tagline {  float:right;  text-align:right;  font-style:italic;  width:240px;  margin:12px;  margin-top:58px;}.toolbar {  font-variant: small-caps;  text-align: center;  line-height: 1.6em;  margin: 0;  padding:1px 8px;}.toolbar a { color: white; text-decoration: none; padding: 6px 12px; }.toolbar a:visited { color: white; }.toolbar a:hover { color: #80a796; background: white; }.content    { margin: 5%; }.content dt { font-weight:bold; }.content dd { margin-bottom: 25px; margin-left:20%; }.content ul { padding:0px; padding-left: 15px; margin:0px; }/* rounded corners */.se  { background: url(images/se.png) 100% 100% no-repeat #80a796}.sw  { background: url(images/sw.png) 0% 100% no-repeat }.ne  { background: url(images/ne.png) 100% 0% no-repeat }.nw  { background: url(images/nw.png) 0% 0% no-repeat }</style><meta http-equiv="content-type" content="text/html; charset=UTF-8">  </head><body><div><!-- container div to satisfy validator --><a href="index.html"><img class="logo" src="images/SQLite.gif" alt="SQLite Logo" border="0"></a><div><!-- IE hack to prevent disappearing logo--></div><div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div><table width=100% style="clear:both"><tr><td>  <div class="se"><div class="sw"><div class="ne"><div class="nw">  <div class="toolbar">    <a href="about.html">About</a>    <a href="sitemap.html">Sitemap</a>    <a href="docs.html">Documentation</a>    <a href="download.html">Download</a>    <a href="copyright.html">License</a>    <a href="news.html">News</a>    <a href="http://www.sqlite.org/cvstrac/index">Developers</a>    <a href="support.html">Support</a>  </div></div></div></div></div></td></tr></table>  <a href="lang.html"><h2>SQL As Understood By SQLite</h2></a><h3>BEGIN TRANSACTION</h3><table cellpadding="10"><tr><td align="right" valign="top"><i><font color="#ff3434">sql-statement</font></i>&nbsp;::=</td><td><b><font color="#2c2cf0">BEGIN </font></b>[<b><font color="#2c2cf0"> DEFERRED </font></b><big>|</big><b><font color="#2c2cf0"> IMMEDIATE </font></b><big>|</big><b><font color="#2c2cf0"> EXCLUSIVE </font></b>]<b><font color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">TRANSACTION </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">name</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b></td></tr></table><table cellpadding="10"><tr><td align="right" valign="top"><i><font color="#ff3434">sql-statement</font></i>&nbsp;::=</td><td><b><font color="#2c2cf0">END </font></b>[<b><font color="#2c2cf0">TRANSACTION </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">name</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b></td></tr></table><table cellpadding="10"><tr><td align="right" valign="top"><i><font color="#ff3434">sql-statement</font></i>&nbsp;::=</td><td><b><font color="#2c2cf0">COMMIT </font></b>[<b><font color="#2c2cf0">TRANSACTION </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">name</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b></td></tr></table><table cellpadding="10"><tr><td align="right" valign="top"><i><font color="#ff3434">sql-statement</font></i>&nbsp;::=</td><td><b><font color="#2c2cf0">ROLLBACK </font></b>[<b><font color="#2c2cf0">TRANSACTION </font></b>[<b><font color="#2c2cf0"></font></b><i><font color="#ff3434">name</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"></font></b></td></tr></table><p>No changes can be made to the database except within a transaction.Any command that changes the database (basically, any SQL commandother than SELECT) will automatically start a transaction ifone is not already in effect.  Automatically started transactionsare committed at the conclusion of the command.</p><p>Transactions can be started manually using the BEGINcommand.  Such transactions usually persist until the nextCOMMIT or ROLLBACK command.  But a transaction will also ROLLBACK if the database is closed or if an error occursand the ROLLBACK conflict resolution algorithm is specified.See the documentation on the <a href="lang_conflict.html">ON CONFLICT</a>clause for additional information about the ROLLBACKconflict resolution algorithm.</p><p>END TRANSACTION is an alias for COMMIT.</p><p>The optional transaction name is current ignored. SQLite does not recognize nested transactions at this time.However, future versions of SQLite may be enhanced to support nestedtransactions and the transaction name would then become significant.Application are advised not to use the transaction name in orderto avoid future compatibility problems.</p><p>Transactions can be deferred, immediate, or exclusive.  The default transaction behavior is deferred.Deferred means that no locks are acquiredon the database until the database is first accessed.  Thus with adeferred transaction, the BEGIN statement itself does nothing.  Locksare not acquired until the first read or write operation.  The first readoperation against a database creates a SHARED lock and the firstwrite operation creates a RESERVED lock.   Because the acquisition oflocks is deferred until they are needed, it is possible that anotherthread or process could create a separate transaction and write tothe database after the BEGIN on the current thread has executed.If the transaction is immediate, then RESERVED locksare acquired on all databases as soon as the BEGIN command isexecuted, without waiting for thedatabase to be used.  After a BEGIN IMMEDIATE, you are guaranteed thatno other thread or process will be able to write to the database ordo a BEGIN IMMEDIATE or BEGIN EXCLUSIVE.  Other processes can continueto read from the database, however.  An exclusive transaction causesEXCLUSIVE locks to be acquired on all databases.  After a BEGINEXCLUSIVE, you are guaranteed that no other thread or process willbe able to read or write the database until the transaction iscomplete.</p><p>A description of the meaning of SHARED, RESERVED, and EXCLUSIVE locksis available <a href="lockingv3.html">separately</a>.</p><p>The COMMIT command does not actually perform a commit until allpending SQL commands finish.  Thus if two or more SELECT statementsare in the middle of processing and a COMMIT is executed, the commitwill not actually occur until all SELECT statements finish.</p><p>An attempt to execute COMMIT might result in an SQLITE_BUSY return code.This indicates that another thread or process had a read lock on the databasethat prevented the database from being updated.  When COMMIT fails in thisway, the transaction remains active and the COMMIT can be retried laterafter the reader has had a chance to clear.</p><h3>Response To Errors Within A Transaction</h3><p>If certain kinds of errors occur within a transaction, thetransaction may or may not be rolled back automatically.  Theerrors that cause the behavior include:</p><ul><li> SQLITE_FULL: database or disk full<li> SQLITE_IOERR: disk I/O error<li> SQLITE_BUSY: database in use by another process<li> SQLITE_NOMEM: out or memory<li> SQLITE_INTERRUPT: processing interrupted by user request</ul><p>For all of these errors, SQLite attempts to undo just the one statementit was working on and leave changes from prior statements within thesame transaction intact and continue with the transaction.  However, depending on the statement being evaluated and the point at which theerror occurs, it might be necessary for SQLite to rollback andcancel the transaction.  An application can tell whichcourse of action SQLite took by using the<a href="c3ref/get_autocommit.html">sqlite3_get_autocommit()</a> C-language interface.</p><p>It is recommended that applications respond to the errorslisted above by explicitly issuing a ROLLBACK command.  If the transaction has already been rolled back automaticallyby the error response, then the ROLLBACK command will fail with anerror, but no harm is caused by this.</p><p>Future versions of SQLite may extend the list of errors whichmight cause automatic transaction rollback.  Future versions ofSQLite might change the error response.  In particular, we maychoose to simplify the interface in future versions of SQLite bycausing the errors above to force an unconditional rollback.</p><hr><small><i>This page last modified 2008/04/15 19:31:05 UTC</i></small></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -