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

📄 conflict.html

📁 嵌入式数据库sqlite 3.5.9的文档
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Constraint Conflict Resolution in SQLite</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>  <h1>Constraint Conflict Resolution in SQLite</h1><p>In most SQL databases, if you have a UNIQUE constraint ona table and you try to do an UPDATE or INSERT that violatesthe constraint, the database will abort the operation inprogress, back out any prior changes associated with the sameUPDATE or INSERT statement, and return an error.This is the default behavior of SQLite, though SQLite also allows one todefine alternative ways for dealing with constraint violations.This article describes those alternatives and how to use them.</p><h2>Conflict Resolution Algorithms</h2><p>SQLite defines five constraint conflict resolution algorithmsas follows:</p><dl><dt><b>ROLLBACK</b></dt><dd><p>When a constraint violation occurs, an immediate ROLLBACKoccurs, thus ending the current transaction, and the command abortswith a return code of SQLITE_CONSTRAINT.  If no transaction isactive (other than the implied transaction that is created on everycommand) then this algorithm works the same as ABORT.</p></dd><dt><b>ABORT</b></dt><dd><p>When a constraint violation occurs, the command backs outany prior changes it might have made and aborts with a return codeof SQLITE_CONSTRAINT.  But no ROLLBACK is executed so changesfrom prior commands within the same transactionare preserved.  This is the default behavior for SQLite.</p></dd><dt><b>FAIL</b></dt><dd><p>When a constraint violation occurs, the command aborts with areturn code SQLITE_CONSTRAINT.  But any changes to the database thatthe command made prior to encountering the constraint violationare preserved and are not backed out.  For example, if an UPDATEstatement encountered a constraint violation on the 100th row thatit attempts to update, then the first 99 row changes are preservedbut change to rows 100 and beyond never occur.</p></dd><dt><b>IGNORE</b></dt><dd><p>When a constraint violation occurs, the one row that containsthe constraint violation is not inserted or changed.  But the commandcontinues executing normally.  Other rows before and after the row thatcontained the constraint violation continue to be inserted or updatednormally.  No error is returned.</p></dd><dt><b>REPLACE</b></dt><dd><p>When a UNIQUE constraint violation occurs, the pre-existing rowthat caused the constraint violation is removed prior to insertingor updating the current row.  Thus the insert or update always occurs.The command continues executing normally.  No error is returned.</p></dd></dl><hr><small><i>This page last modified 2007/12/16 00:35:09 UTC</i></small></div></body></html>

⌨️ 快捷键说明

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