Data Types
int / integer
Stores integer values, whole numbers, no decimal point.
age INTdecimal
Stores floating-point values, and takes two numbers in parentheses to control exactly how: DECIMAL(total digits, digits after the decimal point).
salary DECIMAL(10, 2)DECIMAL(10, 2) means: 10 digits total, and 2 of those are reserved for after the decimal point, leaving 8 for before it. So this column can hold anything up to 99999999.99.
char
Stores character values, at a fixed length. CHAR(20) always takes up 20 characters of storage, a shorter value gets padded with spaces to fill it out.
grade CHAR(2)varchar
Also stores character values, but at a variable length instead, only the actual characters used take up space, no padding. CHAR for values that are always roughly the same length, VARCHAR when the length genuinely varies.
ename VARCHAR(20)char vs varchar, in memory
A common board question, and easiest to see with the same value stored both ways.
name CHAR(10)
name = 'Ram'CHAR(10) reserves all 10 characters of storage the moment the column's defined, no matter what actually gets put in it. Storing 'Ram' fills the first 3 slots and pads the remaining 7 with blank space, R a m _ _ _ _ _ _ _, all 10 slots occupied regardless.
name VARCHAR(10)
name = 'Ram'VARCHAR(10) only reserves what's actually used, plus a little overhead to track the length. Storing 'Ram' here takes up space for R a m, and the remaining 7 characters of "room" are left unused, free to be released rather than sitting padded and wasted.
That difference is the whole trade-off:
CHARoccupies all the memory assigned to it, every time,NOTmemory efficient.VARCHARleaves unused memory space free, memory efficient.CHARhas faster processing, fixed-size slots are simpler for the engine to read and jump between.VARCHAR's processing is slower thanCHAR, the trade for that memory efficiency, the engine has to check the actual stored length every time instead of just reading a fixed-width block.CHARallows a length of0to255,256possible sizes.VARCHARallows a length of0to65535,65536possible sizes, a much wider range, useful when a column's length genuinely can't be predicted ahead of time.
date
Stores a date, in the fixed format YYYY-MM-DD.
dob DATE
-- e.g. 2026-03-20