(Transfer) Java data type and MySql data type corresponding table

java mysql data type comparison

type name Display length database type JAVA type JDBC type index (int) describe
           
VARCHAR L+N VARCHAR java.lang.String 12  
CHAR N CHAR java.lang.String 1  
BLOB L+N BLOB java.lang.byte [] -4  
TEXT 65535 VARCHAR java.lang.String -1  
           
INTEGER 4 INTEGER UNSIGNED java.lang.Long 4  
TINYINT 3 TINYINT UNSIGNED java.lang.Integer -6  
SMALLINT 5 SMALLINT UNSIGNED java.lang.Integer 5  
MEDIUMINT 8 MEDIUMINT UNSIGNED java.lang.Integer 4  
BIT 1 BIT java.lang.Boolean -7  
BIGINT 20 BIGINT UNSIGNED java.math.BigInteger -5  
FLOAT 4+8 FLOAT java.lang.Float 7  
DOUBLE 22 DOUBLE java.lang.Double 8  
DECIMAL 11 DECIMAL java.math.BigDecimal 3  
BOOLEAN 1 同TINYINT      
           
ID 11 PK (INTEGER UNSIGNED) java.lang.Long 4  
           
DATE 10 DATE java.sql.Date 91  
TIME 8 TIME java.sql.Time 92  
DATETIME 19 DATETIME java.sql.Timestamp 93  
TIMESTAMP 19 TIMESTAMP java.sql.Timestamp 93  
YEAR 4 YEAR java.sql.Date 91






For bolb, it is generally used for database storage of pictures. The principle is to convert the pictures into binary, and then perform a storage method, which corresponds to the byte[] array in java.

For the boolen type, in the mysql database, I personally think that it is better to use the int type instead, and it is not very convenient for bit operations, especially in projects with web page development, which means 0/1, which corresponds to the java type Integer is better.
 
The declaration syntax for decimal columns is decimal(m,d).
在mysql5.1中,参数的取值范围: 
1、M是数字的最大数(精度)。其范围为1~65(在较旧的MySQL版本中,允许的范围是1~254)。 
2、D是小数点右侧数字的数目(标度)。其范围是0~30,但不得超过M。 
说明:float占4个字节,double占8个字节,decimail(M,D)占M+2个字节。 
如DECIMAL(5, 2) 的最大值为9 9 9 9 . 9 9,因为有7 个字节可用。 
 
 
 
REFS:http://www.cnblogs.com/jerrylz/p/5814460.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326707622&siteId=291194637