When to use CHAR and VARCHAR

Abstract: When to use CHAR and VARCHAR

Problem: When to use CHAR and VARCHAR Solution: As a guideline: The rule for CHAR and VARCHAR is to use CHAR only for strings whose length you know to be fixed. For example, if you define a domain whose values are restricted to 'T' and 'F', you should probably make that CHAR[1]. If you're storing US social security numbers, make the domain CHAR[9] (or CHAR[11] if you want punctuation). Use VARCHAR for strings that can vary in length, like names, short descriptions, etc. Use VARCHAR when you don't want to worry about stripping trailing blanks. Use VARCHAR unless there's a good reason not to. Use CHAR when you're defining external tables. VARCHAR includes a two-byte binary prefix that contains the effective length of the string. That's a nuisance in an external file - your text editor won't like it at all. Source: Ann Harrison Mers listserve