SQLite scripts: 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 SQLite database, you’ll keep all your CREATE TABLE SQL 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 command reads your SQLite script/file and executes all of the command in it.

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

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.