How common SQL data types work

Use common families

  • INTEGER for whole numbers
  • DECIMAL or NUMERIC for exact decimal values
  • TEXT or VARCHAR for text
  • DATE, TIME, or TIMESTAMP for temporal values

Choose by meaning

A phone number is text, not a number used in arithmetic. Money usually needs an exact decimal type; floating-point types can introduce rounding surprises.

Know SQLite's model

SQLite uses flexible type affinity and commonly stores dates as ISO 8601 text, Julian day numbers, or Unix timestamps. PostgreSQL and MySQL enforce declared types more strictly and have native date/time behavior.

CREATE TABLE events (
  name TEXT,
  starts_on TEXT  -- ISO date: YYYY-MM-DD
);

Allow absence deliberately

NULL means missing or unknown. Add NOT NULL when every row must provide a value, and use constraints to protect other rules.