MySQL Data Types Cheatsheet

String Datatypes

Data Type Max size
CHAR(size) 255 characters.
VARCHAR(size) 65,535 bytes.
TINYTEXT(size) 255 characters.
TEXT(size) 65,535 characters.
MEDIUMTEXT(size) 16,777,215 characters.
LONGTEXT(size) 4GB or 4,294,967,295 characters.
BINARY(size) 255 characters.
VARBINARY(size) 65,535 bytes.

Numeric Datatypes

Data type Description Storage
bit(size) Bit-value type, from 1 to 64 bits about (size + 7) / 8 bytes
tinyint Allows whole numbers from -128 to 127, or 0 to 255 if unsigned 1 byte
smallint Allows whole numbers between -32,768 and 32,767 2 bytes
int Allows whole numbers between -2,147,483,648 and 2,147,483,647 4 bytes
bigint Allows whole numbers between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 8 bytes
decimal(p,s) Exact fixed-point number, up to 65 digits. 4 bytes for every 9 digits
numeric(p,s) The same as decimal. 4 bytes for every 9 digits
mediumint Allows whole numbers between -8,388,608 and 8,388,607 3 bytes
double Double precision floating point number. 8 bytes
float(n) Floating point number. 4 or 8 bytes
real The same as double (or float if the REAL_AS_FLOAT mode is on) 8 bytes

Date datatypes

Data type Description Storage
datetime From 1000-01-01 00:00:00 to 9999-12-31 23:59:59 with an accuracy of up to 1 microsecond 5-8 bytes
date Store a date only. From 1000-01-01 to 9999-12-31 3 bytes
time Store a time only, from -838:59:59 to 838:59:59 with an accuracy of up to 1 microsecond 3-6 bytes
year Store a 4-digit year, from 1901 to 2155 1 byte
timestamp From 1970-01-01 00:00:01 UTC to 2038-01-19 03:14:07 UTC. It can be updated automatically every time a row gets created or modified 4-7 bytes

Large Datatypes

Data type Description
tinyblob Stores up to 255 bytes of binary data
blob Stores up to 65,535 bytes of binary data
mediumblob Stores up to 16,777,215 bytes of binary data
longblob Stores up to 4GB of binary data
json Stores JSON documents

TablePlus is a native client for MySQL, PostgreSQL, SQLite, Microsoft SQL Server, and other databases. You can keep several databases open at once.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS.

TablePlus GUI Tool MySQL

← All posts