Different between oracle datatypes char20 and varchar20?
In Oracle, the char(20) datatype is a fixed length character
string. It will always use 20 characters in the block. If the value
contained in the field is less than 20 characters, it will be
padded on the right (or the left, depending on coding) with
spaces.
In Oracle, the varchar(20) datatype is a variable length
character string. It will use betwen 1 and 21 characters in the
block, 1 for the length, and 0-20 for the data. Its effective
length can range between 0 and 20 characters. Note, however, that a
string of length 0 is indistinguishable from a null value. This is
a deviation from the SQL standard that Oracle acknowledges, but
fixing it would break too much existing code.
Note also that comparing a char against a varchar is
problematic. With the trailiing spaces, the char is not the same as
a varchar containing the same characters. Predicates involving
these mixed types should use the rtrim expression on the char
datatype. (Example: while rtrim(mycharvalue) = myvarcharvalue)
Note also that varchar is obsolete. Current code should use
varchar2, such as varchar2(20).