MariaDB Data Types

Summaryin this tutorial, you will learn about MariaDB data types and how to use them effectively for designing a table.

Before designing a database in MariaDB, you should consider the available data types so that you can select the most optimal ones for storing data. MariaDB provides you with many data types including:

  • Numeric data types
  • String data types
  • Temporal data types
  • Spatial data types

Each data type has the following properties:

  • The value that it can present.
  • The storage size
  • The values can be indexed or not.
  • How values can be compared.

MariaDB numeric data types

MariaDB supports many kinds of numeric types including the exact and approximate numeric data types. The following table shows the summary of numeric types supported by MariaDB:

Numeric TypesDescription
 TINYINTA very small integer
 SMALLINTA small integer
 MEDIUMINTA medium-sized integer
 INTA standard integer
 BIGINTA large integer
 DECIMALA fixed-point number
 FLOATA single-precision floating-point number
 DOUBLEA double-precision floating-point number
 BITA bit

MariaDB Boolean data type

MariaDB uses the TINYINT(1) to represent Boolean values. In MariaDB, zero (0) means false and non-zero means true. The BOOLEAN and BOOL are the synonym of TINYINT(1).

MariaDB string data types

MariaDB string types can hold any string data including plain text, binary data, and even contents of files. The following table displays string data types in MariaDB:

String TypesDescription
 CHARA fixed-length nonbinary (character) string
 VARCHARA variable-length non-binary string
 BINARYA fixed-length binary string
 VARBINARYA variable-length binary string
 TINYBLOBA very small BLOB (binary large object)
 BLOBA small BLOB
 MEDIUMBLOBA medium-sized BLOB
 LONGBLOBA large BLOB
 TINYTEXTA very small non-binary string
 TEXTA small non-binary string
 MEDIUMTEXTA medium-sized non-binary string
 LONGTEXTA large non-binary string
 ENUMAn enumeration
 SETA set

MariaDB temporal types

MySQL temporal types including types that represent a date without time, a time without date, a datetime, a timestamp, and year. This table shows the MariaDB temporal data types:

Temporal Data TypesDescription
 DATEA date value in CCYY-MM-DD format
 TIMEA time value in hh:mm:ss format
 DATETIMEA date and time value inCCYY-MM-DD hh:mm:ssformat
 TIMESTAMPA timestamp value in CCYY-MM-DD hh:mm:ss format
 YEARA year value in CCYY or YY format

MariaDB spatial data types

MariaDB supports many spatial data types that contain various kinds of geographical values

Spatial Data TypesDescription
 GEOMETRYA spatial value of any type
 POINTA point (a pair of X-Y coordinates)
 LINESTRINGA curve (one or more POINT values)
 POLYGONA polygon
 GEOMETRYCOLLECTIONA collection of GEOMETRY values
 MULTILINESTRINGA collection of LINESTRINGvalues
 MULTIPOINTA collection of POINT values
 MULTIPOLYGONA collection of POLYGONvalues

In this tutorial, you have learned various MariaDB data types including numeric, string, spatial data types,

Was this tutorial helpful ?