Data Types

String data types

Data TypeDescriptionMaximum Size Limit
CHAR(length)Fixed length string, length specifies the number of characters to be stored255
VARCHAR(length)Variable length string,length specifies the number of characters to be stored255
text(length)Fixed length string, length specifies the number of characters to be stored255
binary(length)Fixed length string, length specifies the number of characters to be stored255
BLOB, TEXTBLOB is for storing binary data and Text is used to store large string65,535(64KB)
TINYTEXTused to store short strings255
MEDIUMTEXTused to store larger text strings16,777,215(16MB)
LONG TEXTused to store very large data which can't be stored in MEDIUMTEXT4,294,967,295(4GB)

Data and time data types

Data typeFormatRange
DATE'YYYY-MM-DD''1000-01-01' to '9999-12-31'
DATETIME[(f)]'YYYY-MM-DD hh:mm:ss[.fraction]''1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999'
TIMESTAMP[(f)]'YYYY-MM-DD hh:mm:ss[.fraction]''1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' UTC
TIME[(f)]'hh:mm:ss[.fraction]''-838:59:59.000000' to '838:59:59.000000'
YEAR[(2/4)]'YY'/'YYYY'(default)Year represented in 2 or 4 digits

Note: f refers to fractional seconds precision

Numeric data types

1. Integer Family

Data TypeUnsigned Min ValueUnsigned Max ValueSigned Min ValueSigned Max Value
INT04294967295-21474836482147483647
SMALLINT065535-3276832767
MEDIUMINT016777215-83886088388607
BIGINT018446744073709551615-92233720368547758089223372036854775807
TINYINT0255-128127

2. FLOAT(d)

where d is number of decimals. If the d value is in between 0-24 then the data type becomes FLOAT() else if the d value is >24 and <53 then the data type becomes DOUBLE()

3. DECIMAL(l,d)

where l is number of digits displayed before the decimal point and d is number of digits after the decimal point. Default value is DECIMAL(10,2).