This article brings you a detailed summary of Mysql data types. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Before data storage, let’s first understand the data types of mysql. What is the data type? The data type refers to the column; the data characteristics of parameters, expressions and local variables in the stored procedure, which determines the way the data is stored and represents different information types. (Recommended course: MySQL Tutorial)
Integer type:
Integer type often refers to integer, but in integer type it can be There are 5 types, TINYNIT, SMALLINT, MEDIUMINT, INT, BIGINT.
Type | Storage range | Occupied bytes |
---|---|---|
TINYINT | Signed values: -128 to 127 (-2^7 to 2^7-1) Unsigned values: 0 to 255 (0 to 2^8-1) | 1 |
SMALLINT | Signed value: -32768 to 32767 (-2^15 to 2^15-1) Unsigned value: 0 to 65535 (0 to 2^16-1) |
2 |
MEDIUMINT | Signed values: -8388608 to 8388607 (-2^ 23 to 2^23-1) Unsigned value: 0 to 16777215 (2^24-1) |
3 |
INT | Signed value: -2147483648 to 2147483647 (-2^31 to 2^31-1) Unsigned value: 0 to 4294967295 (2^32-1) |
4 |
BIGINT | Signed values: -9223372036854775808 to 9223372036854775807 (-2^63 to 2^63-1) Unsigned values: 0 to 18446744073709551615 (2^64-1 ) |
8 |
Floating point numbers
Floating point numbers often refer to numbers with decimals. Two types, FLOAT single-precision floating-point number, DOUBLE double-precision floating-point number. Double-precision floating-point numbers are ten times more accurate than single-precision floating-point numbers, but they take up more memory.
Type | Storage Range |
---|---|
-3.402823466E 38 to -1.175494351E-38, 0 and 1.175494351E-38 to 3.402823466E 38 M represents the total number of digits, and D represents the number of digits after the decimal point. If M and D are omitted, the value is saved according to the limitations allowed by the hardware. Single-precision floating point numbers are accurate to approximately 7 decimal places. |
|
-1.7976931348623157E 308 to -2.2250738585072014E-308, 0 and 2.2250738585072014E-308 to 1.7976931348623157 E 308 | M represents the total number of digits, and D represents the number of digits after the decimal point. If M and D are omitted, the value is saved according to the limitations allowed by the hardware. Single-precision floating point numbers are accurate to approximately 7 decimal places. |
Character type is a very commonly used type, such as string. Character type has 8 types.
Storage Range | |
---|---|
VARCHAR(M) | |
TINYTEXT | |
TEXT | |
MIUDMTEXT | |
##LONGTEXT | |
##ENUM('val', 'val') | 1 or 2 bytes, depending on the number of enumerations (up to 65535 values) |
SET('val','val' ,'val') | 1,2,3,4 or 8 bytes, depending on the number of set members (up to 64) |
In this section we first understand the data types of mysql, and in the next section we learn how to create a data table. |
The above is the detailed content of Detailed summary of Mysql data types. For more information, please follow other related articles on the PHP Chinese website!