A relational table
| type name type | | | show length database JAVA type index (int) | | JDBC type
|-|-|-|-|-|-| 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 a DECIMAL | | 11 DECIMAL | Java. Math., BigDecimal | 3 BOOLEAN | 1 | with TINYINT 11 | | | ID 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
Pay attention to
bolb :
Bolb is generally used for database storage of images. The principle is to type images into binary and then store them in a way corresponding to byte [] arrays in Java.
boolen
For BOOLen type, in mysql database, I think it is better to use int type instead, which is not very convenient for bit operation, especially in projects with Web page development, which represents 0/1, and Integer corresponding to Java type is better.
decima
The declarative syntax for decimal columns is decimal(m,d). In mysql5.1, the value range of the parameter is:
- M is the largest number (precision) of a number.
The range is from 1 to 65 (in older MySQL versions, the range is allowed from 1 to 254).
- D is the number of numbers to the right of the decimal point (scale).
The value ranges from 0 to 30, but does not exceed M.
Description:
Float accounts for 4 bytes, double for 8 bytes, and Decimail (M,D) for M+2 bytes.
For example, the maximum value for DECIMAL(5, 2) is 9, 9, 9, 9. 9, 9, because 7 bytes are available.