Data type mainly defines which type of data object can hold. The data type property is very important for optimizing the database. That means, As per our requirement, only those types and sizes of fields we will use. Like if our requirement is only 5 characters, then we will not use 10 character data type field.
There are following categories of data type:-
- Numeric data type:- MySQL supports all standard SQL numeric data types Like- BIT, TINYINT, BOOL, BOOLEAN, SMALLINT, MEDIUMINT, INT, INTEGER, BIGINT, FLOAT(M, D), DOUBLE(M, D), DOUBLE PRECISION(M, D), DECIMAL(M, D), DEC
All the numeric data types may have some extra options like- UNSIGNED OR ZEROFILL.
If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column.
ZEROFILL deprecated from MySQL version 8.0.17
UNSIGNED deprecated from MySQL version 8.0.17 for a column of type FLOAT, DOUBLE, and DECIMAL.
- Date and Time:- The date and time data types for representing temporal values are DATE, TIME, DATETIME, TIMESTAMP, and YEAR. Date and time data types are:-DATE, DATETIME, TIMESTAMP, TIME, YEAR.
- String Data Type:- The string data types are CHAR, VARCHAR, BINARY, VARBINARY, BLOB, TEXT, ENUM, and SET.