O'Reilly logo

SQL in a Nutshell by Kevin Kline

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

MySQL Datatypes

MySQL numeric datatypes support the following optional attributes:

UNSIGNED

The numeric value is assumed to be non-negative (positive or zero). For fixed-point datatypes like DECIMAL and NUMERIC, the space normally used to show a positive or negative condition of the numeric value can then be used as part of the value, providing a little extra numeric range in the column for DECIMAL and NUMERIC types. (There is no SIGNED optional attribute.)

ZEROFILL

Used for display formatting, this attribute tells MySQL that the numeric value is padded with zeros to its full size rather than spaces. ZEROFILL automatically forces the UNSIGNED attribute as well.

MySQL also enforces a maximum display size for columns of up to 255 characters. Columns longer than 255 characters are stored properly, but only 255 characters are displayed. Floating-point numeric datatypes may have a maximum of 30 digits after the decimal point.

The list below shows that MySQL supports most of the SQL2003 datatypes, plus several additional datatypes used to contain lists of values, as well as datatypes used for binary large objects (BLOBs). Datatypes that extend the ANSI standard include TEXT, ENUM, SET, and MEDIUMINT. Special datatype attributes that go beyond the ANSI standard include AUTO_INCREMENT, BINARY, NULL, UNSIGNED, and ZEROFILL.

BIGINT[(n)] [UNSIGNED] [ZEROFILL] (SQL2003 Datatype: BIGINT)

Stores signed or unsigned integers. The signed range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required