Data types in MySQL (2024)

Data typeLengthDescription
TINYINT1 byteRange from -128 to +127 (unsigned: from 0 to 255)
SMALLINT2 bytesRange from -32 768 to +32 767 (unsigned: from 0 to 65 535)
MEDIUMINT3 bytesRange from -8 388 608 to +8 388 607 (unsigned: from 0 to 16 777 215)
INT,INTEGER4 bytesRange from -2 147 483 648 to +2 147 483 647 (unsigned: from 0 to 4 294 967 295)
BIGINT8 bytesRange 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, BOOL1 bytesynonym for TINYINT(1) type
FLOATRange from -3.402823466E+38 to +3.402823466E+38
DOUBLERange from -1.7976931348623157E+308 to +1.7976931348623157E+308
DOUBLE PRECISION, REALsynonym for DOUBLE type
DECIMAL(m,d), DEC(m,d), NUMERIC(m,dthe range sets the "m" and "d" parameters, the maximum range is the same as for 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 can be set 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 then 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" (format "HH:MM:SS")
YEAR(n)0000YEAR(4) = range from 1901 to 2155, (format "RRRR"), YEAR(2) = range from 1970 to 2069
CHAR(m)

- the string length "m" can be in the range from 0 to 255

- if the entered string is shorter than defined, then the missing characters are filled automatically with spaces (the length is fixed)

- CHAR (without "m") is considered to be CHAR(1)

VARCHAR(m)

- the string length "m" can be in the range from 0 to 255

- if the entered string is shorter than defined, then the missing characters are not filled (the length is flexible), but the information about its length is also stored

TINYBLOB, TINYTEXTString length is max. 255 characters
BLOB, TEXTString length is max. 65 535 characters
MEDIUMBLOB, MEDIUMTEXTString length is max. 16 777 215 characters
LONGBLOB, LONGTEXTString length is max. 4 294 967 295 characters
ENUM('item1','item2',...)

- array of defined strings (items) of the max. 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 (instead of 'item1'), 2 (instead of 'item2')...

SET('item1','item2',...)

- array of defined strings (items) with the max. number of 64

- the table cell may contain multiple defined items

See http://dev.mysql.com/doc/refman/5.6/en/data-types.html, http://www.junext.net/mysql.

PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person

Data types in MySQL (2024)
Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 6410

Rating: 4 / 5 (71 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.