String Data Types

Data typeDescription
CHAR(size)A string with a set length (can contain letters, numbers, and special characters). The size parameter sets the length of the column in characters. Its value can be between 0 and 255. Default is 1
VARCHAR(size)A string with different lengths (can contain letters, numbers, and special characters). The size parameter sets the maximum number of characters that can be in a column. This number can range from 0 to 65535.
BINARY(size)Same as CHAR(), but stores strings of binary bytes. The size parameter gives the length of the column in bytes. Default is 1
VARBINARY(size)The same as VARCHAR(), but stores strings of binary bytes. The size parameter says how many bytes the longest column can be.
TINYBLOBFor BLOBs (Binary Large OBjects). Length limit: 255 bytes
TINYTEXTHolds a string that can be up to 255 characters long.
TEXT(size)Holds a string that is up to 65,535 bytes long.
BLOB(size)For BLOBs (Binary Large OBjects). Up to 65,535 bytes of data can fit in it.
MEDIUMTEXTKeeps a string that is up to 16,777,215 characters long.
MEDIUMBLOBFor BLOBs (Binary Large OBjects). Up to 16,777,215 bytes of data can fit in it.
LONGTEXTString that can hold up to 4,294,967,295 characters.
LONGBLOBFor BLOBs (Binary Large OBjects). Up to 4,294,967,295 bytes of data can fit in it.
ENUM(val1, val2, val3, ...)A string object that can only have one value from a list of options. An ENUM list can have up to 65535 values. If a value is entered that is not in the list, a blank value will be entered. The order in which you enter the values is used to sort them.
SET(val1, val2, val3, ...)A string object that can have 0 or more values from a list of possible values. A SET list can have up to 64 values.

Numeric Data Types

Data typeDescription
BIT(size)A type of bit-value. In size, the number of bits per value is given. The value of the size parameter can be between 1 and 64. By default, size is set to 1.
TINYINT(size)A very small integer. From -128 to 127, signed range. The range of unsigned is from 0 to 255. The size parameter sets the maximum width of the display (which is 255)
BOOLValues that are not zero are considered to be true, while zero is considered to be false.
BOOLEANEqual to BOOL
SMALLINT(size)A small integer. From -32768 to 32767 is the signed range. The range of unsigned is between 0 and 65535. The size parameter sets the maximum width of the display (which is 255)
MEDIUMINT(size)A medium integer. Range signed is between -8388608 and 8388607. Unsigned is between 0 and 16777215. The size parameter sets the maximum width of the display (which is 255)
INT(size)A medium integer. From -2147483648 to 2147483647 is the signed range. The range of unsigned is 0 to 4294967295. The size parameter sets the maximum width of the display (which is 255)
INTEGER(size)Equal to INT(size)
BIGINT(size)A large integer. Signed range is between -9223372036854775808 and 9223372036854775807. Range is from 0 to 18446744073709551615 for unsigned. The size parameter sets the maximum width of the display (which is 255)
FLOAT(size, d)Float number. In size, the number of digits as a whole is given. In the d parameter, the number of digits after the decimal point is set. This syntax is no longer supported as of MySQL 8.0.17, and it will be taken out of future versions of MySQL.
FLOAT(p)Float number. MySQL uses the value of p to decide whether to use the data type FLOAT or DOUBLE. If p is between 0 and 24, the type of data is FLOAT (). If p is between 25 and 53, the type of data is changed to DOUBLE ()
DOUBLE(size, d)A normal-size floating point number. In size, the number of digits as a whole is given. In the d parameter, the number of digits after the decimal point is given.
DOUBLE PRECISION(size, d)The range of the double precision type is between 1E-307 and 1E+308, and it is accurate to at least 15 digits. If the value is too big or too small, an error will happen. If the precision of a number you enter is too high, rounding might happen.
DECIMAL(size, d)An exact fixed-point number. In size, the number of digits as a whole is given. In the d parameter, the number of digits after the decimal point is set. The most that can be chosen for size is 65. The most that d can be is 30. size is set to 10 by default. d is set to 0 by default.
DEC(size, d)Equal to DECIMAL(size,d)

Date and Time Data Types

Data typeDescription
DATEA date. YYYY-MM-DD is the format. Dates from '1000-01-01' to '9999-12-31' can be used.
DATETIME(fsp)A date and time that go together. YYYY-MM-DD hh:mm:ss is the format. From "1000-01-01 00:00:00" to "9999-12-31 23:59:59" is the range that can be used. By putting DEFAULT and ON UPDATE in the column definition, the current date and time will be set automatically and the column will be set to its default value.
TIMESTAMP(fsp)A timestamp. The number of seconds since the Unix epoch ('1970-01-01 00:00:00' UTC) is stored as the TIMESTAMP value. YYYY-MM-DD hh:mm:ss is the format. From 1970-01-01 00:00:01 UTC to 2038-01-09 03:14:07 UTC is supported. You can set DEFAULT CURRENT TIMESTAMP and ON UPDATE CURRENT TIMESTAMP in the column definition to automatically set the date and time to the current time and date.
TIME(fsp)A time. For example, hh:mm:ss. From '-838:59:59' to '838:59:59' is the range that can be used.
YEARA year with four numbers. In a four-digit format, you can use the numbers 1901 to 2155 and 0000.
MySQL 8.0 doesn't work with years with only two digits.