How to create a SQLite database

SQLite database FAQ: How do I create a SQLite database?

Solution

To create a new database using SQLite, assuming that you have SQLite installed and your PATH set up properly, from your Unix or DOS shell, just issue this SQLite command:

$ sqlite3 my-database-name

That's all you have to do to create a SQLite database. In this case the database is named my-database-name.

A complete SQLite “create database” example

As a concrete example of how to create a SQLite database, if I want to create a new SQLite database named blog.db, I'd create it like this:

$ sqlite3 blog.db

SQLite version 3.4.0
Enter ".help" for instructions
sqlite> 

As you can see, SQLite creates my database, and logs me into the new database at the same time. I can now issue whatever SQLite commands I want, presumably some CREATE TABLE commands to create new tables in my new SQLite database.

Note that this SQLite “create database” command creates a new file in my local directory, as I can see with the Unix ls command:

$ ls -al

drwxr-xr-x  8 al  al      272 Jun 24 13:21 .
drwxr-xr-x@ 7 al  al      238 Jun 24 09:20 ..
-rw-r--r--  1 al  al        0 Jun 24 13:21 blog.db