difference:
1. The length of the char is fixed, and the length of the VARCHAR2 can vary,
Such as:
Store the string "abc",
For char (10), the characters you store represent 10 bytes (including 7 null characters).
The same VARCHAR2 (10) takes up only 3 bytes of length, and 10 is the maximum value, which is stored as the actual length when you store less than 10 o'clock characters.
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.
What are the main differences between char (10) and varchar (10)?