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: CHAR vs VARCHAR

Re: CHAR vs VARCHAR

From: Alex Filonov <afilonov_at_yahoo.com>
Date: 2 Apr 2003 11:20:45 -0800
Message-ID: <336da121.0304021120.2182ebb2@posting.google.com>


"Paul Pruchnik" <paulrp_at_earthlink.net> wrote in message news:<5eria.3978$ey1.309583_at_newsread1.prod.itd.earthlink.net>...
> Greetings,
> What is the savings of CHAR(4) vs VARCHAR(4) for storing a 4 (required)
> character code? What is the overhead in using VARCHAR for fields of required
> length?
> Thanks,
> -Paul Pruchnik

The correct question is: "What is the overhead in using CHAR". If Oracle was designed from scratch to work with both CHAR and VARCHAR, CHAR operations probably would be faster. But initially, until V7, Oracle had CHAR datatype which was the same as current VARCHAR2. And, judging by behavior, CHAR datatype uses the same code as VARCHAR2, adjusted to fixed length. Hence CHAR still has a length descriptor.
There is a conceptual difference between CHAR and VARCHAR2 when doing string comparisons. Unless all your data is exactly 4 characters, comparison operations might return different results when using CHAR vs VARCHAR2. It's described in SQL reference documentation. There is no significant difference in performance. Received on Wed Apr 02 2003 - 13:20:45 CST

Original text of this message

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