CHAR and VARCHAR Data Type:- The CHAR and VARCHAR Data types are similar, but differ in the way they are stored and retrieved. CHAR and VARCHAR are declared with a fixed length, which declares how many a maximum number of characters will be stored.
When we create a table, the CHAR column will be fixed in length. The length value can be any value from 0 to 255 bytes. The stored CHAR value will be right-padded with space to the specified length. When PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled, then trailing spaces will not remove after retrieving the CHAR value.
VARCHAR column value will be variable in length. Variable length value can be any value from 0 to 65,535 bytes. The effective maximum length of a VARCHAR is subject to the maximum row size. VARCHAR values are not padded when they are stored. Trailing spaces are retained when values are stored and retrieved.
Note:- If strict SQL mode will enable, values that exceed the column length are not stored, and an error results.
CREATE TABLE employee(
BIT MySQL Data Type
TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT MySQL Data Type
BOOLEAN, FLOAT, DOUBLE, DECIMAL MYSQL Data Type
ENUM MySQL Data Type
MYSQLSET Data Type
MySQL BINARY and VARBINARY Data Type
For more detail about Data Type, Please visit Mysql Manual