A SMALL DATABASE. A USEFUL FIRST STEP.

Get started with SQLite

Choose the browser for a quick experiment, or the command-line shell for working with a local database file. Start with a tiny table so every result is easy to understand.

SQLite, sqlite3 and SQL

SQL is the language you use to describe queries. SQLite is a database engine that runs inside an application. The sqlite3 command-line program opens SQLite databases in a terminal. Python also names its SQLite interface sqlite3; it is a module, not the terminal program.

Choose your starting point

  1. No installation: open the sample above, edit a query and choose Run query. Files remain in your browser.
  2. Existing file: open an unencrypted .sqlite or .db file. Select a table to browse rows.
  3. Local terminal: follow the platform steps below, then run the first-database example.

SQLite on Windows

On the official download page, choose the SQLite tools archive matching your Windows architecture. Extract it to a folder. Open PowerShell in that folder and run the executable directly; adding the folder to PATH is optional.

.\sqlite3.exe --version
.\sqlite3.exe learning.db

SQLite on Mac

Open Terminal and check whether the shell is available. If it is missing or you need a different version, use the official macOS tools download matching your processor. Run the extracted executable from its folder.

sqlite3 --version
# From an extracted tools folder:
./sqlite3 learning.db

SQLite on Linux

Check for sqlite3 first. If missing, install your distribution's SQLite command-line package using its package manager, or use a compatible Linux tools archive from the official downloads. Package names and versions vary by distribution.

sqlite3 --version
sqlite3 learning.db

Create, insert, query

After the shell opens learning.db, enter this SQL. You can also paste it into a new SQLite Lab workspace. Use a fresh database or change the table name when repeating it.

CREATE TABLE reading_list (
  id INTEGER PRIMARY KEY,
  title TEXT NOT NULL,
  finished INTEGER NOT NULL DEFAULT 0
);
INSERT INTO reading_list (title) VALUES ('Learn SQLite');
SELECT id, title, finished FROM reading_list;

You should see one row with id 1 and finished 0. In the terminal shell, use .quit to exit. Dot commands belong to the shell and are not SQL; do not paste them into the browser editor.

Keep your work

The terminal stores learning.db in your current folder. In SQLite Lab, download your database using Export database. Browser storage may be cleared, so keep a separate backup of work you need.

What to learn next

Official shell documentation · Official downloads