Data Types

For each data type, the syntax shown uses square brackets ([]) to indicate optional parts of the syntax. The following example shows how BIGINT is explained in this chapter:

BIGINT[(display_size)]

This indicates that you can use BIGINT alone or with a display size value. The italics indicate that you do not enter display_size literally, but instead enter your own value. Possible uses of BIGINT include:

BIGINT
BIGINT(20)

In addition to the BIGINT type, many other MySQL data types support the specification of a display size. Unless otherwise specified, this value must be an integer between 1 and 255.

Before MySQL 5, MySQL would silently change column values in certain circumstances. As of MySQL 5, these silent changes no longer happen.

VARCHARCHAR

When the specified VARCHAR column size is less than four characters, it is converted to CHAR.

CHARVARCHAR

When a table has at least one column of a variable length, all CHAR columns greater than three characters in length are converted to VARCHAR.

TIMESTAMP display sizes

Display sizes for TIMESTAMP fields must be an even value between 2 and 14. A display size of 0 or greater than 14 converts the field to a display size of 14. An odd-valued display size is converted to the next highest even value. MySQL 5 no longer takes a size value for timestamps.

Numerics

MySQL supports all ANSI SQL2 numeric data types. MySQL numeric types break down into integer, decimal, and floating point types. Within each group, the types differ by the amount ...

Get MySQL Pocket Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.