>_ IzzyLab

Hands-on task

This task is step 1 of the course “Databases in an evening: SQLite, PostgreSQL, Redis”

SQLite: a book catalog in one file

easy~5 min

Let's start with the simplest database — SQLite. Create a database /root/catalog.db with a table books of three columns id, title and year, and add at least 3 books to it.

Write the SQL as a script in the file /root/catalog.sql — it's handy to type it in the Editor tab — and then run that script in sqlite3.

What you'll practise:
  • sqlite3
  • create table
  • insert
  • sql

Topic breakdown

SQLite is an embedded DBMS without a server: the whole database, with all its tables and indexes, lives in one file, and the sqlite3 utility opens it directly and creates it on first access. You work in ordinary SQL: the table structure is described with CREATE TABLE with column names and types, data is added with INSERT INTO, and several rows can be passed in one query. String values are written in single quotes, numbers without, so it's handy to wrap the whole SQL in the shell's double quotes.

What's checked

  1. books has at least 3 books
  2. the SQL script /root/catalog.sql creates the table

What it looks like