

a string which is not present in the list of permitted values, the empty string will be inserted. If you insert an invalid value into an ENUM column i.e. You can specify up to a maximum of 65,535 distinct values in an ENUM list.

For example, a column specified as gender ENUM('male', 'female') NOT NULL can have any of these values: '', 'male' or 'female'. The ENUM data type allows you to specify a list of possible values that can be stored in a column. It means the maximum number of characters is less for strings that contain multibyte characters. Note: In case of nonbinary string data types column length values are normally referred as number of characters rather than bytes. The maximum length is in bytes, whether the type is binary or nonbinary. The following table lists the MySQL string data types that come in pairs. These correspond to the four BLOB types and have the same maximum lengths and storage requirements. Similary, the four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These differ only in the maximum length of the values they can hold. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. It is especially useful when you need to store binary media files in the database, such as images or audio files. The TEXT data type is used to to store long string of text like descriptions, blog comments, etc.Ī BLOB is a binary large object that can hold a variable amount of data. The TEXT and BLOB data types are specifically made to hold large sets of data. The permissible maximum length is the same for BINARY and VARBINARY as it is for CHAR and VARCHAR, except that the length for BINARY and VARBINARY is a length in bytes rather than in characters. The BINARY and VARBINARY types are similar to CHAR and VARCHAR, except that they contain binary strings rather than nonbinary string.


Note: The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used. This means if you store the value 'ab' in a CHAR(4) column the value will be stored as 'ab ', whereas the same value will be stored in VARCHAR(4) column as 'ab'. When values are stored in a CHAR column, they are right-padded with spaces to the specified length, but in VARCHAR column values are not padded when they are stored. The main difference between the CHAR and VARCHAR data type is the way they stores the data. For example, CHAR(5) can hold up to 5 characters. The CHAR and VARCHAR data types are declared with a length that indicates the maximum number of characters you want to store. Whereas the VARCHAR data type allows you to store variable-length strings with a maximum size of 65,535 characters (it was limited to 255 characters prior to MySQL 5.0.3). The CHAR data type allows you to store fixed-length strings with a maximum size of 255 characters. String data types are normally used to store names, addresses, descriptions or any value that contains letters and numbers including binary data, like image or audio files. MySQL supports three categories of data types: string, numeric and date/time data types. The following sections describe the data types supported by MySQL.
