How to create a SQLite database

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

Creating a new database in SQLite is so easy, it's amazing. Once you have SQLite installed and your PATH set up properly, from your Unix or DOS shell, just issue a SQLite command like this:

$ sqlite3 database-name

That's all you have to do to create a SQLite database.

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

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

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.