1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html><head>
- <title>SQLite Query Language: INSERT</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="lang.html">
- <h2 align="center">SQL As Understood By SQLite</h2></a><h1>INSERT</h1><h4><a href="syntaxdiagrams.html#insert-stmt">insert-stmt:</a></h4><blockquote> <img alt="syntax diagram insert-stmt" src="images/syntax/insert-stmt.gif"></img> </blockquote>
- <p>The INSERT statement comes in two basic forms. The first form
- (with the "VALUES" keyword) creates a single new row in an existing table.
- If no column-list is specified then the number of values must
- be the same as the number of columns in the table. If a column-list
- is specified, then the number of values must match the number of
- specified columns. Columns of the table that do not appear in the
- column list are filled with the default value, or with NULL if no
- default value is specified.
- </p>
- <p>The second form of the INSERT statement takes its data from a
- SELECT statement. The number of columns in the result of the
- SELECT must exactly match the number of columns in the table if
- no column list is specified, or it must match the number of columns
- name in the column list. A new entry is made in the table
- for every row of the SELECT result. The SELECT may be simple
- or compound.</p>
- <p>The optional conflict-clause allows the specification of an alternative
- constraint conflict resolution algorithm to use during this one command.
- See the section titled
- <a href="lang_conflict.html">ON CONFLICT</a> for additional information.
- For compatibility with MySQL, the parser allows the use of the
- single keyword <a href="lang_replace.html">REPLACE</a> as an
- alias for "INSERT OR REPLACE".
- </p>
- <p>The optional "<i>database-name</i><b>.</b>" prefix on the <i>table-name</i>
- is support for top-level INSERT statements only. The table name must be
- unqualified for INSERT statements that occur within <a href="lang_createtrigger.html">CREATE TRIGGER</a> statements.
- Likely, the "DEFAULT VALUES" form of the INSERT statement is support for
- top-level INSERT statements only and not for INSERT statements within
- triggers.
- <p>
|