8

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..

4 Answers 4

15

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
 $
Sign up to request clarification or add additional context in comments.

1 Comment

You can also use the ATTACH DATABASE command to create a new database from within the sqlite shell, but providing it at the command line like this is the best, "cleanest" option.
3

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>

Comments

1

when you type sqlite3 in the 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 the following command to create a new DB "sqlite3 siya.db" where "siya" is the database name and check created database using the following command .databases(to check all the databases)

enter image description here

Comments

0

open cmd and type cd\ and then C:>cd sqlite C:\sqlite>sqlite3 test.db SQLite version 3.39.2 2022-07-21 15:24:47 Enter ".help" for usage hints. sqlite> .databases main: C:\sqlite\test.db r/w sqlite>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.