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

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

Re: VARCHAR2 vs. CHAR

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/12/10
Message-ID: <349001a8.13169116@inet16>#1/1

A varchar2 field is stored as a data field with a leading length inidicator of either 1 or 2 bytes (depending on the string length) and the data. So, a varchar2(30) with 10 characters in it will take 11 bytes.

A char fields is stored as a data field with a leading length inidicator or 1 or 2 bytes (depending on string length - O8 lets chars be 2000 bytes) and the data BLANK PADDED out to the maximum length. So a char(30) will always take either zero bytes (null at the end of the row) or 31 bytes.

So a varchar2 is stored varying length and only consumes space for the characters in it. A char is always maxed out to the maximum length and consumes all of the space.

On Wed, 10 Dec 1997 12:04:18 -0500, "Roy Chang" <roy_chang_at_mail.amsinc.com> wrote:

>
>
>Hello everbody,
>
>I had heard that if I set a field to VARCHAR2(XX), XX being less than 35 or
>so, that it wouldn't save any space or make a difference. Is this correct?
>And if so, should I change the fields that are VARCHAR2 and less than 35 to
>CHAR(XX)?
>
>Any comments would be appreciated.
>
>Thanks in advance,
>
>Roy.
>
>
>
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Wed Dec 10 1997 - 00:00:00 CST

Original text of this message

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