The Oracle (tm) Users' Co-Operative FAQ

Why should I use varchar2 instead of char types ?

Author's name: Martin Haltmayer

Author's Email:

Date written: 14 June 2001

Oracle version(s): 8.1.7

Are there any reasons why the varchar2() data type is generally more appropriate than the char() data type for character data ?

Back to index of questions

Several reasons for using varchar2 instead of char:

1. char (xx) will always rpad data with blanks. This is a guarantee for surprises when comparing data and using indexes for searches because implicit conversion strikes. Please look up the rules for implicit conversions.

2. A value of char will always consume full space in the database because it is padded. Therefore, indexes grow bigger and searches are slower.

3. As opposed to a wide-spread misunderstanding, char (1) does *not* use less space in the database than varchar2 (1) when the value 'a' is stored because also char (1) has a length field. This can be proved by the dump () function.  

Further reading: N/A

Back to top

Back to index of questions