SQL and PostgreSQL

Lesson 01 · 9 min

Tables and SELECT

A table is rows and columns. SELECT picks which columns to show.

9 minLesson 1 of 10Practice includedAsk AI on any point

A relational database stores data in tables. Every column has a type (integer, text, timestamptz), every row is one record. The primary key id uniquely identifies a row. A SELECT query changes nothing; it only reads.

A table and a first query
AI

You can ask about this rule«Don't write SELECT * in app code»

  • NOT NULL makes a field required, UNIQUE forbids repeats, DEFAULT sets a default value.
  • Keywords are written in capitals by habit; the database doesn't care.
  • AS renames a column in the result: SELECT name AS title.
AI

You can ask about this point«Lesson summary»

Check

Lock it in before you move on

  1. 1. What does PRIMARY KEY do?

  2. 2. Why is SELECT * bad in app code?

  3. 3. A column is NOT NULL. Can you insert a row without it?

PracticeSolve the lesson tasksA few short tasks in the editor. Check your code right away and see where it goes wrong.Start practice