How to create an empty SQLite db with command?

command, database, sqlite

Solution

I don't think there is a way to do that in just one statement.

In Linux I would workaround it this way:

sqlite3 aFile.db "create table aTable(field1 int); drop table aTable;"

This will automatically create the needed file with the table in it and then drop it leaving the database file without tables. That's the closest thing I know.

Anyway, I think most editors will even accept an empty file too. Give that a try.

Problem

Is it possible to create an empty `sqlite3` database from the command line (e.g. `sqlite3 <someoption> dbname`) which would create a database file for me empty of any tables so that I can access it from a different SQL editor? Currently, when I do `sqlite3 dbname`, I get a sqlite prompt from which I can do `CREATE TABLE ...` but if I don't, when I exit, no file is created. So I am looking for a single command which would create an empty database for me without a need to create at least one table within that step.

Original source

Related problems