Creating sqlite database using command line shell in windows

I have a sqlite3.exe file in C:\ and I want to create a sqlite database in C:\db\sqlite . I tried sqlite3 ex1, as suggested in the docs http://www.sqlite.org/sqlite.html , but I get Error Near error "sqlite3".

What is the correct way to create a new database from the shell?

+6
source share
2 answers

Here is one way to use SQLite3 from the command line on Windows.

First you need to know the path to the folder in which you installed SQLite ODBC Driver . If you used the default settings, this would be C: \ Program Files \ SQLite ODBC Driver in Windows XP

Go to Start → Run → type cmd → click OK

Type cmd

This opens a command prompt.

Command prompt

At the command prompt, enter the following command. You can use Alt + Space if you want to use cut and paste. Remember to change the path for your installation if you installed SQLite in a different folder.

cd C: \ Program Files \ SQLite ODBC driver

Path to folder

This will bring you to the SQLite installation folder. Now you can call SQLite. Type the following command at the SQLite prompt.

sqlite3

Call sqlite

The File menu opens, in which you can select a database to connect to or create a new database file.

File menu

Go to C: \ db \ sqlite and create myDatabase.db and click "Open" to close the file menu.

Now you are ready to work on your new database, run your queries, for example. create a table.

Create table

+14
source

Since a new file is created in the current directory, you must follow this format to create the file elsewhere:

eg. to store the file FILENAME.db in c: / users / xyz / abc you must enter

 sqlite>.open c:/users/xyz/abc/FILENAME.db 

and then press enter, a new file will be created at the specified path.

and now when you type .databases you will see your file listed in the list of databases.

+7
source

Source: https://habr.com/ru/post/899592/


All Articles