VARCHAR stores character strings whose lengths can vary within a declared maximum. It fits attributes such as names, where values are relatively short, differ in length, and have a reasonably predictable upper limit. section 4.5
Choosing the right string type matters because unnecessary storage can increase memory and computation needs as a database grows. Use CHAR for uniform-length values, VARCHAR for short varied values, and TEXT for large text whose limit is difficult to estimate. section 4.5
Customer names
For a customer-name attribute, lengths vary but an upper limit of about 30 characters is easy to estimate, making VARCHAR a practical choice. By comparison, a two-character state code suits CHAR, while text regularly exceeding a thousand characters suits TEXT. section 4.5
Filtering a VARCHAR value
String values appear in single quotes when filtering. For example: SELECT name FROM product WHERE manufacturer = 'Mad Inventors Inc.'; A product table can use a string type for manufacturer and a numeric type for price, then combine conditions with AND. section 1.7
Choose among the common string types using these practical rules:
- Use CHAR when the attribute always has a uniform length. section 4.5
- Use VARCHAR when the attribute is relatively short, varies in length, and has an estimable maximum. section 4.5
- Use TEXT when values regularly exceed a few thousand characters or their maximum length is hard to estimate. section 4.5



