5
votes

I am new to SQLite. I downloaded the latest version of SQLite (both shell and dll) and extract them to my D: drive. I execute the 'sqlite3.exe' file by double clicking on that.

When I try to create the database with the command sqlite3 test.db;, I get this error.

D:\Android Work\Sqlite\sqlite-shell-win32-x86-3070800>sqlite3.exe
SQLite version 3.7.8 2011-09-19 14:49:19
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> sqlite3 test.db
...> ;
Error: near "sqlite3": syntax error
sqlite>

Please help me..

3

3 Answers

13
votes

I believe you have to type "sqlite3 test.db" from the command line prompt, not from inside the interactive SQLite interface.

See here:

 $ sqlite3 test.db
 SQLite version 3.0.8
 Enter ".help" for instructions
 sqlite> .quit
 $
3
votes

If you're seeing sqlite> then you are inside SQLite. You need to come out with .quit and then type sqlite3 testDB.db to create a database file managed with SQLite

Example below:

sqlite> sqlite3 testDB.db
...> CREATE TABLE first(a int, b string);
Error: near "sqlite3": syntax error
sqlite> .quit

C:\Users\>sqlite3 testDB.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> .databases
main: C:\Users\testDB.db
sqlite>
0
votes

when you type sqlite3 in terminal or cmd you're getting into SQLite command prompt which doesn't allow you to create DB

enter image description here

so quit from cmd or terminal using this command .quit

enter image description here

now run following command to create new DB "sqlite3 siya.db" where "siya" is database name and check created database using following command .databases(to check all the databases)

enter image description here