SQL Data Types – Choosing the Right Tool for Your Data

(because age ain’t text, and names aren’t numbers)

Let’s say we’re building a users table like this:

id name email age balance signup_date is_active
1Oliviaolivia@email.com2699.502024-09-20TRUE
2Masonmason@mail.com30199.992023-07-12FALSE

You’re planning this table and asking:
“What kind of stuff is going in each column?”

That’s where SQL data types come in. You’re telling the database:

  • This column = text
  • That one = number
  • This other one = date
  • And that = true/false

Based on that, here’s how we’d define the table:

CREATE TABLE users (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(100),
  email VARCHAR(100),
  age INT,
  balance DECIMAL(10,2),
  signup_date DATE,
  is_active BOOLEAN
);

Numeric Data Types

TypeWhat it storesExample
INTWhole numbers1, 42, -10
BIGINTLarge numbers9000000000
FLOATDecimals (approximate)3.14
DECIMAL(p,s)Exact decimals (like money)99.99, 123.45

Use:

  • INT for age, quantity, IDs
  • DECIMAL for money, pricing
  • FLOAT for averages or measurements

Text Data Types

TypeWhat it storesExample
VARCHAR(n)Variable text (max n chars)‘Mason’, ‘Olivia’
CHAR(n)Fixed-length text‘Y’, ‘NY’
TEXTLong textMessages, bios

Use:

  • VARCHAR for names, emails, cities
  • TEXT for comments, articles
  • CHAR for codes (like ‘M’ or ‘F’)

Date & Time Data Types

TypeStores…Example
DATEJust the date‘2025-04-03’
TIMEJust the time’14:30:00′
DATETIMEFull date & time‘2025-04-03 14:30:00’
TIMESTAMPWith time zone stuffUsed in logs

Use:

  • DATE for birthdays, hire dates
  • DATETIME for events, signups
  • TIMESTAMP for time zone-sensitive tracking

Boolean Type

TypeStores…Values
BOOLEAN / BOOLTrue/False1 (TRUE), 0 (FALSE)

Use:

  • is_active, is_deleted, is_verified — anything yes/no

Recap

  • Choose your data types based on the real kind of data you’re storing
  • Use INT for whole numbers, DECIMAL for money
  • VARCHAR for most text, DATE for calendar things
  • BOOLEAN for anything binary (yes/no)

Good data types = cleaner data + faster queries + less stress later

Next up:

Let’s see how you can find (aka filter) specific stuff in your table — like “users over 21” or “all active accounts.”
This is where the WHERE clause comes in. If you want a simple intro to filtering data in SQL, check out this beginner-friendly guide.

I’ll break it down in plain English next!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top