Learning the MySQL Data Types

MySQL uses many different data types, broken into three categories: numeric, date and time, and string types.

 INT—A normal-sized integer that can be signed or unsigned. If signed, the
allowable range is from –2147483648 to 2147483647. If unsigned, the allowable
range is from 0 to 4294967295. You can specify a width of up to 11 digits.

. TINYINT—A small integer that can be signed or unsigned. If signed, the allowable
range is from –128 to 127. If unsigned, the allowable range is from 0 to
255. You can specify a width of up to 4 digits.

 SMALLINT—A small integer that can be signed or unsigned. If signed, the
allowable range is from –32768 to 32767. If unsigned, the allowable range is
from 0 to 65535. You can specify a width of up to 5 digits.

 MEDIUMINT—A medium-sized integer that can be signed or unsigned. If signed,
the allowable range is from –8388608 to 8388607. If unsigned, the allowable
range is from 0 to 16777215. You can specify a width of up to 9 digits.

 BIGINT—A large integer that can be signed or unsigned. If signed, the allowable
range is from –9223372036854775808 to 9223372036854775807. If
unsigned, the allowable range is from 0 to 18446744073709551615. You can
specify a width of up to 11 digits.

FLOAT(M,D)—A floating-point number that cannot be unsigned. You can
define the display length (M) and the number of decimals (D). This is not
required and defaults to 10,2, where 2 is the number of decimals and 10 is the
total number of digits (including decimals). Decimal precision can go to 24
places for a FLOAT.

 DOUBLE(M,D)—A double-precision floating-point number that cannot be
unsigned. You can define the display length (M) and the number of decimals
(D). This is not required and will default to 16,4, where 4 is the number of
decimals. Decimal precision can go to 53 places for a DOUBLE. REAL is a synonym
for DOUBLE.


DECIMAL(M,D)—An unpacked floating-point number that cannot be unsigned.
In unpacked decimals, each decimal corresponds to 1 byte. Defining the display
length (M) and the number of decimals (D) is required. NUMERIC is a synonym
for DECIMAL.