Anshul
Anshul

Reputation: 645

Syntax error in sqlite trying to create a database

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

Upvotes: 8

Views: 24911

Answers (4)

Krishnamoorthy Acharya
Krishnamoorthy Acharya

Reputation: 4254

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

Upvotes: 1

akshay kumar
akshay kumar

Reputation: 1

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>

Upvotes: 0

Mostafa Lotfi
Mostafa Lotfi

Reputation: 171

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>

Upvotes: 3

Otávio Décio
Otávio Décio

Reputation: 74320

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
 $

Upvotes: 15

Related Questions