SQLite’s sqlite3 Command is used to create a new SQLite database. You do not need any special permissions to create a data. The basic syntax of the sqlite3 command is as follows: In general, database names should be unique within RDBMS. We can also use .open to create a new database file: The above command creates the database file test.db, which is located in the same directory as the sqlite3 command. The. Open command is also used to open an existing database. If the above command test.db If it exists, it will be opened directly, and if it does not exist, create it. If you want to create a new database < testDB.db >, the SQLITE3 statement looks like this: The above command will create a file in the current directory testDB.db . This file will be used as a database by the SQLite engine. If you have noticed that after the sqlite3 command successfully creates the database file, it provides a sqlite> Prompt. Once the database is created, you can use SQLite’s .databases Command to check if it is in the database list, as follows: You can use SQLite .quit The command exits the sqlite prompt, as follows: You can use SQLite from a command prompt .dump Click the command to export the complete database in a text file, as follows: The above command will convert the entire testDB.db Put the contents of the database into the statement of SQLite and dump it to the ASCII text file testDB.sql Medium. You can recover from the generated testDB.sql in a simple way, as follows: At this time, the database is empty, once there are tables and data in the database, you can try the above two programs. Now, let’s move on to the next chapter. 1.7.1. Grammar ¶
$ sqlite3 DatabaseName.db
sqlite>.open test.db
1.7.2. Example ¶
$ sqlite3 testDB.db
SQLite version 3.7.15.2 2013-01-09 11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
sqlite>.databases
seq name file
--- --------------- ----------------------
0 main /home/sqlite/testDB.db
sqlite>.quit
$
1.7.3. .dump command ¶
$sqlite3 testDB.db .dump > testDB.sql
$sqlite3 testDB.db < testDB.sql