Skip to content

MySQL / MariaDB Data Types

Most commonly used data types in MySQL and MariaDB

Numeric Data Types

Integer Types

Used for whole numbers.

TypeSizeRange (Signed)Typical Use
TINYINT1 byte-128 to 127Flags, booleans (0/1)
SMALLINT2 bytes-32,768 to 32,767Small counters
MEDIUMINT3 bytes-8,388,608 to 8,388,607Rarely used
INT4 bytes-2,147,483,648 to 2,147,483,647Default integer
BIGINT8 bytesVery largeIDs, large counters

TIP

  • UNSIGNED doubles the positive range.
  • INT is the most common choice.
  • BIGINT is typical for primary keys in large systems.

Floating Point Types

Used for approximate numeric values.

TypeDescriptionTypical Use
FLOAT32-bitScientific data
DOUBLE64-bitCalculations needing more precision

TIP

  • Not exact. Avoid for money.

Fixed-Point (Exact) Types

Used when precision matters.

TypeDescriptionTypical Use
DECIMAL(p,s)Exact number with precisionMoney, financial data

Example:

sql
DECIMAL(10,2)

String (Text) Data Types

Character Types

TypeDescriptionTypical Use
CHAR(n)Fixed-length stringCodes, ISO values
VARCHAR(n)Variable-length stringNames, emails

Text Types

TypeMax Size
TINYTEXT255 bytes
TEXT64 KB
MEDIUMTEXT16 MB
LONGTEXT4 GB

Date and Time Data Types

TypeDescriptionTypical Use
DATEDate onlyBirthdays
TIMETime onlyDurations
DATETIMEDate and timeEvents
TIMESTAMPUnix-based datetimeAudit fields
YEARYearRare

Boolean

TypeDescription
BOOLEAN / BOOLAlias for TINYINT(1)

Binary Data Types

TypeDescription
BINARY(n)Fixed-length binary
VARBINARY(n)Variable-length binary
BLOBBinary large object

ENUM and SET

ENUM

sql
ENUM('draft', 'published', 'archived')

SET

sql
SET('read', 'write', 'execute')

JSON

TypeDescription
JSONStructured JSON data

Most Common Choices

PurposeRecommended Type
Primary keyBIGINT / INT UNSIGNED
Text fieldsVARCHAR
Long textTEXT
MoneyDECIMAL
BooleanTINYINT(1)
TimestampsDATETIME / TIMESTAMP
JSON dataJSON

More about data types

Lapland University of Applied Sciences

© 2026 Juha Petäjäjärvi

© 2026 Juha Petäjäjärvi