lang_createindex.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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: CREATE INDEX</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>CREATE INDEX</h1><h4><a href="syntaxdiagrams.html#create-index-stmt">create-index-stmt:</a></h4><blockquote> <img alt="syntax diagram create-index-stmt" src="images/syntax/create-index-stmt.gif"></img> </blockquote>
  47. <h4><a href="syntaxdiagrams.html#indexed-column">indexed-column:</a></h4><blockquote> <img alt="syntax diagram indexed-column" src="images/syntax/indexed-column.gif"></img> </blockquote>
  48. <p>The CREATE INDEX command consists of the keywords "CREATE INDEX" followed
  49. by the name of the new index, the keyword "ON", the name of a previously
  50. created table that is to be indexed, and a parenthesized list of names of
  51. columns in the table that are used for the index key.</p>
  52. <p>Each column name can be followed by one of the "ASC" or "DESC" keywords
  53. to indicate sort order. The sort order may or may not be ignored depending
  54. on the database file format. The "legacy" file format ignores index
  55. sort order. The descending index file format takes index sort order
  56. into account. Only copies of SQLite newer than version 3.3.0
  57. (released on 2006-01-10) are able to understand the newer descending
  58. index file format and so for compatibility with older versions of
  59. SQLite, the legacy file format is generated by default. Use the
  60. <a href="pragma.html#pragma_legacy_file_format">legacy_file_format</a> pragma to modify this behavior and generate
  61. databases that use the newer file format. Future versions of SQLite
  62. may begin to generate the newer file format by default.</p>
  63. <p>The COLLATE clause following each column name defines a collating
  64. sequence used for text entries in that column. The default collating
  65. sequence is the collating sequence defined for that column in the
  66. <a href="lang_createtable.html">CREATE TABLE</a> statement. Or if no collating sequence is otherwise defined,
  67. the built-in BINARY collating sequence is used.</p>
  68. <p>There are no arbitrary limits on the number of indices that can be
  69. attached to a single table. The number of columns in an index is
  70. limited to SQLITE_MAX_COLUMN.</p>
  71. <p>If the UNIQUE keyword appears between CREATE and INDEX then duplicate
  72. index entries are not allowed. Any attempt to insert a duplicate entry
  73. will result in an error. For the purposes of unique indices, all NULL values
  74. are considered to different from all other NULL values and are thus unique.
  75. This is one of the two possible interpretations of the SQL-92 standard
  76. (the language in the standard is ambiguious) and is the interpretation
  77. followed by PostgreSQL, MySQL, Firebird, and Oracle. Informix and
  78. Microsoft SQL Server follow the other interpretation of the standard.</p>
  79. <p>If the optional IF NOT EXISTS clause is present and another index
  80. with the same name aleady exists, then this command becomes a no-op.</p>
  81. <p>Indexes are removed with the <a href="lang_dropindex.html">DROP INDEX</a>
  82. command.</p>