Types that tell the truth

Step 1 of 120%

Concept · step 1 of 12

The types you will use most

Every column has a type, and the type is the first rule the column keeps. Most tables need only a handful of them.

  • `TEXT` for words of any length, and `INT` or `BIGINT` for whole numbers..
  • `BOOLEAN` for yes or no. true or false.
  • `DATE` for a day of the calendar, with no time of day..
CREATE TABLE members (
  name   TEXT,
  age    INT,
  active BOOLEAN,
  joined DATE
);
Those four cover most columns. Two kinds of value need more care, and they are the rest of this lesson: money, where the obvious type loses cents, and moments in time, where the obvious type loses the time zone.
PostgreSQL docs: Numeric types ↗

Starting Postgres in your browser

About 5 MB the first time, cached after that.

PostgreSQL running in your browser