SQL Data Types
Every column has a declared type — it's what decides what values are valid and how they compare and sort.
What & Why
A column's data type constrains what can be stored in it and how operations like comparison, sorting, and arithmetic behave. This lesson series covers the major categories: numbers, text, boolean, and date/time — plus how to convert between them explicitly.
See How It Works
EXAMPLE TABLE — marketing.campaigns
| id | name | channel | spend | start_date | status |
|---|---|---|---|---|---|
| 1 | Spring Launch | google_ads | 55000.00 | 2024-01-15 | active |
| 2 | Retention Webinar | 45000.00 | 2024-02-10 | active | |
| 3 | Finance Retargeting | 50000.00 | 2024-03-12 | active | |
| 4 | Enterprise Search | google_ads | 60000.00 | 2024-04-01 | active |
Every column above already has a type: `spend` is a decimal number, `start_date` is a date, and `status` is text. The type makes `spend > 50000` a numeric comparison and makes `ORDER BY start_date` sort chronologically rather than alphabetically.
Sign up free to try it on a real business scenario