Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: VARCHAR2 vs CHAR

Re: VARCHAR2 vs CHAR

From: Kevin Kirkpatrick <kjk_at_hrb.com>
Date: Tue, 13 Oct 1998 15:58:08 -0400
Message-ID: <3623B0CF.A3A359B3@hrb.com>


I have one rule of thumb, use VARCHAR2! That isn't entirely true though. I typically use VARCHAR2 for everything. But there are two things you need to consider. First, a CHAR is blank padded whereas a VARCHAR2 isn't. For example, if you allocate 10 characters for a char and don't use all 10, the rest are space padded. This becomes a problem in certain situations, like string comparison. Second, whether you use all 10 characters or not, you will have length 10. A VARCHAR2 is variable length, so this saves on storage space...

Bottom line:

    Use CHAR when the trailing blanks aren't going to matter for string comparisons

    Use VARCHAR if trailing blanks would matter in string comparisons, or if you want to store values more efficiently

There is also the difference in size, a CHAR can be up to 255 characters in length, whereas a VARCHAR can be 2000

That is it in a nutshell!

Good luck
Kevin

Jeffrey A. Thompson wrote:

> I'm new to ORACLE. Is there a rule of thumb of when to use VARCHAR2 instead
> of CHAR.
>
> Thanks.
Received on Tue Oct 13 1998 - 14:58:08 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US