>_ IzzyLab

Hands-on task

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

Your first PostgreSQL database

easy~2 min

After SQLite comes a real server. A PostgreSQL cluster is already running, but apart from the system databases it holds nothing. Create a database library — further along the path it will hold a book catalog.

What you'll practise:
  • postgresql
  • createdb
  • sudo -u postgres
  • psql -l

Topic breakdown

Unlike SQLite, PostgreSQL is a server: one cluster (the postgres process and its data directory) holds many databases, and clients connect to it over a socket or the network. The cluster is administered by the system user of the same name, postgres, which is also the DBMS superuser; the OS root means nothing to PostgreSQL, so commands are run via sudo -u postgres. A new database is created either with the command-line wrapper utility or with the SQL command CREATE DATABASE; both add a row to the system catalog pg_database, which is where psql -l reads it from.

What's checked

  1. database library created

What it looks like