What are the different data types in MariaDB?

The primary difference between the various data types in MariaDB is the values they can hold and, as a result, their size.

Which data types does MariaDB have?

MariaDB can store and map different types of data. Before you create a new database in MariaDB and fill it with tables using MariaDB’s CREATE TABLE statement, you should consider which data types are useful. These differ not only in terms of their possible values, but also in their size. Data types in MariaDB can be roughly divided into five categories: numeric, date and time, strings, geometry and other miscellaneous data types that stand on their own.

Managed Databases
Time-saving database services
  • Enterprise-grade architecture managed by experts
  • Flexible solutions tailored to your requirements
  • Hosted in the UK under strict data protection legislation

Numeric data types

Data type Description
TINYINT Whole numbers from -128 to 127
SMALLINT Whole numbers from -32768 to 32767
MEDIUMINT Whole numbers from -8388608 to 8388607
INT Whole numbers from -2147483648 to 2147483647
BIGINT Whole numbers from -9223372036854775808 to 9223372036854775807
BOOLEAN The Boolean values ‘true’ or ‘false’; synonym for TINYINT(1)
DECIMAL Decimal numbers with up to 65 digits
FLOAT Floating point numbers between -3.402823466E+38 and -1.175494351E-38, 1.175494351E-38 and 3.402823466E+38 or with the value 0
DOUBLE Floating point numbers between -1.7976931348623157E+308 and -2.2250738585072014E-308, 2.2250738585072014E-308 to 1.7976931348623157E+308 or with the value 0
BIT A bit

Date and time data types

Data type Description
DATE The date format is YYYY-MM-DD with a range from 1000-01-01 to 9999-12-31
TIME Time specification in the range from -838:59:59.999999 to 838:59:59.999999
DATETIME Time specification in the format YYYY-MM-DD HH:MM with a range from 1000-01-01 00:00:00.000000 to 9999-12-31 23:59:59.999999
TIMESTAMP Timestamp in the format YYYY-MM-DD HH:MM; also supports microseconds
YEAR Four-digit year specification with a range from 1901 to 2155 and the option 0000

Strings

In MariaDB, data types from the string category can contain different sequences of text, binary data and other files.

Data type Description
CHAR A string that contains characters based on ASCII codes ranging from 0 to 255
VARCHAR A string with a range from 0 to 65,535
BINARY Binary data
VARBINARY A variable-length binary string
TINYBLOB A small binary object up to 255 bytes
BLOB A binary object up to 65,535 bytes
MEDIUMBLOB A medium-sized binary object up to 16,777,215 bytes
LONGBLOB A large binary object up to 4,294,967,295 bytes
TINYTEXT A sequence of up to 255 characters
TEXT A sequence of up to 65,535 characters
MEDIUMTEXT A sequence of up to 16,777,215 characters
LONGTEXT A sequence of up to 4,294,967,295 characters
ENUM An enumeration type
SET A string with distinct values

Geometry data types

Data type Description
GEOMETRY A geometric value
POINT A point on the X and Y coordinates
LINESTRING A curve consisting of one or more points
POLYGON A polygon
GEOMETRYCOLLECTION A collection of multiple GEOMETRY values
MULTILINESTRING Multiple LINESTRING values
MULTIPOINT Multiple POINT values
MULTIPOLYGON Multiple POLYGON values

Miscellaneous data types in MariaDB

Data type Description
AUTO_INCREMENT Automatically fills a new field with the next higher count value; not an independent data type
NULL An empty field; not an independent data type
Tip

You can find out more about MariaDB in our Digital Guide. Among other things, we compare MariaDB and MySQL and explain how to install MariaDB.

Was this article helpful?
Page top