1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html><head>
- <title>SQLite Query Language: ATTACH DATABASE</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>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>
- <p>The ATTACH DATABASE statement adds another database
- file to the current database connection. If the filename contains
- punctuation characters it must be quoted. The database-names 'main' and
- 'temp' refer to the main database and the database used for
- temporary tables. These cannot be detached. Attached databases
- are removed using the <a href="lang_detach.html">DETACH</a> statement.</p>
- <p>You cannot create a new table with the same name as a table in
- an attached database, but you can attach a database which contains
- tables whose names are duplicates of tables in the main database. It is
- also permissible to attach the same database file multiple times.</p>
- <p>Tables in an attached database can be referred to using the syntax
- <i>database-name.table-name</i>. If an attached table doesn't have
- a duplicate table name in the main database, it does not require a
- <i>database-name</i> prefix. When a database is attached, all of its
- tables which don't have duplicate names become the default table
- of that name. Any tables of that name attached afterwards require the
- database prefix. If the default table of a given name is detached, then
- the last table of that name attached becomes the new default.</p>
- <p>
- Transactions involving multiple attached databases are atomic,
- assuming that the main database is not "<a href="inmemorydb.html">:memory:</a>". If the main
- database is ":memory:" then
- transactions continue to be atomic within each individual
- database file. But if the host computer crashes in the middle
- of a <a href="lang_transaction.html">COMMIT</a> where two or more database files are updated,
- some of those files might get the changes where others
- might not.
- </p>
- <p>There is a compile-time limit of SQLITE_MAX_ATTACHED
- attached database files.</p>
|