CREATE TABLE, from nothing

Step 1 of 110%

Concept · step 1 of 11

The anatomy of CREATE TABLE

A table is declared once, by name, with its columns between brackets. Read the example piece by piece.

  • The name comes first. CREATE TABLE authors. Lowercase and plural is the usual style.
  • Then, between brackets, one line per column. its name, then its type.
  • Columns are separated by commas, with none after the last, and the statement ends with a semicolon..
CREATE TABLE authors (
  name TEXT,
  born INT
);
That is the whole shape. The board is empty now; in two steps you will fill it. Everything later in the course adds words to these lines, like NOT NULL or PRIMARY KEY, but never changes this skeleton.
PostgreSQL docs: Creating a new table ↗

Starting Postgres in your browser

About 5 MB the first time, cached after that.

PostgreSQL running in your browser