String Column Types

MySQL has a range of string column types. Although in name they are intended for storing string or textual data, you can in fact use them to store any kind of data you want, including numbers, images, sounds, and binary data.

Your choice of string column type for a given application largely depends on the length of data you want to store and how you want to work with the data. Table 5.3 shows MySQL's string column types.

Table 5.3. String Column Types
Type NameMaximum Size
CHAR(M)M bytes
VARCHAR(M)M bytes
TINYBLOB28-1 bytes
BLOB216-1 bytes
MEDIUMBLOB224-1 bytes
LONGBLOB232-1 bytes
TINYTEXT28-1 bytes
TEXT216-1 bytes
MEDIUMTEXT224-1 bytes
LONGTEXT232-1 bytes
ENUM('value1','value2',...)65565 values
SET('value1','value2',...)64 values

In essence, ...

Get Sams Teach Yourself MySQL in 21 Days, Second 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.