2
0

lang_attach.html 3.4 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: ATTACH DATABASE</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>ATTACH DATABASE</h1><h4><a href="syntaxdiagrams.html#attach-stmt">attach-stmt:</a></h4><blockquote> <img alt="syntax diagram attach-stmt" src="images/syntax/attach-stmt.gif"></img> </blockquote>
  47. <p>The ATTACH DATABASE statement adds another database
  48. file to the current database connection. If the filename contains
  49. punctuation characters it must be quoted. The database-names 'main' and
  50. 'temp' refer to the main database and the database used for
  51. temporary tables. These cannot be detached. Attached databases
  52. are removed using the <a href="lang_detach.html">DETACH</a> statement.</p>
  53. <p>You cannot create a new table with the same name as a table in
  54. an attached database, but you can attach a database which contains
  55. tables whose names are duplicates of tables in the main database. It is
  56. also permissible to attach the same database file multiple times.</p>
  57. <p>Tables in an attached database can be referred to using the syntax
  58. <i>database-name.table-name</i>. If an attached table doesn't have
  59. a duplicate table name in the main database, it does not require a
  60. <i>database-name</i> prefix. When a database is attached, all of its
  61. tables which don't have duplicate names become the default table
  62. of that name. Any tables of that name attached afterwards require the
  63. database prefix. If the default table of a given name is detached, then
  64. the last table of that name attached becomes the new default.</p>
  65. <p>
  66. Transactions involving multiple attached databases are atomic,
  67. assuming that the main database is not "<a href="inmemorydb.html">:memory:</a>". If the main
  68. database is ":memory:" then
  69. transactions continue to be atomic within each individual
  70. database file. But if the host computer crashes in the middle
  71. of a <a href="lang_transaction.html">COMMIT</a> where two or more database files are updated,
  72. some of those files might get the changes where others
  73. might not.
  74. </p>
  75. <p>There is a compile-time limit of SQLITE_MAX_ATTACHED
  76. attached database files.</p>