Difference:
1. The length of the char is fixed, and the length of the VARCHAR2 is changeable, for example, storing the string "abc", for Char (20), which means that the characters you store will account for 20 bytes (including 17 null characters), while the same VARCHAR2 (20) consumes only 3 bytes of length. 20 is the maximum value, which is stored as the actual length when the character you store is less than 20 o'clock.
2. The efficiency of char is slightly higher than that of VARCHAR2.
3. Currently varchar is synonymous with VARCHAR2. The industry standard varchar type can store an empty string, but Oracle does not, although it retains the right to do so later. Oracle has developed a data type of VARCHAR2, which is not a standard varchar, and it will store null values in the database in which the varchar column stores the empty string. If you want to have backward compatibility capabilities, Oracle recommends using VARCHAR2 instead of varchar.
When should I use char and when should I use VARCHAR2?
Char and VARCHAR2 are a pair of contradictory unity, the two are complementary relations.
VARCHAR2 saves space than Char and is slightly less efficient than char, that is, to be efficient, you have to sacrifice a certain amount of space, which is what we often call "space-for-efficiency" in database design.
Although VARCHAR2 is more space-saving than char, if a VARCHAR2 column is often modified and the length of each modified data is different, this causes a ' row-migration ' phenomenon, which creates redundant I/O, which is to be avoided in database design and tuning. , it would be better to use char instead of VARCHAR2 in this case.
A space is also automatically filled in char because you insert a space automatically in a Char field, but no space is deleted after the select.
The difference between char,varchar,varchar2 in Oracle