Compiled a data type in mysql
1. Value Type
tinyint
From -2 ^ 7 (-128) to 2 ^ 7--1 (127) of integer data. Storage size is 1 byte.
unsigned integer data is from 0 to 255. For decimal type
So when construction of the table can only be tinyint (3), even if you build tinyint (100), he was three biggest so much.
smallint
From -2 ^ 15 (-32,768) through 2 ^ 15 --1 (32,767) integer data. Storage size is 2 bytes.
unsigned integer data is from 0 to 65535. For large integer values
So when construction of the table can only be smallint (5), even if you build smallint (100), he was five largest so much.
mediumint
Integer data from -2 ^ 23 (-8,388,608) to 2 ^ 23 (8,388,607) (all digital) storage size of 3 bytes.
unsigned integer data is from 0 to 16,777,215 of. For large integer values
So when construction of the table can only be mediumint (7), even if you build int (100), he was seven largest so much.
int/integer
From -2 ^ 31 (2,147,483,648) to 2 ^ 31 - 1 (2,147,483,647) integer data (all numbers) storage size of 4 bytes.
unsigned integer data is from 0 to 4294967296.
So when construction of the table can only be int (10), even if you build int (100), he was 10 biggest so much.
bigint
From -2 ^ 63 (-9,223,372,036,854,775,808) to 2 ^ 63-1 (9,223,372,036,854,775,807) integer data (all numbers). The storage size is 8 bytes.
unsigned is (do the math)
So when construction of the table can only be bigint (20), even if you build bigint (100), he was 20 biggest so much.
float
Single-precision floating-point value
Storage size is 4 bytes.
double
Double precision floating point value
The storage size is 8 bytes.
decimal
Of DECIMAL (M, D), if M> D, M + 2 is otherwise D + 2
And storing a value smaller range of values based on the size of the M and D
ps: m is the total number of digits, d is the number of digits after the decimal point. If m and d will be omitted to save hardware condition value in accordance with the allowable limit.
2. Time and date
date
3-byte storage size
Format YYYY-MM-DD
Range 1000-01-01 / 9999-12-31
A date value
time
3-byte storage size
Format HH: MM: SS
Range '-838: 59: 59' / '838: 59: 59'
Values for the time or duration
year
Storage Size 1 byte
YYYY format
Range 1901/2155
For the year value
datetime
Storage size of 8 bytes
Format YYYY-MM-DD HH: MM: SS
Range 1000-01-0100: 00: 00 / 9999-12-31 23:59:59
Date and time values for mixing
timestamp
Storage Size 4 bytes
Format YYYYMMDD HHMMSS
Range 1970-01-0100: 00: 00/2038
End times are 2147483647 seconds, the Beijing 2038-1-19 11:14:07 GMT, January 19, 2038 early morning 03:14:07
Mixing a date and time values, the time stamp
3. string type
char
0-255 bytes storage size
A fixed-length string
varchar
Storage size 0-65535 bytes
A variable-length strings
TINYBLOB
0-255 bytes storage size
No more than 255 characters in binary string
tinytext
0-255 bytes storage size
Short text strings
blob
Storage size 0-65535 bytes
Long text data in binary form
text
Storage size 0-65535 bytes
Long text data
mediumblob
Storage size bytes 0-16777215
Binary text data in the form of medium length
mediumtext
Storage size bytes 0-16777215
Medium length text data
longblob
Storing byte size 0-4294967295
Great text data in binary form
longtext
Storing byte size 0-4294967295
Great text data