What does it mean when the size of a VARCHAR2 in Oracle is declared as 1 byte?

AndreaNobili picture AndreaNobili · Jun 16, 2015 · Viewed 112.8k times · Source

I know that I can declare a varchar2 using the number of the characters that it should be able to contain.

However, in an Oracle database on which I am working, I found that a field (named PDF) is defined as follows:

VARCHAR2(1 BYTE)

What does this mean? How many characters can it contain?

Another, related question: What is the difference between a VARCHAR and a VARCHAR2?

Answer

Rene picture Rene · Jun 16, 2015

You can declare columns/variables as varchar2(n CHAR) and varchar2(n byte).

n CHAR means the variable will hold n characters. In multi byte character sets you don't always know how many bytes you want to store, but you do want to garantee the storage of a certain amount of characters.

n bytes means simply the number of bytes you want to store.

varchar is deprecated. Do not use it. What is the difference between varchar and varchar2?