Execute SQLite script Ask Question

Execute SQLite script Ask Question

I start up sqlite3 version 3.7.7, unix 11.4.2 using this command:

sqlite3 auction.db

where auction.db has not already been created.

sqlite> auction.db < create.sql;

gives me this error: near "auction": syntax error

How can I run the script?

ベストアンサー1

You want to feed the create.sql into sqlite3 from the shell, not from inside SQLite itself:

$ sqlite3 auction.db < create.sql

SQLite's version of SQL doesn't understand < for files, your shell does.

おすすめ記事