When considering whether to use CHAR or VARCHAR, the decision depends more on programming considerations than on the database. The difference is that comparisons of two fixed character fields will be automatically padded to equal lengths with spaces; comparisons with VARCHAR will not.
In order to save time on the database design, you might be tempted to avoid using CHAR columns and simply use VARCHAR for all character data in the database. As a result, every time one of these columns is compared to a fixed character column or host variable, the programmers will have to use an RPAD or RTRIM function, since programming languages won't do automatic padding on VARCHAR columns. Because the database cannot simply search the values in the index when a function is applied to a key column queries may unexpectedly take much longer to complete. So the time that was saved in the design phase will probably be spent many times over trying to determine why certain queries are running so poorly.
Home > Computers > Databases > Design > CHAR vs. VARCHAR > Char. Padding
Viewing mobile website page. Switch to WML or Full HTML