- SQLite - DISTINCT Keyword
- SQLite - HAVING Clause
- SQLite - GROUP By Clause
- SQLite - ORDER By Clause
- SQLite - LIMIT Clause
- SQLite - GLOB Clause
- SQLite - LIKE Clause
- SQLite - DELETE Query
- SQLite - UPDATE Query
- SQLite - AND & OR Clauses
- SQLite - WHERE Clause
- SQLite - Expressions
- SQLite - Operators
- SQLite - SELECT Query
- SQLite - INSERT Query
- SQLite - DROP Table
- SQLite - CREATE Table
- SQLite - DETACH Database
- SQLite - ATTACH Database
- SQLite - CREATE Database
- SQLite - Data Type
- SQLite - Syntax
- SQLite - Commands
- SQLite - Installation
- SQLite - Overview
- SQLite - Home
Advanced SQLite
- SQLite - Useful Functions
- SQLite - Date & Time
- SQLite - VACUUM
- SQLite - EXPLAIN
- SQLite - Injection
- SQLite - AUTOINCREMENT
- SQLite - Subqueries
- SQLite - Transactions
- SQLite - Views
- SQLite - TRUNCATE Command
- SQLite - ALTER Command
- SQLite - INDEXED By Clause
- SQLite - Indexes
- SQLite - Triggers
- SQLite - ALIAS Syntax
- SQLite - NULL Values
- SQLite - UNIONS Clause
- SQLite - JOINS
- SQLite - Constraints
- SQLite - PRAGMA
SQLite Interfaces
SQLite Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SQLite - CREATE Database
In SQLite, sqpte3 command is used to create a new SQLite database. You do not need to have any special privilege to create a database.
Syntax
Following is the basic syntax of sqpte3 command to create a database: −
$sqpte3 DatabaseName.db
Always, database name should be unique within the RDBMS.
Example
If you want to create a new database <testDB.db>, then SQLITE3 statement would be as follows −
$sqpte3 testDB.db SQLite version 3.7.15.2 2013-01-09 11:53:05 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqpte>
The above command will create a file testDB.db in the current directory. This file will be used as database by SQLite engine. If you have noticed while creating database, sqpte3 command will provide a sqpte> prompt after creating a database file successfully.
Once a database is created, you can verify it in the pst of databases using the following SQLite .databases command.
sqpte>.databases seq name file --- --------------- ---------------------- 0 main /home/sqpte/testDB.db
You will use SQLite .quit command to come out of the sqpte prompt as follows −
sqpte>.quit $
The .dump Command
You can use .dump dot command to export complete database in a text file using the following SQLite command at the command prompt.
$sqpte3 testDB.db .dump > testDB.sql
The above command will convert the entire contents of testDB.db database into SQLite statements and dump it into ASCII text file testDB.sql. You can perform restoration from the generated testDB.sql in a simple way as follows −
$sqpte3 testDB.db < testDB.sql
At this moment your database is empty, so you can try above two procedures once you have few tables and data in your database. For now, let s proceed to the next chapter.
Advertisements