Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Tuesday, 6 February 2024

MariaDB Data Types: A Comprehensive Guide

MariaDB, a popular open-source relational database management system (RDBMS), offers a wide range of data types to accommodate different types of data and optimize storage efficiency and performance. Here's a comprehensive guide to the data types supported by MariaDB:


 Numeric Data Types:

1. TINYINT: Range: -128 to 127 (signed), 0 to 255 (unsigned). Storage: 1 byte.

2. SMALLINT: Range: -32,768 to 32,767 (signed), 0 to 65,535 (unsigned). Storage: 2 bytes.

3. MEDIUMINT: Range: -8,388,608 to 8,388,607 (signed), 0 to 16,777,215 (unsigned). Storage: 3 bytes.

4. INT: Range: -2^31 to 2^31-1 (signed), 0 to 2^32-1 (unsigned). Storage: 4 bytes.

5. BIGINT: Range: -2^63 to 2^63-1 (signed), 0 to 2^64-1 (unsigned). Storage: 8 bytes.

6. FLOAT: Single-precision floating-point number. Storage: 4 bytes.

7. DOUBLE: Double-precision floating-point number. Storage: 8 bytes.

8. DECIMAL: Fixed-point exact numeric, precise up to 65 digits in total. Storage: Varies.


 String Data Types:

1. CHAR: Fixed-length string. Storage: Defined length up to 255 bytes.

2. VARCHAR: Variable-length string. Storage: Length + 1 or 2 bytes.

3. BINARY: Fixed-length binary string. Storage: Defined length up to 255 bytes.

4. VARBINARY: Variable-length binary string. Storage: Length + 1 or 2 bytes.

5. TINYBLOB: Tiny binary large object. Storage: Up to 255 bytes.

6. BLOB: Binary large object. Storage: Up to 65,535 bytes.

7. MEDIUMBLOB: Medium binary large object. Storage: Up to 16,777,215 bytes.

8. LONGBLOB: Long binary large object. Storage: Up to 4,294,967,295 bytes.

9. TINYTEXT: Tiny text. Storage: Up to 255 bytes.

10. TEXT: Text. Storage: Up to 65,535 bytes.

11. MEDIUMTEXT: Medium text. Storage: Up to 16,777,215 bytes.

12. LONGTEXT: Long text. Storage: Up to 4,294,967,295 bytes.

13. ENUM: Enumeration. Storage: 1 or 2 bytes, depending on the number of enumeration values.

14. SET: Set of strings. Storage: 1, 2, 3, 4, or 8 bytes, depending on the number of set members.


 Date and Time Data Types:

1. DATE: Date in the format 'YYYY-MM-DD'. Storage: 3 bytes.

2. TIME: Time in the format 'HH:MM:SS'. Storage: 3 bytes.

3. DATETIME: Date and time combination in the format 'YYYY-MM-DD HH:MM:SS'. Storage: 8 bytes.

4. TIMESTAMP: Timestamp. Storage: 4 bytes.

5. YEAR: Year in the format 'YYYY' or 'YY'. Storage: 1 byte.


 Other Data Types:

1. BOOL or BOOLEAN: Synonyms for TINYINT(1), representing boolean values.

2. BIT: Fixed-length bit string. Storage: Defined length, rounded up to the nearest byte.

3. GEOMETRY: Spatial data type for storing geometric objects.


 JSON Data Types:

1. JSON: JSON data type for storing JSON (JavaScript Object Notation) documents.


 Spatial Data Types:

1. GEOMETRY: Spatial data type for storing geometric objects.

2. POINT: Represents a single point in a two-dimensional space.

3. LINESTRING: Represents a sequence of points that form a line.

4. POLYGON: Represents a closed polygon.

5. GEOMETRYCOLLECTION: Collection of geometric objects of any type.


 Virtual and Persistent Data Types:

1. VIRTUAL: Computed or generated columns.

2. PERSISTENT: Storage engines that support persistent columns.


 Special Data Types:

1. ENUM: Enumeration, a string object that can have only one value, chosen from a list of possible values.

2. SET: A string object that can have zero or more values, chosen from a list of possible values.


 Binary Data Types:

1. BINARY: Fixed-length binary string.

2. VARBINARY: Variable-length binary string.

3. BLOB: Binary large object.

4. TINYBLOB: Tiny binary large object.

5. MEDIUMBLOB: Medium binary large object.

6. LONGBLOB: Long binary large object.


 JSON Data Types:

1. JSON: JSON data type for storing JSON (JavaScript Object Notation) documents.


 Spatial Data Types:

1. GEOMETRY: Spatial data type for storing geometric objects.

2. POINT: Represents a single point in a two-dimensional space.

3. LINESTRING: Represents a sequence of points that form a line.

4. POLYGON: Represents a closed polygon.

5. GEOMETRYCOLLECTION: Collection of geometric objects of any type.


 Virtual and Persistent Data Types:

1. VIRTUAL: Computed or generated columns.

2. PERSISTENT: Storage engines that support persistent columns.


 Special Data Types:

1. ENUM: Enumeration, a string object that can have only one value, chosen from a list of possible values.

2. SET: A string object that can have zero or more values, chosen from a list of possible values.


These data types offer flexibility and efficiency in storing and manipulating data within MariaDB databases. When choosing data types, it's essential to consider factors such as storage requirements, data precision, and performance implications.

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.