SQLite script - How to read/execute a SQLite script

SQLite script FAQ: How do I read/execute a "create tables" script from the SQLite command line? (How do I read or execute commands in a file from the sqlite3 command line?)

Many times when you're working with a database, you'll keep all your "create table" commands in a database script, which you'll then execute from your database server command line prompt. The file of database commands you execute is often referred to as a "script", or in this case, a "SQLite script".

How to execute a SQLite script (file)

SQLite is no different, and assuming your create table commands are in a file named create.sql, you can execute your script from the SQLite command line using the ".read" command, like this:

sqlite> .read create.sql

As the name of the command implies, this will read and execute all the commands in your SQLite script.

On a related note, if you need an example SQLite script to work with, please see my SQLite create table examples article.

 

Post new comment

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