众所周知,CHAR用于存储固定长度的字符串,而VARCHAR用于存储可变长度的字符串。因此,通过将一列声明为CHAR并将其他列声明为VARCHAR,我们可以在同一表中存储固定长度和可变长度的字符串。
Create Table Employees(FirstName CHAR(10), LastName VARCHAR(10)); Desc Employees; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | FirstName | char(10) | YES | | NULL | | | LastName | varchar(10) | YES | | NULL | | +-----------+-------------+------+-----+---------+-------+ 2 rows in set (0.03 sec)