O'Reilly logo

Managing & Using MySQL, 2nd Edition by Hugh E. Williams, Randy Yarger, George Reese, Tim King

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

Chapter 16. MySQL Data Types

MySQL offers a wide variety of data types to support the storage of different kinds of data. This chapter lists the full range of these data types and describes their functionality, syntax, and data storage requirements. 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. Thus, possible uses of BIGINT include:

BIGINT
BIGINT(20)

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

Table 16-1 lists the data types and categorizes them as numeric, string, date, or complex. You can find the full description of each data type later in this chapter.

Table 16-1. MySQL data types

Data type

Classification

BIGINT

Numeric

BLOB

String

CHAR

String

CHARACTER

String

CHARACTER VARYING

String

DATE

Date

DATETIME

Date

DEC

Numeric

DECIMAL

Numeric

DOUBLE

Numeric

DOUBLE PRECISION

Numeric

ENUM

Complex

FLOAT

Numeric

INT

Numeric

INTEGER

Numeric

LONGBLOB

String

LONGTEXT

String

MEDIUMBLOB

String

MEDIUMINT

Numeric

MEDIUMTEXT

String

NCHAR

String

NATIONAL CHAR

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