In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you what the attachment and separation in the SQLlite database is like, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
In SQLlite databases, a data file is often a schema, but in normal business or some conditions, different contents may be stored in different schema, that is, different data files. In some scenarios, when you need data association, you can use the data attachment of SQLlite to establish a temporary link. As follows, when you use the schema of my_test, you need to associate a query with a schema of my_test2 to use the append:
[root@localhost data] # sqlite3 my_test.db # the default database name in the SQLlite database is main SQLite version 3.6.20 Enter ".help" for instructions Enter SQL statements terminated with a "sqlite > .database seq name file-0 Main / data/my_test.db sqlite > ATTACH DATABASE'/ data/my_test2.db' As' my_test2' # append the data in / data/my_test2.db to the current schema and give it an alias of my_test2 Of course, you can give it another name: sqlite > .birthday seq name file -0 main / data/my_test.db 2 my_test2 / data/my_test2.db sqlite > CREATE TABLE my_test2.test_attach (... > an int (10) B int (10)... >) Sqlite > SELECT * FROM my_test2.sqlite_master WHERE type = 'table' AND tbl_name =' test_attach' # use the data in / data/my_test2.db directly under the current schema and view table | test_attach | test_attach | 4 | CREATE TABLE test_attach (an int (10), b int (10)) sqlite > .exit [root@localhost data] # sqlite3 / data/my_test2.db # switch to my_test2.db 's schema to view and verify SQLite version 3.6.20 Enter ".help" for instructions Enter SQL statements terminated with a " "sqlite > SELECT sql FROM sqlite_master WHERE type = 'table' AND tbl_name =' test_attach'; CREATE TABLE test_attach (an int (10), b int (10))
This is the additional database in the SQLlite database, which is actually a link to use other schma data files under different data schma data files. It should be noted here that the attachment in the SQLlite database is temporary. Create a link in the current session. If you exit the session, the attachment will be separated automatically:
[root@localhost data] # sqlite3 / data/my_test.db SQLite version 3.6.20 Enter ".help" for instructions Enter SQL statements terminated with a " "sqlite > .database seq name file-0 Main / data/my_test.db, of course. If there is an attachment database, there must be separation. Separation is relatively simple: sqlite > .separate seq name file -0 main / data/my_test.db 2 my_test2 / data/my_test2.db sqlite > DETACH DATABASE "my_test2" Sqlite > .resume seq name file -0 main / data/my_test.db
In this way, you can successfully actively detach other data files attached to the current schma. Here, you should pay special attention to the fact that if the detached database is in memory or temporary space, the detached data will be destroyed.
The above is what the attachment and separation in the SQLlite database is like. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.