MySQL
1, integer
MySQL Data Types | Meaning (Signed) |
tinyint(m) | A byte range (-128 to 127) |
smallint(m) | 2 byte range (-32768 to 32767) |
mediumint(m) | 3 byte range (~ -8388608 8388607) |
int(m) | 4 byte range (-2147483648 to 2147483647) |
bigint(m) | Range of 8 bytes (18 + -9.22 * 10 th) |
Unsigned range if the increase, the maximum value is doubled, as tinyint unsigned ranges (0 to 255).
int (m) where m is the display width of a SELECT query result set, I do not know what is the use of this m.
int accounted for 10, can not save phone number (11)
2, float (float and double) floating-point stored in the database are approximations
MySQL Data Types | meaning |
float(m,d) | Total single precision floating point precision of eight bits (4 bytes) m number, d decimal places |
double(m,d) | The total 16-bit double precision floating point precision (8 bytes) m number, d decimal places |
Field is defined as a set float (5,3), if a number is inserted 123.45678, actually stored in the database is 123.457, but also the total number of the actual subject, i.e., six.
3, fixed point designated type is stored in the database the exact value
Float stored in the database are approximations, and the fixed-point type stored in the database the exact value.
decimal (m, d) Parameters m <65 is the total number, d <30 and d <m is a decimal.
4, character string (char, varchar, _text)
MySQL Data Types | meaning |
char(n) | Fixed length, up to 255 characters |
varchar(n) | Variable length, up to 65535 bytes |
tinytext | Variable length, up to 255 characters |
text | Variable length, up to 65,535 characters. |
mediumtext | Variable length, a maximum power of 24 characters -1 2 |
longtext | Variable length, up to 32 characters power of 2 -1 |
Java
1、
Basic types: int binary digits: 32
Packaging: java.lang.Integer
Min: Integer.MIN_VALUE = -2147483648 (-2 31 th)
Maximum: Integer.MAX_VALUE = (31 -12 power of) 2147483647
2、
Basic types: short binary digits: 16
Packaging: java.lang.Short
Min: Short.MIN_VALUE = -32768 (-2 this side of 15)
Maximum: Short.MAX_VALUE = (15 -12 power of) 32767
3、
Basic types: long binary digits: 64
Packaging: java.lang.Long
Min: Long.MIN_VALUE = (63 -2 power) -9223372036854775808
Maximum: Long.MAX_VALUE = (63 -12 power of) 9223372036854775807
4、
Basic types: float binary digits: 32
Packaging: java.lang.Float
Min: Float.MIN_VALUE = (-149 power of 2) 1.4E-45
Maximum: Float.MAX_VALUE = (128 -12 power of) 3.4028235E38
5、
Basic types: double the number of bits: 64
Packaging: java.lang.Double
Min: Double.MIN_VALUE = (-1074 power of 2) 4.9E-324
Maximum: Double.MAX_VALUE = 1.7976931348623157E308 (2-th power of 1024 -1)
java mysql data type controls
type name | Display length | Database Type | JAVA type | JDBC type index (int) | description |
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 |