mysql jdbc说明 https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html
Table 6.1 Possible Conversions Between MySQL and Java Data Types
| These MySQL Data Types | Can always be converted to these Java types |
|---|---|
CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET | java.lang.String, java.io.InputStream, java.io.Reader, java.sql.Blob, java.sql.Clob |
FLOAT, REAL, DOUBLE PRECISION, NUMERIC, DECIMAL, TINYINT, SMALLINT, MEDIUMINT, INTEGER, BIGINT | java.lang.String, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Double, java.math.BigDecimal |
DATE, TIME, DATETIME, TIMESTAMP | java.lang.String, java.sql.Date, java.sql.Timestamp |
Table 6.2 MySQL Types and Return Values for ResultSetMetaData.GetColumnTypeName()and ResultSetMetaData.GetColumnClassName()
| MySQL Type Name | Return value of GetColumnTypeName | Return value of GetColumnClassName |
|---|---|---|
BIT(1) | BIT | java.lang.Boolean |
BIT( > 1) | BIT | byte[] |
TINYINT | TINYINT | java.lang.Boolean if the configuration property tinyInt1isBit is set to true (the default) and the storage size is 1, or java.lang.Integer if not. |
BOOL, BOOLEAN | TINYINT | See TINYINT, above as these are aliases for TINYINT(1), currently. |
SMALLINT[(M)] [UNSIGNED] | SMALLINT [UNSIGNED] | java.lang.Integer (regardless of whether it is UNSIGNED or not) |
MEDIUMINT[(M)] [UNSIGNED] | MEDIUMINT [UNSIGNED] | java.lang.Integer (regardless of whether it is UNSIGNED or not) |
INT,INTEGER[(M)] [UNSIGNED] | INTEGER [UNSIGNED] | java.lang.Integer, if UNSIGNED java.lang.Long |
BIGINT[(M)] [UNSIGNED] | BIGINT [UNSIGNED] | java.lang.Long, if UNSIGNED java.math.BigInteger |
FLOAT[(M,D)] | FLOAT | java.lang.Float |
DOUBLE[(M,B)] | DOUBLE | java.lang.Double |
DECIMAL[(M[,D])] | DECIMAL | java.math.BigDecimal |
DATE | DATE | java.sql.Date |
DATETIME | DATETIME | java.sql.Timestamp |
TIMESTAMP[(M)] | TIMESTAMP | java.sql.Timestamp |
TIME | TIME | java.sql.Time |
YEAR[(2|4)] | YEAR | If yearIsDateType configuration property is set to false, then the returned object type is java.sql.Short. If set totrue (the default), then the returned object is of type java.sql.Date with the date set to January 1st, at midnight. |
CHAR(M) | CHAR | java.lang.String (unless the character set for the column is BINARY, then byte[] is returned. |
VARCHAR(M) [BINARY] | VARCHAR | java.lang.String (unless the character set for the column is BINARY, then byte[] is returned. |
BINARY(M) | BINARY | byte[] |
VARBINARY(M) | VARBINARY | byte[] |
TINYBLOB | TINYBLOB | byte[] |
TINYTEXT | VARCHAR | java.lang.String |
BLOB | BLOB | byte[] |
TEXT | VARCHAR | java.lang.String |
MEDIUMBLOB | MEDIUMBLOB | byte[] |
MEDIUMTEXT | VARCHAR | java.lang.String |
LONGBLOB | LONGBLOB | byte[] |
LONGTEXT | VARCHAR | java.lang.String |
ENUM('value1','value2',...) | CHAR | java.lang.String |
SET('value1','value2',...) | CHAR | java.lang.String |
各类型的范围,文章写的太好了直接搬运。
https://www.cnblogs.com/-xlp/p/8617760.html
各数据类型及字节长度一览表:
| 数据类型 | 字节长度 | 范围或用法 |
|---|---|---|
| Bit | 1 | 无符号[0,255],有符号[-128,127],天缘博客备注:BIT和BOOL布尔型都占用1字节 |
| TinyInt | 1 | 整数[0,255] |
| SmallInt | 2 | 无符号[0,65535],有符号[-32768,32767] |
| MediumInt | 3 | 无符号[0,224-1],有符号[-223,2^23-1]] |
| Int | 4 | 无符号[0,232-1],有符号[-231,2^31-1] |
| BigInt | 8 | 无符号[0,264-1],有符号[-263 ,2^63 -1] |
| Float(M,D) | 4 | 单精度浮点数。天缘博客提醒这里的D是精度,如果D<=24则为默认的FLOAT,如果D>24则会自动被转换为DOUBLE型。 |
| Double(M,D) | 8 | 双精度浮点。 |
| Decimal(M,D) | M+1或M+2 | 未打包的浮点数,用法类似于FLOAT和DOUBLE,天缘博客提醒您如果在ASP中使用到Decimal数据类型,直接从数据库读出来的Decimal可能需要先转换成Float或Double类型后再进行运算。 |
| Date | 3 | 以YYYY-MM-DD的格式显示,比如:2009-07-19 |
| Date Time | 8 | 以YYYY-MM-DD HH:MM:SS的格式显示,比如:2009-07-19 11:22:30 |
| TimeStamp | 4 | 以YYYY-MM-DD的格式显示,比如:2009-07-19 |
| Time | 3 | 以HH:MM:SS的格式显示。比如:11:22:30 |
| Year | 1 | 以YYYY的格式显示。比如:2009 |
| Char(M) | M | 定长字符串。 |
| VarChar(M) | M | 变长字符串,要求M<=255 |
| Binary(M) | M | 类似Char的二进制存储,特点是插入定长不足补0 |
| VarBinary(M) | M | 类似VarChar的变长二进制存储,特点是定长不补0 |
| Tiny Text | Max:255 | 大小写不敏感 |
| Text | Max:64K | 大小写不敏感 |
| Medium Text | Max:16M | 大小写不敏感 |
| Long Text | Max:4G | 大小写不敏感 |
| TinyBlob | Max:255 | 大小写敏感 |
| Blob | Max:64K | 大小写敏感 |
| MediumBlob | Max:16M | 大小写敏感 |
| LongBlob | Max:4G | 大小写敏感 |
| Enum | 1或2 | 最大可达65535个不同的枚举值 |
| Set | 可达8 | 最大可达64个不同的值 |
| Geometry | ||
| Point | ||
| LineString | ||
| Polygon | ||
| MultiPoint | ||
| MultiLineString | ||
| MultiPolygon | ||
| GeometryCollection |
614

被折叠的 条评论
为什么被折叠?



