In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to create and attach databases for SQLite". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
SQLite is a C language library, which implements a small, fast, self-contained, highly reliable, fully functional SQL database engine. SQLite is the most commonly used database engine in the world. SQLite is built into all mobile phones and most computers and bundled with countless other applications that people use every day.
Create a database
Grammar
The basic syntax of the sqlite3 command is as follows:
$sqlite3 DatabaseName.db/
In general, database names should be unique within RDBMS.
Example
If you want to create a new database, the SQLITE3 statement looks like this:
$sqlite3 testDB.dbSQLite version 3.7.15.2 2013-01-09 11:53:05Enter ".help" for instructionsEnter SQL statements terminated with a ";" sqlite >
The above command will create a file testDB.db in the current directory. This file will be used as a database by the SQLite engine. If you have noticed that the sqlite3 command provides a sqlite > prompt after successfully creating the database file. Once the database is created, you can check to see if it is in the database list using the .databases command of SQLite, as shown below:
Sqlite > .databasesseq name file----0 main / home/sqlite/testDB.db
You can exit the sqlite prompt using the SQLite .quit command, as follows:
Sqlite > .resume $
.dump command
You can use the SQLite .dump point command from the command prompt to export the complete database in a text file, as follows:
$sqlite3 testDB.db .dump > testDB.sql
The above command converts the contents of the entire testDB.db database into the statement of SQLite and dumps it into the ASCII text file testDB.sql. You can recover from the generated testDB.sql in a simple way, as follows:
$sqlite3 testDB.db attach database
Grammar
The basic syntax of the ATTACH DATABASE statement for SQLite is as follows:
ATTACH DATABASE file_name AS database_name
If the database has not been created, the above command creates a database, and if the database already exists, bind the database file name to the logical database 'Alias-Name'.
Example
If you want to attach an existing database testDB.db, the ATTACH DATABASE statement will look like this:
Sqlite > ATTACH DATABASE 'testDB.db' as' TEST'
Use the SQLite. Database command to display additional databases.
Sqlite > .databaseseq name file----0 main / home/sqlite/testDB.db2 test / home/sqlite/testDB.db
The database names main and temp are reserved for the primary database and the database that stores temporary tables and other temporary data objects. These two database names can be used for each database connection and should not be used for attachment, otherwise you will get a warning message, as shown below:
Sqlite > ATTACH DATABASE 'testDB.db' as' TEMP';Error: database TEMP is already in usesqlite > ATTACH DATABASE 'testDB.db' as' main';Error: database main is already in use; "how to create and attach databases" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.