views:

59

answers:

2
  • char
  • varchar
  • varchar2

I understand that varchar2(10) will allocate space dynamically upto 10 bytes. char(10) will allocate 10 bytes at the beginning and fill it with junk if the actual datalength is less.

If this is correct, what does varchar(10) do?

+3  A: 

I think this explains it directly http://www.orafaq.com/faq/what_is_the_difference_between_varchar_varchar2_and_char_data_types

nonnb
Becareful with that FAQ. There is much misinformation contained within. False claims include, but are not limited to: `CHAR` is faster than `VARCHAR`, the max size of `VARCHAR` and `VARCHAR2` ar different. `VARCHAR` follows the ANSI standard. (It doesn't, Oracle's `VARCHAR` can not hold a zero length string. Zero length strings are equiv to `NULL` in Oracle.)
Shannon Severance
@Shannon, the FAQ itself is correct - it does say `VARCHAR` and `VARCHAR2` are identical - but your warning does apply to the comments that people have added.
Jeffrey Kemp
+2  A: 

It is all covered quite comprehensively in the Oracle documentation.

Tony Andrews