Absolutely! Let’s go through database data types. I’ll focus on the common ones used in SQL databases like MySQL, PostgreSQL, and SQL Server.
| Type | Description | Example |
|---|---|---|
INT / INTEGER |
Whole numbers | 0, 10, -5 |
BIGINT |
Large whole numbers | 1234567890 |
SMALLINT |
Smaller range integer | 100, -50 |
DECIMAL(p, s) / NUMERIC(p, s) |
Exact decimal numbers; p = precision, s = scale |
10.50, 123.45 |
FLOAT / REAL |
Approximate floating-point numbers | 3.14, 2.718 |
DOUBLE |
Double-precision floating-point | 3.1415926535 |
| Type | Description | Example |
|---|---|---|
CHAR(n) |
Fixed-length string, padded with spaces | 'ABC ' (length 5) |
VARCHAR(n) |
Variable-length string | 'Hello', 'Database' |
TEXT / CLOB |
Large text data | 'Lorem ipsum...' |
| Type | Description | Example |
|---|---|---|
DATE |
Stores date only (YYYY-MM-DD) | '2025-08-28' |
TIME |
Stores time only (HH:MM:SS) | '14:30:00' |
DATETIME / TIMESTAMP |
Stores date and time | '2025-08-28 14:30:00' |
YEAR |
Stores year | 2025 |
| Type | Description | Example |
|---|---|---|
BOOLEAN / BOOL |
True or False | TRUE, FALSE |
BIT |
Stores 0 or 1 | 0, 1 |
| Type | Description | Example |
|---|---|---|
BLOB |
Binary Large Object (images, files) | image data |
BINARY(n) |
Fixed-length binary | 10101010 |
VARBINARY(n) |
Variable-length binary | file bytes |
ENUM – Predefined list of values
CREATE TABLE Shirt (size ENUM('S','M','L','XL'));
JSON / JSONB – Store JSON objects (PostgreSQL, MySQL)
CREATE TABLE Data (info JSON);