![]() SQLite opens the database without much fanfare, but it does print a helpful message to the screen. Now we are all set up to browse our SQLite database! Useful SQLite commands Sqlite> Code language: plaintext ( plaintext ) We can open it with the sqlite3 command like this: C:\> sqlite3 customers.db We’ll work with our previous database called customers.db. Let’s start by opening this SQLite database in a file on the filesystem. Now we have an existing database to work with. If you inspect the filesystem, you’ll see that SQLite has created the customers.db file for us. ![]() To close the shell, press control D, which sends the end-of-file character to your terminal, or type in the. Mary|53 Code language: SQL (Structured Query Language) ( sql ) We can see the results with a simple SELECT statement: sqlite> select * from customers Sqlite> insert into customers values( 'Mary', 53) Code language: SQL (Structured Query Language) ( sql ) Sqlite> insert into customers values( 'Erik', 40) Now create a table and insert some data by entering the following lines: sqlite> create table customers( name text, age int) db extension to clearly mark this as a database file. You can pick any filename you want though, but I recommend using the. We can directly give our database a name by giving it as the first argument: $ sqlite3 customers.db We need to start SQLite with the sqlite3 command again to get an SQLite shell. If you don’t have a database, let’s first create one from scratch so we have something to work with. Sqlite> Code language: Bash ( bash ) Create an SQLite database on Command Line If you already have a file-based SQLite database, however, it’s easier to directly open it like so: C:\> sqlite3 customers.db As SQLite points out to use, we can open a database by using the. When opening SQLite without any arguments, it will create an in-memory database. Use ".open FILENAME" to reopen on a persistent database. This works the same on all the operating systems (Windows, MacOS, Linux): C:\> sqlite3Ĭonnected to a transient in-memory database. To open the SQLite shell, we must enter the sqlite3 command in a terminal or command prompt. ![]() If you haven’t done so already, install SQLite first. We can use the SQLite shell to browse SQLite databases.
0 Comments
Leave a Reply. |