![]() The following databases have already be attached. Sample Output: DETACH DATABASE 'Alias-Name' To detach an attached database, the syntax is simply The database main or temp cannot be detached. If two or more database files in the same name have been attached with multiple aliases, then DETACH command will disconnect only the name given and rest of the attachment will still remain same. SQLite DETACH DATABASE statement allows to detach and dissociate a named database from a database connection which was attached using ATTACH statement. Sample Output: sqlite> attach main as main Now we are going to attach the database main and temp and look the result below. The alias for hr database is hrdb and for medical.db are medical and medical1.If the database you specified, already not exists, then a database in the name will be created. In the above example we have attach three databses, one is hr and another two are medical.db in different aliases. Now see the status of the current connection. Let's attached two database hr and medical.db with three aliases, that are hrdb, medical and medical1 ATTACHhr AS hrdb ĪTTACH DATABASE 'medical.db' as 'medical' ĪTTACH DATABASE 'medical.db' as 'medical1' Here in the above example shows that the main database is appearing and another database temp is hidden. ![]() Sample Output: D:\sqlite>sqlite3 medical.db The filename refers to the path and name of the SQLite database file, and database_name refers to the logical name with which to reference that database and its objects. The filename for the database to be attached is the value of the expression, occurs before the AS keyword. Here is the syntax: ATTACH filename AS database_name This adds a connection to another database without replacing your currently selected database. More databases can be attached to your current session with the ATTACH DATABASE statement. When the table name is unique across all attached databases as well as the main and temp databases, then the database-name prefix is not required but when two or more tables in different databases have the same name, then it is necessary to specify the desired table using the database-name prefix. Tables in an attached database can be used like database-name.table-name. The main and temp databases cannot be attached or detached. Both of these database names exist for every database connection and should not be used for attachment, otherwise, you will get a warning message. The database names main and temp are reserved for the primary database and database to hold temporary tables and other temporary data objects. The name that occurs after the AS keyword is the name of the database used internally by SQLite. When a database is attached, all of its contents are accessible in the global scope of the current database file. The ATTACH DATABASE statement allows you to attach multiple database files to the current database connection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |