MariaDB Data Types

Following is a list of data types in MariaDB:

  • String data types
  • Numeric data types
  • Date/time data types
  • Large object data types

String Data Types

data type syntaxmaximum sizeexplanation
char(size)maximum size of 255 characters.where size is the number of characters to store. fixed-length strings. space padded on right to equal size characters.
varchar(size)maximum size of 255 characters.where size is the number of characters to store. variable-length string.
tinytext(size)maximum size of 255 characters.where size is the number of characters to store.
text(size)maximum size of 65,535 characters.where size is the number of characters to store.
mediumtext(size)maximum size of 16,777,215 characters.where size is the number of characters to store.
longtext(size)maximum size of 4gb or 4,294,967,295 characters.where size is the number of characters to store.
binary(size)maximum size of 255 characters.where size is the number of binary characters to store. fixed-length strings. space padded on right to equal size characters.
varbinary(size)maximum size of 255 characters.where size is the number of characters to store. variable-length string.

Date/Time Data Types

data type syntaxmaximum sizeexplanation
datevalues range from '1000-01-01' to '9999-12-31'.displayed as 'yyyy-mm-dd'.
datetimevalues range from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.displayed as 'yyyy-mm-dd hh:mm:ss'.
timestamp(m)values range from '1970-01-01 00:00:01' utc to '2038-01-19 03:14:07' utc.displayed as 'yyyy-mm-dd hh:mm:ss'.
timevalues range from '-838:59:59' to '838:59:59'.displayed as 'hh:mm:ss'.
year[(2|4)]year value as 2 digits or 4 digits.default is 4 digits.

Numeric Data Types

data type syntaxmaximum size
bitvery small integer value that is equivalent to tinyint(1).
signed values range from -128 to 127. unsigned values range from 0 to 255.
tinyint(m)very small integer value.
signed values range from -128 to 127. unsigned values range from 0 to 255.
smallint(m)small integer value.
signed values range from -32768 to 32767. unsigned values range from 0 to 65535.
mediumint(m)medium integer value.
signed values range from -8388608 to 8388607. unsigned values range from 0 to 16777215.
int(m)standard integer value.
signed values range from -2147483648 to 2147483647. unsigned values range from 0 to 4294967295.
integer(m)standard integer value.
signed values range from -2147483648 to 2147483647. unsigned values range from 0 to 4294967295.
bigint(m)big integer value.
signed values range from -9223372036854775808 to 9223372036854775807. unsigned values range from 0 to 18446744073709551615.
decimal(m,d)unpacked fixed point number.
m defaults to 10, if not specified.d defaults to 0, if not specified.
dec(m,d)unpacked fixed point number.
m defaults to 10, if not specified.
d defaults to 0, if not specified.
numeric(m,d)unpacked fixed-point number.
m defaults to 10, if not specified.d defaults to 0, if not specified.
fixed(m,d)unpacked fixed-point number.
m defaults to 10, if not specified.
d defaults to 0, if not specified.
float(m,d)single precision floating point number.
double(m,d)double precision floating point number.
double precision(m,d)double precision floating point number.
real(m,d)double precision floating point number.
float(p)floating point number.
boolsynonym for tinyint(1)
booleansynonym for tinyint(1)

Large Object (LOB) Datatypes

data type syntaxmaximum size
tinyblobmaximum size of 255 bytes.
blob(size)maximum size of 65,535 bytes.
mediumblobmaximum size of 16,777,215 bytes.
longtextmaximum size of 4gb or 4,294,967,295 characters.