SQLite - CREATE Database

SQLite - CREATE Database

In SQLite the sqlite3 command can be used to create a database.

Basic Syntex

The syntex fro creatin a new database using SQLite is show below:

$sqlite3 your_database_name.db  

To create a new database in SQLite follow the steps below:

  1. Go to command prompt
  2. type cd \ (press enter)
  3. cd sqlite (press enter)
  4. sqlite3 mydb.db(press enter)
  5. .databases(press enter)

On the terminal the output will be displayed as shown below:

$sqlite3 mydb.db
SQLite version 3.13.0 2016-05-18 10:57:30
Enter ".help" for usage hints.
sqlite>

The above command will create a database named mydb.db in your present working folder.

After the database is created sqlite3 command will give a sqlite>.


.databases Command

Once the database is created .databases command can be used to list the databases.

sqlite> .databases
seq  name             file             
---  ---------------  --------------------------------------
0    main             /home/sqlite/mydb.db        
sqlite>

.quit Command

.quit command can be used to quit the sqlite interface.

sqlite> .quit
$