Oracle VARCHAR2(1) vs CHAR(1)?

Well, minimum size for both Oracle datatypes is 1 byte. So in terms of storage, they’ll both consume either null or 1 byte in storage space. So, when declaring a character datatype with a length of 1, it doesn’t really matter which one you use. The rules change when the length is greater than 1 though.

This is because CHAR is a fixed character data, so values held in this datatype is always RPAD’ed with blanks. Storing character data as VARCHAR2 will save space on, not just the character field, but any indexes that reference it.

As a personal preference, I always use VARCHAR2. The most important practice though is to be consistent. For example, if you use CHAR for a 1 byte character datatype and VARCHAR2 for everything else, then stick with it throughout your whole database.

You may also like...

2 Responses

  1. Richard says:

    Doesn’t a varchar2 need to know the lenght of the string to store? I think so, therefore a varchar2(1) needs two bytes, one for the actual value and one to store the length of the stored string whereas a char(1) uses one byte period.

  2. ryelpango says:

    Richard,
    VARCHAR2(1 BYTE) consumes 1 byte, period.
    VARCHAR2(1 CHAR) can consume up to 4 bytes for a Unicode character.

Leave a Reply

Your email address will not be published. Required fields are marked *