Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute SQLite script

Tags:

sqlite

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?

like image 277
Rose Perrone Avatar asked Jul 25 '12 06:07

Rose Perrone


People also ask

How use SQLite file in SQL?

Import the SQL file Open DB Browser for SQLite. Choose “File” > “Import” > “Database” from SQL file from the menu bar at the top of your screen.


1 Answers

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.

like image 57
mu is too short Avatar answered Oct 04 '22 09:10

mu is too short