mysql data type <----> java data type (数值)

时间:2022-09-02 10:21:35

https://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html

+----------------------------+----------------------------------------------------+--------------------------------+
| Data Type | Storage Required | Java Type |
+----------------------------+----------------------------------------------------+--------------------------------+
| TINYINT | 1 byte | Byte |
| SMALLINT | 2 bytes | Short |
| MEDIUMINT | 3 bytes | Integer |
| INT, INTEGER | 4 bytes | Integer |
| BIGINT | 8 bytes | Long |
| FLOAT(0-24) | 4 bytes if 0 <= p <= 24 | Float |
| FLOAT(25-53) | 8 bytes if 25 <= p <= 53 | Double |
| FLOAT | 4 bytes | Float |
| DOUBLE(0-8) | 8 bytes | Double |
| REAL | 8 bytes | Double |
| DECIMAL(m,n) | Maximum is 65 for 'm',Maximum is 30 for 'n'. | |
| DECIMAL(1-4,0) | | Short |
| DECIMAL(5-9,0) | | Integer |
| DECIMAL(0,0) | Same as decimal | Long |
| DECIMAL(10-18,0) | | Long |
| DECIMAL(19-65,0) | | BigDecimal |
| DECIMAL(m,1+) | | BigDecimal |
| NUMERIC(m,n) | Same as DECIMAL(m,n) | |
| BIT(n) | approximately (M+7)/8 bytes | Boolean |
+----------------------------+----------------------------------------------------+--------------------------------+