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: [OT] Index on Number & Varchar2

Re: [OT] Index on Number & Varchar2

From: Rob Cowell <rjc4687_at_hotmail.com>
Date: Wed, 3 Dec 2003 11:38:34 +0000 (UTC)
Message-ID: <3FCDCB39.7C03B296@hotmail.com>

Hilarion wrote:
>
> > [...]
> > varchar2(10) takes 10 bytes, assuming all
> > positions are used.
> >
> > Varchar2(20) only takes 10 bytes if it's only storing 10 characters.
> > [...]
>
> Hmm... If we have VARCHAR2(20) storing 10 chars, then how can you
> store it on 10 bytes?
> Where from you take the information about string
> length, or string ending?
> I do not know where from I know it, so I can be wrong, but I think
> that a 10 char string takes 11 bytes (10 chars + 1 byte string ending mark).
> If it's not so, then what is the CHAR type for? (String stored in CHAR
> column has always as many chars as defined, so it does not have to
> use string ending mark.)
> Please correct me if I'm wrong.
>
> Hilarion

You're quite right. I was trying to explain that its what the varchar2 holds that is significant, not the size of the varchar2.

A varchar2(20) holding 10 characters takes 10 bytes.

A number(10) holding 10 characters takes 6 bytes.

Both ways (I think) you have to add a 1 byte column overhead. Received on Wed Dec 03 2003 - 05:38:34 CST

Original text of this message

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