PostgreSQL quick start
Starting from zero, you connect with psql, create your first database and tables, insert and query data and add users to learn how PostgreSQL works.
Level 101 · 15 lessons · 12 practice labs
Lessons
First steps
- What PostgreSQL is and who uses it
- Connecting with psql
- psql meta-commands: \l, \dt, \d
- Creating a database
- Short task: get to know the server and report
Tables and queries
- Creating tables and data types
- Inserting and reading data
- Filtering and sorting
- Updating, deleting and RETURNING
- First joins
- Short task: a book club database
Users and backups
- Creating roles and setting passwords
- Table privileges with GRANT
- Your first backup with pg_dump
- Capstone: a membership database for a club
Practice labs
- Get to know a server with psql: Connect with psql and find the version, the databases and the largest table using meta-commands.
- Map an unknown schema: Use \d commands to list the tables, columns and relations of an inherited database and write a short map.
- Turn psql output into a report: Run psql in script mode and write query results to files as CSV and HTML.
- Create book club tables: Build member and book tables with suitable types and primary keys for a book club.
- Get updated rows back with RETURNING: Mark expired members inactive and list the changed rows with RETURNING to build a notice list.
- Move and delete in one statement: Write a CTE that deletes old events and inserts them into an archive table in the same statement.
- Filter and sort club members: List members who joined this year in a given city, sorted by surname.
- Match who reads which book: Join reading records with members and books to list books currently being read.
- Report members who never borrowed: Use joins and grouping to list members who signed up but never borrowed, with their join date.
- Create a read-only role: Create a reporting role with a password, grant only SELECT and try writing.
- Grant on future tables too: See privileges missing on newly created tables and solve it with default privileges.
- Restore a dump into another database: Take a custom-format pg_dump and restore it into a database with another name without ownership errors.
About this course
Starting from zero, you connect with psql, create your first database and tables, insert and query data and add users to learn how PostgreSQL works.
What you will learn
- First steps
- Tables and queries
- Users and backups
Prerequisites
No prior knowledge is needed; the course starts from zero.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at beginner level; every term is explained where it first appears.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.