skip to content
06, 11 chapters
types and values

types and values

numbers, text, time, json, arrays and ranges. picking the type is half the schema.

start part 06part 06 of 18, 11 chapters
  1. 06.01types and castsevery value has a type. ::, implicit casts, and why '1' + 1 works but 1 || 1 doesn't.
  2. 06.02integers, numeric and floatsint vs bigint, numeric for money, and 0.1 + 0.2 in float8 vs numeric.
  3. 06.03text, varchar and collationswhy varchar(255) is a habit from another database, and why 'B' sorts before 'a' here.
  4. 06.04dates, times and intervalsdate arithmetic, interval math across month ends, and date_trunc for grouping by week.
  5. 06.05timestamptz and time zonesit stores an instant, not a zone. and the hour in march that never happened.
  6. 06.06booleans, enums and domainsa boolean with three values, enums you can grow but not shrink, and domains as reusable rules.
  7. 06.07identity columns and uuidswhy serial is legacy, GENERATED AS IDENTITY, and uuidv7 keys that sort by time.
  8. 06.08arraysa list in a column. ANY, unnest, @>, and the day it should have been a table.
  9. 06.09json and jsonba document in a column. ->, ->>, @>, jsonpath, JSON_TABLE, and why jsonb won.
  10. 06.10range typesa start and an end as one value. overlaps with &&, empty ranges, and multiranges.
  11. 06.11generated columnscolumns computed from other columns. stored vs virtual, and why postgres 18 made virtual the default.