MySQL String Data Types

What are the String data types in MySQL?

Explanation

MySQL String data types :



Different types of String Data types in MySQL.
CHAR() :
It is a fixed length string and is mainly used when the data is not going to vary much in it's length. It ranges from 0 to 255 characters long. While storing CHAR values they are right padded with spaces to the specified length. When retrieving the CHAR values, trailing spaces are removed.
VARCHAR() :
It is a variable length string and is mainly used when the data may vary in length. It ranges from 0 to 255 characters long. VARCHAR values are not padded when they are stored.
TINYTEXT, TINYBLOB :
A string with a maximum length of 255 characters.
TEXT :
TEXT columns are treated as character strings(non-binary strings). It contains a maximum length of 65535 characters.
BLOB :
BLOB stands for Binary Large OBject. It can hold a variable amount of data. BLOB columns are treated as byte strings(binary strings). It contains a maximum length of 65535 characters.
MEDIUMTEXT, MEDIUMBLOB :
It has a maximum length of 16777215 characters.
LONGTEXT, LONGBLOB :
It has a maximum length of 4294967295 characters.
BINARY :
The BINARY is similar to the CHAR type. It stores the value as binary byte strings instead of non-binary character strings.
VARBINARY :
The VARBINARY is similar to the VARCHAR type. It stores the value as binary byte strings instead of non-binary character strings.
ENUM() :
An enumeration. Each column may have one of a specified possible values. It can store only one of the values that are declared in the specified list contained in the ( ) brackets. The ENUM list ranges up to 65535 values.
SET() :
A set. Each column may have more than one of the specified possible values. It contains up to 64 list items and can store more than one choice. SET values are represented internally as integers.
If CHAR and VARCHAR options are used in the same table, then MySQL will automatically change the CHAR into VARCHAR for compatability reasons. The ( ) bracket allows to enter a maximum number of characters that will be used in the column.These all are the MySQL String Data Types

Ask Questions

Ask Question