SQLite uses tutorial 5 to detach a database

Source: Internet
Author: User
Tags db2 sqlite

Http://www.runoob.com/sqlite/sqlite-detach-database.html

Sqlitedetaching a database

SQLite's DETACH dtabase statement is used to detach and dissociate a named database from a database connection that was previously appended using the ATTACH statement. If the same database file has been appended with more than one alias, the DETACH command will only break the connection for the given name, while the remaining remains valid. You cannot detach the main or temp database.

If the database is in memory or a staging database, the database will be destroyed and the content will be lost.
Grammar

The basic syntax for SQLite's DETACH DATABASE ' alias-name ' statement is as follows:

DETACH DATABASE ' Alias-name ';

  

Here, ' Alias-name ' is the same alias you used to attach the database using the ATTACH statement.

Instance

Let's say you've created a database in the previous section and attached ' test ' and ' CurrentDb ' to it, using the. Database command, we can see:

SQLITE>.DATABASESSEQ  name             file---  ---------------  ----------------------0    main             / HOME/SQLITE/TESTDB.DB2    test             /home/sqlite/testdb.db3    currentdb        /home/sqlite/testdb.db

Now, let's try to separate the ' CurrentDb ' from the testdb.db as follows:

sqlite> DETACH DATABASE ' CurrentDb ';

Now, if you check the currently attached database, you will find that the testdb.db remains connected to ' test ' and ' main '.

SQLITE>.DATABASESSEQ  name             file---  ---------------  ----------------------0    Main             /home/sqlite/testdb.db2    Test             /home/sqlite/testdb.db

  

SQLite uses tutorial 5 to detach a database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.