Joke Collection Website - Cold jokes - Problems with char type in mysql?

Problems with char type in mysql?

Char is a fixed-length type, and varchar is a variable-length type. The difference between them is:

In a data column of type char(M), each Each value occupies M

bytes

. If a length is less than M, MySQL will

right

Complement with space characters. (Padding space characters will be removed during the search operation.) In a varchar(M) type data column, each value only takes up just enough bytes plus one byte to record its length ( That is, the total length is L+1 bytes).

Rules used in MySQL to determine whether column comparison

type conversion

is required

>1. In a

data table

, if the length of each data column is fixed, then the length of each data row will also be fixed.

2. As long as there is a variable length of data column in the data table, then the length of each data row will be variable.

3. If the length of the data rows in a certain data table is variable, then, in order to save

storage space

, MySQL will Fixed-length data columns in the data table are converted into corresponding variable-length types.

Exception: char data columns with a length less than 4 characters will not be converted to varchar type

Hope this helps you