Data types include integer, floating-point and fixed-point type type, date and time, strings and binary type.
First, the integer type
MySQL's integer types are divided into five kinds: TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT .
Of different integer number of bytes occupied by the type and value ranges are different. As shown below:
Second, floating-point and fixed-point type
In MySQL, it is stored using decimal floating-point and fixed-point represented.
There are two types of float: single precision floating point type ( FLOAT ), double precision floating point type ( DOUBLE ).
Only one kind of fixed-point type: DECIMAL type.
And the number of bytes occupied FIG following ranges:
Note: the same type of value ranges --DECIMAL DOUBLE type.
- Note that the effective range of DECIMAL type is determined by M and D.
- where, M is the length of the data, D represents the length after the decimal point.
Third, the time and date type
The date and time stored in the database, MySQL provides a data type represents dates and times: YEAR, DATE, the TIME, DATETIME, TIMESTAMP
Below lists the number of bytes in the MySQL date and time data corresponding to the type, range, date formats, and a zero value.
Note: If the inserted value is not valid, the system will automatically zero value into the corresponding database.
Types of | The number of bytes (size) | use |
CHAR | 0-255 bytes | Fixed length byte character |
VARCHAR | 0-65535 bytes | Variable length byte character |
BLOB | 0-65535 bytes | Long text data in binary form |
TINYBLOB | 0-255 bytes | No more than 255 characters in binary string |
MEDIUMBLOB | 0-16777215 bytes | Binary text data in the form of medium length |
LONGBLOB | 0-4294967295 bytes | Great text data in binary form |
TEXT | 0-65535 bytes | Long text data |
TINYTEXT | 0-255 bytes | Short text strings |
MEDIUMTEXT | 0-16777215 bytes | Medium length text data |
LONGTEXT | 0-4294967295 bytes | Great text data |
BINARY and VARBINARY type is similar to CHAR and VARCHAR, except that they contain binary strings rather than non-binary strings. That is, they contain byte strings rather than character strings.
A BLOB is a binary large object, can hold a variable amount of data. There are four BLOB types: TINYBLOB, BLOB, MEDIUMBLOB and LONGBLOB. They differ only in length can accommodate the maximum values.
TEXT There are four types: TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT. These types correspond to four kinds of BLOB, the maximum length and have the same storage requirements.