How to use sqlite3.exe to create database from exported .sql script
Use the following command line:
sqlite3 -init dump.sql newsqlite.db ""
It will create a new SQLite database file by newsqlite.db
following the instructions from dump.sql
. An empty string is ""
required for sqlite3 to close automatically.
If the file newsqlite.db
already exists with some data, the import may fail if you do not use IF NOT EXISTS
table and index creation for all statements.
source to share
Place sqlite3.exe
where you want, as long as you remember that place, and you can start sqlite3
from there.
Applying a script to a database (possibly just created) on the command line:
sqlite3.exe my-new-db.somesuffix < myscript.sql
Executing script in an interactive session sqlite3
:
sqlite3.exe my-new-db.somesuffix
....
.read myscript.sql
....
Both options are valid and usable. (Note: if yours .sql
was built for a non-sqlite database, I would expect sqlite3
some changes to work in order to work . And things like stored procedures and UDFs would definitely be lost).
source to share