Numeric
MySQL Data Type: Numeric
Numeric Type
Integer
Type | Size | Description |
---|---|---|
TINYINT | 1 byte | Allows signed integers -128 to 127 and 0 to 255 unsigned integers |
SMALLINT | 2 byte | Allows signed integers from -32768 to 32767 and 0 to 65535 unsigned integers |
MEDIUMINT | 3 byte | Allows signed integers from -8388608 to 8388607 and 0 to 16777215 unsigned integers |
INT | 4 byte | Allows signed integers from -2147483638 to 214747483637 and 0 to 4294967925 unsigned integers |
BIGINT | 8 byte | Allows signed integers from -9223372036854775808 to 9223372036854775807 and 0 to 18446744073709551615 unsigned integers |
Decimal
Type | Size | Description |
---|---|---|
FLOAT(size, after decimal point) | 4 byte | Allows small numbers with floating decimal point |
DOUBLE(size, after decimal point) | 8 byte | Allows large numbers with floating decimal point |
DECIMAL(size, after decimal point) | Varies | Allows storing DOUBLE as a string |
Approximate Value FLOAT(M,D)
- M: values can be stored with up to
M digits
in total - D:
D digits
may beafter the decimal point
Example | Result |
---|---|
FLOAT(7,4) | -999.9999 |
Reference
- MySQL :: MySQL 8.0 Reference Manual :: 11.1 Numeric Data Types
- MySQL Data Type: An Overview of the Data Types in MySQL - DZone Database
- MySQL :: MySQL 8.0 Reference Manual :: 11.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE
- MySQL :: MySQL 8.0 Reference Manual :: 11.7 Data Type Storage Requirements