CHAR is a string data type for values whose length is uniform. Declare the required width in parentheses, such as CHAR(12); use it when every value for an attribute has the same number of characters. section 4.5 section 4.6
Choosing a suitable string type matters as a database grows: unnecessarily large data can increase storage, memory, and lookup costs. For short values with varying lengths, use VARCHAR; for regularly large text with an uncertain upper limit, use TEXT. section 4.5
Use CHAR for identifiers that look numeric but are not used in calculations:
- Card numbers can use CHAR(16), preserving any leading zeros while recording their uniform 16-digit length. section 4.6
- Expiry dates can use CHAR(4) when each value contains four digits. section 4.6
- Universal Product Codes can use CHAR(12), because each UPC has 12 digits and may begin with zero. section 4.6
Treat codes as strings
A value can consist only of digits yet still be string data. A product code is not meant for arithmetic, and an integer type can remove leading zeros. CHAR(12) records its fixed 12-character form instead. section 4.6




