lang_insert.html 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html><head>
  3. <title>SQLite Query Language: INSERT</title>
  4. <style type="text/css">
  5. body {
  6. margin: auto;
  7. font-family: Verdana, sans-serif;
  8. padding: 8px 1%;
  9. }
  10. a { color: #45735f }
  11. a:visited { color: #734559 }
  12. .logo { position:absolute; margin:3px; }
  13. .tagline {
  14. float:right;
  15. text-align:right;
  16. font-style:italic;
  17. width:240px;
  18. margin:12px;
  19. margin-top:58px;
  20. }
  21. .toolbar {
  22. font-variant: small-caps;
  23. text-align: center;
  24. line-height: 1.6em;
  25. margin: 0;
  26. padding:1px 8px;
  27. }
  28. .toolbar a { color: white; text-decoration: none; padding: 6px 12px; }
  29. .toolbar a:visited { color: white; }
  30. .toolbar a:hover { color: #80a796; background: white; }
  31. .content { margin: 5%; }
  32. .content dt { font-weight:bold; }
  33. .content dd { margin-bottom: 25px; margin-left:20%; }
  34. .content ul { padding:0px; padding-left: 15px; margin:0px; }
  35. /* rounded corners */
  36. .se { background: url(images/se.png) 100% 100% no-repeat #80a796}
  37. .sw { background: url(images/sw.png) 0% 100% no-repeat }
  38. .ne { background: url(images/ne.png) 100% 0% no-repeat }
  39. .nw { background: url(images/nw.png) 0% 0% no-repeat }
  40. </style>
  41. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  42. </head>
  43. <body>
  44. <div><!-- container div to satisfy validator -->
  45. <a href="lang.html">
  46. <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>
  47. <p>The INSERT statement comes in two basic forms. The first form
  48. (with the "VALUES" keyword) creates a single new row in an existing table.
  49. If no column-list is specified then the number of values must
  50. be the same as the number of columns in the table. If a column-list
  51. is specified, then the number of values must match the number of
  52. specified columns. Columns of the table that do not appear in the
  53. column list are filled with the default value, or with NULL if no
  54. default value is specified.
  55. </p>
  56. <p>The second form of the INSERT statement takes its data from a
  57. SELECT statement. The number of columns in the result of the
  58. SELECT must exactly match the number of columns in the table if
  59. no column list is specified, or it must match the number of columns
  60. name in the column list. A new entry is made in the table
  61. for every row of the SELECT result. The SELECT may be simple
  62. or compound.</p>
  63. <p>The optional conflict-clause allows the specification of an alternative
  64. constraint conflict resolution algorithm to use during this one command.
  65. See the section titled
  66. <a href="lang_conflict.html">ON CONFLICT</a> for additional information.
  67. For compatibility with MySQL, the parser allows the use of the
  68. single keyword <a href="lang_replace.html">REPLACE</a> as an
  69. alias for "INSERT OR REPLACE".
  70. </p>
  71. <p>The optional "<i>database-name</i><b>.</b>" prefix on the <i>table-name</i>
  72. is support for top-level INSERT statements only. The table name must be
  73. unqualified for INSERT statements that occur within <a href="lang_createtrigger.html">CREATE TRIGGER</a> statements.
  74. Likely, the "DEFAULT VALUES" form of the INSERT statement is support for
  75. top-level INSERT statements only and not for INSERT statements within
  76. triggers.
  77. <p>