CHAR Datatype Oracle VARCHAR2

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.

2 replies on “Oracle VARCHAR2(1) vs CHAR(1)?”

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.

Leave a Reply

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