Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: [OT] Index on Number & Varchar2
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
![]() |
![]() |