| 1 |
<!DOCTYPE html> |
| 2 |
<html><head> |
| 3 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 4 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
| 5 |
<link href="../sqlite.css" rel="stylesheet"> |
| 6 |
<title>SQLite Syntax: upsert-clause</title> |
| 7 |
<!-- path=../ --> |
| 8 |
</head> |
| 9 |
<body> |
| 10 |
<div class=nosearch> |
| 11 |
<a href="../index.html"> |
| 12 |
<img class="logo" src="../images/sqlite370_banner.gif" alt="SQLite" border="0"> |
| 13 |
</a> |
| 14 |
<div><!-- IE hack to prevent disappearing logo --></div> |
| 15 |
<div class="tagline desktoponly"> |
| 16 |
Small. Fast. Reliable.<br>Choose any three. |
| 17 |
</div> |
| 18 |
<div class="menu mainmenu"> |
| 19 |
<ul> |
| 20 |
<li><a href="../index.html">Home</a> |
| 21 |
<li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a> |
| 22 |
<li class='wideonly'><a href='../about.html'>About</a> |
| 23 |
<li class='desktoponly'><a href="../docs.html">Documentation</a> |
| 24 |
<li class='desktoponly'><a href="../download.html">Download</a> |
| 25 |
<li class='wideonly'><a href='../copyright.html'>License</a> |
| 26 |
<li class='desktoponly'><a href="../support.html">Support</a> |
| 27 |
<li class='desktoponly'><a href="../prosupport.html">Purchase</a> |
| 28 |
<li class='search' id='search_menubutton'> |
| 29 |
<a href="javascript:void(0)" onclick='toggle_search()'>Search</a> |
| 30 |
</ul> |
| 31 |
</div> |
| 32 |
<div class="menu submenu" id="submenu"> |
| 33 |
<ul> |
| 34 |
<li><a href='../about.html'>About</a> |
| 35 |
<li><a href='../docs.html'>Documentation</a> |
| 36 |
<li><a href='../download.html'>Download</a> |
| 37 |
<li><a href='../support.html'>Support</a> |
| 38 |
<li><a href='../prosupport.html'>Purchase</a> |
| 39 |
</ul> |
| 40 |
</div> |
| 41 |
<div class="searchmenu" id="searchmenu"> |
| 42 |
<form method="GET" action="../search"> |
| 43 |
<select name="s" id="searchtype"> |
| 44 |
<option value="d">Search Documentation</option> |
| 45 |
<option value="c">Search Changelog</option> |
| 46 |
</select> |
| 47 |
<input type="text" name="q" id="searchbox" value=""> |
| 48 |
<input type="submit" value="Go"> |
| 49 |
</form> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
<script> |
| 53 |
function toggle_div(nm) { |
| 54 |
var w = document.getElementById(nm); |
| 55 |
if( w.style.display=="block" ){ |
| 56 |
w.style.display = "none"; |
| 57 |
}else{ |
| 58 |
w.style.display = "block"; |
| 59 |
} |
| 60 |
} |
| 61 |
function toggle_search() { |
| 62 |
var w = document.getElementById("searchmenu"); |
| 63 |
if( w.style.display=="block" ){ |
| 64 |
w.style.display = "none"; |
| 65 |
} else { |
| 66 |
w.style.display = "block"; |
| 67 |
setTimeout(function(){ |
| 68 |
document.getElementById("searchbox").focus() |
| 69 |
}, 30); |
| 70 |
} |
| 71 |
} |
| 72 |
function div_off(nm){document.getElementById(nm).style.display="none";} |
| 73 |
window.onbeforeunload = function(e){div_off("submenu");} |
| 74 |
/* Disable the Search feature if we are not operating from CGI, since */ |
| 75 |
/* Search is accomplished using CGI and will not work without it. */ |
| 76 |
if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){ |
| 77 |
document.getElementById("search_menubutton").style.display = "none"; |
| 78 |
} |
| 79 |
/* Used by the Hide/Show button beside syntax diagrams, to toggle the */ |
| 80 |
function hideorshow(btn,obj){ |
| 81 |
var x = document.getElementById(obj); |
| 82 |
var b = document.getElementById(btn); |
| 83 |
if( x.style.display!='none' ){ |
| 84 |
x.style.display = 'none'; |
| 85 |
b.innerHTML='show'; |
| 86 |
}else{ |
| 87 |
x.style.display = ''; |
| 88 |
b.innerHTML='hide'; |
| 89 |
} |
| 90 |
return false; |
| 91 |
} |
| 92 |
var antiRobot = 0; |
| 93 |
function antiRobotGo(){ |
| 94 |
if( antiRobot!=3 ) return; |
| 95 |
antiRobot = 7; |
| 96 |
var j = document.getElementById("mtimelink"); |
| 97 |
if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href"); |
| 98 |
} |
| 99 |
function antiRobotDefense(){ |
| 100 |
document.body.onmousedown=function(){ |
| 101 |
antiRobot |= 2; |
| 102 |
antiRobotGo(); |
| 103 |
document.body.onmousedown=null; |
| 104 |
} |
| 105 |
document.body.onmousemove=function(){ |
| 106 |
antiRobot |= 2; |
| 107 |
antiRobotGo(); |
| 108 |
document.body.onmousemove=null; |
| 109 |
} |
| 110 |
setTimeout(function(){ |
| 111 |
antiRobot |= 1; |
| 112 |
antiRobotGo(); |
| 113 |
}, 100) |
| 114 |
antiRobotGo(); |
| 115 |
} |
| 116 |
antiRobotDefense(); |
| 117 |
</script> |
| 118 |
<h1 align='center'>upsert-clause</h1> |
| 119 |
<div class='imgcontainer'> |
| 120 |
<div style="max-width:901px"><svg xmlns='http://www.w3.org/2000/svg' class="pikchr" viewBox="0 0 901.142 363.96"> |
| 121 |
<path d="M223,165L759,165L759,51L223,51Z" style="fill:none;stroke-width:3.24;stroke:rgb(211,211,211);" /> |
| 122 |
<circle cx="5" cy="66" r="3.6" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 123 |
<polygon points="47,66 35,71 35,62" style="fill:rgb(0,0,0)"/> |
| 124 |
<path d="M9,66L41,66" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 125 |
<path d="M62,82L71,82A15 15 0 0 0 86 66A15 15 0 0 0 71 51L62,51A15 15 0 0 0 47 66A15 15 0 0 0 62 82Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 126 |
<text x="66" y="66" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">ON</text> |
| 127 |
<polygon points="103,66 92,71 92,62" style="fill:rgb(0,0,0)"/> |
| 128 |
<path d="M86,66L98,66" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 129 |
<path d="M118,82L193,82A15 15 0 0 0 208 66A15 15 0 0 0 193 51L118,51A15 15 0 0 0 103 66A15 15 0 0 0 118 82Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 130 |
<text x="156" y="66" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">CONFLICT</text> |
| 131 |
<polygon points="264,97 253,101 253,92" style="fill:rgb(0,0,0)"/> |
| 132 |
<path d="M208,66 L 223,66 Q 238,66 238,81 L 238,82 Q 238,97 248,97 L 259,97" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 133 |
<path d="M280,112A15 15 0 0 0 295 97L295,97A15 15 0 0 0 280 82A15 15 0 0 0 264 97L264,97A15 15 0 0 0 280 112Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 134 |
<text x="280" y="97" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">(</text> |
| 135 |
<polygon points="331,97 319,101 319,92" style="fill:rgb(0,0,0)"/> |
| 136 |
<path d="M295,97L325,97" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 137 |
<path d="M331,112L475,112L475,82L331,82Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 138 |
<text x="403" y="97" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">indexed-column</text> |
| 139 |
<polygon points="511,97 500,101 500,92" style="fill:rgb(0,0,0)"/> |
| 140 |
<path d="M475,97L506,97" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 141 |
<path d="M526,112A15 15 0 0 0 542 97L542,97A15 15 0 0 0 526 82A15 15 0 0 0 511 97L511,97A15 15 0 0 0 526 112Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 142 |
<text x="526" y="97" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">)</text> |
| 143 |
<polygon points="583,135 572,139 572,130" style="fill:rgb(0,0,0)"/> |
| 144 |
<path d="M542,97 L 549,97 Q 557,97 557,112 L 557,119 Q 557,135 567,135 L 577,135" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 145 |
<path d="M598,150L648,150A15 15 0 0 0 663 135A15 15 0 0 0 648 119L598,119A15 15 0 0 0 583 135A15 15 0 0 0 598 150Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 146 |
<text x="623" y="135" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">WHERE</text> |
| 147 |
<polygon points="680,135 669,139 669,130" style="fill:rgb(0,0,0)"/> |
| 148 |
<path d="M663,135L674,135" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 149 |
<path d="M680,150L729,150L729,119L680,119Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 150 |
<text x="705" y="135" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">expr</text> |
| 151 |
<polygon points="744,108 749,119 740,119" style="fill:rgb(0,0,0)"/> |
| 152 |
<path d="M729,135 L 737,135 Q 744,135 744,124 L 744,114" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 153 |
<polygon points="786,66 774,71 774,62" style="fill:rgb(0,0,0)"/> |
| 154 |
<path d="M744,108 L 744,81 Q 744,66 759,66 L 765,66 L 780,66" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 155 |
<path d="M801,82L809,82A15 15 0 0 0 824 66A15 15 0 0 0 809 51L801,51A15 15 0 0 0 786 66A15 15 0 0 0 801 82Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 156 |
<text x="805" y="66" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">DO</text> |
| 157 |
<polygon points="729,97 718,101 718,92" style="fill:rgb(0,0,0)"/> |
| 158 |
<path d="M542,97L723,97" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 159 |
<path d="M729,97 L 737,97 Q 744,97 744,89 L 744,82" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 160 |
<path d="M208,66L774,66" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 161 |
<path d="M403,150A15 15 0 0 0 418 135A15 15 0 0 0 403 119A15 15 0 0 0 388 135A15 15 0 0 0 403 150Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 162 |
<text x="403" y="135" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">,</text> |
| 163 |
<polygon points="418,135 430,130 430,139" style="fill:rgb(0,0,0)"/> |
| 164 |
<path d="M475,97 L 483,97 Q 490,97 490,112 L 490,119 Q 490,135 475,135 L 439,135 L 424,135" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 165 |
<path d="M388,135 L 319,135 Q 304,135 304,119 L 304,112 Q 304,97 312,97 L 319,97" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 166 |
<text x="288" y="36" text-anchor="middle" font-style="italic" fill="rgb(128,128,128)" dominant-baseline="central">conflict target</text> |
| 167 |
<polygon points="436,195 447,191 447,199" style="fill:rgb(0,0,0)"/> |
| 168 |
<path d="M824,66 L 831,66 Q 839,66 839,81 L 839,180 Q 839,195 824,195 L 456,195 L 441,195" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 169 |
<polygon points="47,271 35,275 35,266" style="fill:rgb(0,0,0)"/> |
| 170 |
<path d="M436,195 L 35,195 Q 20,195 20,210 L 20,256 Q 20,271 31,271 L 41,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 171 |
<path d="M62,286L116,286A15 15 0 0 0 131 271A15 15 0 0 0 116 255L62,255A15 15 0 0 0 47 271A15 15 0 0 0 62 286Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 172 |
<text x="89" y="271" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">UPDATE</text> |
| 173 |
<polygon points="148,271 137,275 137,266" style="fill:rgb(0,0,0)"/> |
| 174 |
<path d="M131,271L143,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 175 |
<path d="M164,286L179,286A15 15 0 0 0 194 271A15 15 0 0 0 179 255L164,255A15 15 0 0 0 148 271A15 15 0 0 0 164 286Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 176 |
<text x="171" y="271" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">SET</text> |
| 177 |
<polygon points="257,308 245,313 245,304" style="fill:rgb(0,0,0)"/> |
| 178 |
<path d="M194,271 L 215,271 Q 230,271 230,286 L 230,293 Q 230,308 241,308 L 251,308" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 179 |
<path d="M257,324L413,324L413,293L257,293Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 180 |
<text x="335" y="308" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">column-name-list</text> |
| 181 |
<polygon points="475,271 464,275 464,266" style="fill:rgb(0,0,0)"/> |
| 182 |
<path d="M413,308 L 434,308 Q 449,308 449,293 L 449,286 Q 449,271 459,271 L 469,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 183 |
<path d="M490,286A15 15 0 0 0 505 271A15 15 0 0 0 490 255A15 15 0 0 0 475 271A15 15 0 0 0 490 286Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 184 |
<text x="490" y="271" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">=</text> |
| 185 |
<polygon points="523,271 511,275 511,266" style="fill:rgb(0,0,0)"/> |
| 186 |
<path d="M505,271L517,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 187 |
<path d="M523,286L572,286L572,255L523,255Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 188 |
<text x="547" y="271" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">expr</text> |
| 189 |
<polygon points="619,271 608,275 608,266" style="fill:rgb(0,0,0)"/> |
| 190 |
<path d="M572,271L613,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 191 |
<path d="M634,286L684,286A15 15 0 0 0 699 271A15 15 0 0 0 684 255L634,255A15 15 0 0 0 619 271A15 15 0 0 0 634 286Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 192 |
<text x="659" y="271" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">WHERE</text> |
| 193 |
<polygon points="716,271 705,275 705,266" style="fill:rgb(0,0,0)"/> |
| 194 |
<path d="M699,271L710,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 195 |
<path d="M716,286L765,286L765,255L716,255Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 196 |
<text x="741" y="271" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">expr</text> |
| 197 |
<polygon points="891,233 880,237 880,228" style="fill:rgb(0,0,0)"/> |
| 198 |
<path d="M765,271 L 773,271 Q 780,271 780,256 L 780,248 Q 780,233 795,233 L 871,233 L 886,233" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 199 |
<circle cx="895" cy="233" r="3.6" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 200 |
<path d="M62,248L130,248A15 15 0 0 0 145 233A15 15 0 0 0 130 218L62,218A15 15 0 0 0 47 233A15 15 0 0 0 62 248Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 201 |
<text x="96" y="233" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">NOTHING</text> |
| 202 |
<polygon points="47,233 35,237 35,228" style="fill:rgb(0,0,0)"/> |
| 203 |
<path d="M20,218 L 20,225 Q 20,233 31,233 L 41,233" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 204 |
<path d="M145,233L880,233" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 205 |
<polygon points="638,233 626,237 626,228" style="fill:rgb(0,0,0)"/> |
| 206 |
<path d="M587,271 L 594,271 Q 602,271 602,256 L 602,248 Q 602,233 617,233 L 617,233 L 632,233" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 207 |
<path d="M383,361A15 15 0 0 0 398 346A15 15 0 0 0 383 331A15 15 0 0 0 368 346A15 15 0 0 0 383 361Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 208 |
<text x="383" y="346" text-anchor="middle" font-weight="bold" fill="rgb(0,0,0)" dominant-baseline="central">,</text> |
| 209 |
<polygon points="398,346 410,342 410,351" style="fill:rgb(0,0,0)"/> |
| 210 |
<path d="M572,271 L 579,271 Q 587,271 587,286 L 587,331 Q 587,346 572,346 L 419,346 L 404,346" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 211 |
<polygon points="206,308 210,320 201,320" style="fill:rgb(0,0,0)"/> |
| 212 |
<path d="M368,346 L 221,346 Q 206,346 206,331 L 206,329 L 206,314" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 213 |
<path d="M206,308 L 206,286 Q 206,271 221,271 L 227,271 L 242,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 214 |
<polygon points="257,271 245,275 245,266" style="fill:rgb(0,0,0)"/> |
| 215 |
<path d="M194,271L251,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 216 |
<path d="M272,286L366,286A15 15 0 0 0 381 271A15 15 0 0 0 366 255L272,255A15 15 0 0 0 257 271A15 15 0 0 0 272 286Z" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 217 |
<text x="319" y="271" text-anchor="middle" fill="rgb(0,0,0)" dominant-baseline="central">column-name</text> |
| 218 |
<path d="M381,271L464,271" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 219 |
<polygon points="865,97 869,108 860,108" style="fill:rgb(0,0,0)"/> |
| 220 |
<path d="M850,233 L 857,233 Q 865,233 865,218 L 865,117 L 865,102" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 221 |
<polygon points="403,6 415,2 415,10" style="fill:rgb(0,0,0)"/> |
| 222 |
<path d="M865,97 L 865,21 Q 865,6 850,6 L 424,6 L 409,6" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 223 |
<path d="M403,6 L 40,6 Q 25,6 25,21 L 25,51 Q 25,66 32,66 L 40,66" style="fill:none;stroke-width:2.16;stroke:rgb(0,0,0);" /> |
| 224 |
</svg> |
| 225 |
</div><br> |
| 226 |
|
| 227 |
Used by: <a href='./insert-stmt.html'>insert-stmt</a><br></br> |
| 228 |
References: <a href='./column-name-list.html'>column-name-list</a> <a href='./expr.html'>expr</a> <a href='./indexed-column.html'>indexed-column</a><br></br> |
| 229 |
See also: <a href='../lang_createtrigger.html'>lang_createtrigger.html</a> <a href='../lang_insert.html'>lang_insert.html</a> <a href='../lang_upsert.html'>lang_upsert.html</a> |
| 230 |
</div> |
| 231 |
|
| 232 |
|
| 233 |
|