Create SQLite database
SQLite'ssqlite3 command is used to create a new SQLite database.You do not need any special permission to create a data.
grammar
sqlite3 basic syntax of the command is as follows:
$ Sqlite3 DatabaseName.db
Typically, the database name in RDBMS should be unique.
Examples
If you want to create a new database <testDB.db>, SQLITE3 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 will create a file in the current directorytestDB.db.The document will be used as the database engine SQLite. If you have noticed sqlite3 command after successfully create a database file, it will provide asqlite> prompt.
Once the database is created, you can use the SQLite.databases command to check whether it is in the list of databases, as follows:
sqlite> .databases seq name file --- --------------- ---------------------- 0 main /home/sqlite/testDB.db
You can useSQLite .quit quit sqlite command prompt, as follows:
sqlite> .quit $
.dump command
You can export the entire database in a text file, as shown below usingSQLite .dump point command at a command prompt:
$ Sqlite3 testDB.db .dump> testDB.sql
The above command will convert the contents of entiretestDB.db database to SQLite statement, and dump it into an ASCII text file in testDB.sql.You can be a simple way to recover from the resulting testDB.sql, as follows:
$ Sqlite3 testDB.db <testDB.sql
In this case the database is empty, once the database has tables and data, you can try these two programs. Now, let's continue to the next chapter.