English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In SQLite,sqlite3
The command is used to create a new SQLite database. You do not need any special privileges to create a database.
The following is sqlite3The basic syntax of the command to create a database is:-
$sqlite3 DatabaseName.db
Always, the database name should be unique in RDBMS.
If you want to create a new database <testDB.db>, then SQLITE3The statement is as follows-
$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>
The above command willtestDB.db
Create a file in the current directory. This file will be used as the database by the SQLite engine. If you noticed while creating the database, sqlite3The command willsqlite>
A prompt is provided after successfully creating the database file.
After creating a database, you can use the following SQLite.databases
The command verifies it in the database list.
sqlite>.databases seq name file --- --------------- ---------------------- 0 main /home/sqlite/testDB.db
You will use SQLite.quit
The command exits from the sqlite prompt, as shown below-
sqlite>.quit$
You can use the .dump command in the command prompt to export the complete database to a text file using the following SQLite command.
$sqlite3 testDB.db .dump > testDB.sql
The above command willtestDB.db
All the content of the database is converted to SQLite statements and stored as an ASCII text filetestDB.sql
You can recover from the generated testDB.sql in the following simple way-
$sqlite3 testDB.db < testDB.sql
Currently your database is empty, so once the tables and data in the database are few, you can try the above two processes. Now, let's continue to the next chapter.