Data Types in MariaDB
Data Type is the set of quantities that belong to a similar category. Data Types are the fundamental concept in computer science and database management. MariaDB supports a variety of data types that allow us to define the nature of the data that can be stored in each column of a table.
Each programming language and database management device has its own set of data types, and those kinds determine the character of operations that may be achieved on the data, the quantity of memory required to save the information, and the limitations of the data.
1. Numeric Data Types
Different kinds of numeric data types are supported by MariaDB. The provided numeric data types are as follows:
Data Types |
Range |
Description |
---|---|---|
TINYINT |
0 and 255 (unsigned) or -128 and 127 (signed). |
These are the 1-byte integers. |
SMALLINT |
-32768 to 32768 (signed) or 0 to 65535 (unsigned). |
These are the 2-byte integers. |
MEDIUMINT |
0 to 16777215 (unsigned) or -8388608 to 8388607 (signed). |
These are the 3-byte integers. |
INT |
-2147483648 to 2147483647 (signed) or 0 to 4294967295 (unsigned). |
This is the 4-byte standard integer. |
BIGINT |
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (signed) or 0 to 18,446,744,073,709,551,615 (unsigned). |
These are the 8-byte large integers. |
FLOAT |
Not defined |
32-bit single-precision floating point numbers are represented in this data type. |
DOUBLE |
Not defined |
Stores double-precision floating point numbers. This data type occupies 64 bits in memory. |
DECIMAL |
Not defined |
These are used for storing fixed-point numbers. It is specified with two parameters M and D, where M is the total number of digits and D is the number of digits after decimal point. |
BIT |
Not defined |
Used for storing bit sequence, which are sequences of binary digits. |
2. String Data Types
Some of the string data types are given below:
DATA TYPES |
Maximum Size |
DESCRIPTION |
---|---|---|
CHAR |
255 characters |
This is a fixed length string data type. Its default value is 1. |
VARCHAR |
255 characters |
This is a variable length string data type. It can contain letters, number and special characters. |
BINARY |
255 characters |
This is equal to CHAR data type but stores fixed length binary byte strings. It’s default value is 1. |
VARBINARY |
255 characters |
This is equal to VARCHAR but stores variable length binary byte strings. |
TINYBLOB |
255 characters |
BLOB stands for Binary Large Objects. It is variable-length binary string with a maximum length of size. |
BLOB |
65,535 characters |
It is also a variable-length binary string with a maximum length of size. |
MEDIUMBLOB |
16,777,215 characters |
It is also a variable-length binary string with a maximum length of size. |
LONGBLOB |
4,294,967,295 characters |
It is also a variable-length binary string with a maximum length of size. |
TINYTEXT |
255 characters |
This data type represents the variable-length string with a maximum length of size. |
TEXT |
65,535 characters |
This data type represents the variable-length string with a maximum length of size. |
MEDIUMTEXT |
16,777,215 characters |
It represents the variable-length string with a maximum length of size. |
LONGTEXT |
4,294,967,295 characters |
This data type represents the variable-length string with a maximum length of size. |
ENUM |
varies |
It is used to store a set of predefined values. |
SET |
varies |
It is also similar to ENUM data type but allows for multiple values to be selected. |
3. Date and Time Data Types
Also known as Temporal data types.
DATA TYPES |
Range |
Format |
---|---|---|
DATE |
1000-01-01 to 9999-12-31 |
YYYY-MM-DD |
TIME |
-838:59:59 to 838:59:59 |
HH:MM:SS |
DATETIME |
1000-01-01 00:00:00 to 9999-12-31 23:59:59 |
YYYY-MM-DD HH:MM:SS |
TIMESTAMP |
1970-01-01 00:00:01 UTC to 2038-01-19 03:14:07 UTC |
YYYY-MM-DD HH:MM:SS |
YEAR |
2 0r 4 digit |
4 digit format. |
4. Spatial Data Types
DATA TYPES |
DESCRIPTION |
---|---|
GEOMETRY |
This data type represents various geometric shapes like points, lines and polygons. |
POINT |
This data type represents a single point. |
LINESTRING |
Represents a sequence of connected line segments. |
POLYGON |
Represents a closed shape with a series of connected linear rings. |
MULTIPOINT |
Represents a collection of points. |
MULTILINESTRING |
Represents a collection of line strings. |
MULTIPOLYGON |
This data type represents a collection of polygons. |
GEOMETRYCOLLECTION |
Represents a collection of geometric objects of different types. |
MariaDB Data Types
MariaDB is an open-source software It has implemented various performance improvements over MySQL. It includes various enhancements such as the Aria storage engine, the Thread Pool feature, and the MaxScale proxy, all of which provide better performance and scalability. MariaDB has a large number of users and contributors to support and solve doubts and so on.
In this article, we will talk about the various data types that MariaDB supports and their uses. These data types provide flexibility for storing various types of information in a MariaDB database.