String Types

The MySQL string types are commonly used to store text, but are general and may hold arbitrary data. Types are available to hold values of varying maximum lengths and can be chosen according to whether or not you want values to be treated in case sensitive fashion.

CHAR(M)

Meaning. A fixed-length character string 0 to M bytes long M should be an integer from 1 to 255 prior to MySQL 3.23, and from 0 to 255 as of MySQL 3.23 Strings shorter than M characters are right-padded with spaces when stored Strings longer than M characters are chopped to length M when stored Trailing spaces are removed when values are retrieved.

Allowable attributes. BINARY

Allowable length. 0 to M bytes

Default value. NULL if column can be NULL, "" if NOT NULL ...

Get MySQL 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.