Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Data type in MySql

Data type Length Description
TINYINT 1 byte Range from -128 to +127 (unsigned: from 0 to 255)
SMALLINT 2 bytes Range from -32 768 to +32 767 (unsigned: from 0 to 65 535)
MEDIUMINT 3 bytes Range from -8 388 608 to +8 388 607 (unsigned: from 0 to 16 777 215)
INT,INTEGER 4 bytes Range from -2 147 483 648 to +2 147 483 647 (unsigned: from 0 to 4 294 967 295)
BIGINT 8 bytes Range from -9 223 372 036 854 775 808 to +9 223 372 036 854 775 807 (unsigned: from 0 to 18 446 744 073 709 551 615)
BIT, BOOL 1 byte synonym for TINYINT(1)
FLOAT   Range from -3.402823466E+38 to +3.402823466E+38
DOUBLE   Range from -1.7976931348623157E+308 to +1.7976931348623157E+308
DOUBLE PRECISION, REAL   synonym for DOUBLE type
DECIMAL(m,d), DEC(m,d), NUMERIC(m,d   the range sets the parameters "m" and "d", the maximum range is similar to DOUBLE type
DATE '0000-00-00' the date in format "year-month-day" meaning "RRRR-MM-DD". Range from 1000-01-01 to 9999-12-31
DATETIME '0000-00-00 00:00:00' date and time. Range from 1000-01-01 00:00:00 to 9999-12-31 23:59:59 (format = "RRRR-MM-DD HH:MM:SS")
TIMESTAMP(n) '0000-00-00 00:00:00'
- date and time in the range from 1970-01-01 00:00:00 to 2037-01-01 00:00:00 (all 14 digits are always stored !)
- the display format is defined by "m" parameter with the value of 14 (or missing), 12, 10, 8, 6, 4, or 2
- "RRRRMMDDHHMMSS", "RRMMDDHHMMSS", "RRMMDDHHMM", "RRRRMMDD", "RRMMDD", "YYMM", "YY"
- if no data is written into such cell, the MySQL will add the current time of modification of the corresponding row
TIME '00:00:00' time range is from "-838:59:59" to "838:59:59" (forma "HH:MM:SS")
YEAR(n) 0000 YEAR(4) = range from 1901 to 2155, (format "RRRR"), YEAR(2) = range from 1970 to 2069
CHAR(m)  
- the string lenght "m" can be in the range of from 0 to 255
- if the entered string is shorter than defined, the missing characters are filled with spaces (the lenght is fixed)
- CHAR (without "m") is considered to be CHAR(1)
VARCHAR(m)  
- the string lenght "m" can be in the range from 0 to 255
- if the entered string is shorter than defined, the missing characters are not filled (the lenght is flexible), but the information about its lenght is also stored
TINYBLOB, TINYTEXT   Char string max. length 255
BLOB, TEXT   Char string max. length 65 535
MEDIUMBLOB, MEDIUMTEXT   Char string max. length 16 777 215
LONGBLOB, LONGTEXT   Char string max. length 4 294 967 295
ENUM('item1','item2',...)  
- array of defined strings (items) of the maximum number of 65 535
- the table cell may contain only a single item of the defined set
- instead of using the 'item' name, the item order can also be used: 1 (as 'item1'), 2 (as 'item2')...
SET('item1','item2',...)  
- array of defined strings (items) with the maximum number of 64
- the table cell may contain multiple defined items
 
See dev.mysql.com/doc/refman/5.6/en/data-types.html, www.junext.net/mysql/.
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice