Creating Tables

CREATE TABLE defines a new table — its name, and the name and type of each column.

Basic syntax

This example starts from a completely empty database, so it creates its own table from scratch:

create a books table
Result

Common column types

  • INTEGER — whole numbers
  • REAL — decimal numbers
  • TEXT — text of any length

PRIMARY KEY

Marking a column as PRIMARY KEY means every row must have a unique value in that column — it's how the database tells rows apart.

Note: everything so far covers reading and shaping data. The next few lessons dig into text matching, cutting down results, missing values, and combining queries in more advanced ways — all things you'll bump into constantly once you're working with real, messier data.