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: Do number(38)'s waste space?

Re: Do number(38)'s waste space?

From: Joel Garry <joelga_at_pebble.org>
Date: Fri, 08 May 1998 23:26:17 GMT
Message-Id: <slrn6l755n.buh.joelga@pebble.org>


On Fri, 8 May 1998 20:09:28 +0100,
Steve Haynes <steve_at_rwx777.demon.co.uk> wrote:

>Hi All,
>My question relates to 7.3.3 and 8.0.4.
>In a large table, if number(38)'s are used
>but only populated with, say, 10 digits is
>any space wasted. Also if this number is later

No.

>updated to, say, 20 digits could this cause
>row chaining - or at best data fragmentation

Yes.

>within the block?
>Same question on varchar2 actually, I heard
>that over vachar2(255), 2 bytes are needed to
>store the length, so if you store less than 255
>chars in a, say, varchar2(300) then you waste
>two bytes per row.

No. (One byte wasted, because the shorter varchar would still take one.)

>Can anyone verify this?
>Thanks

tkyte said it best:

> > > 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.
> > >

>Steve
>--
>"The floggings will continue until morale improves."
>

--
These opinions are my own and not necessarily those of Information Quest

jgarry@eiq.com                           http://www.informationquest.com

http://ourworld.compuserve.com/homepages/joel_garry "See your DBA?" I AM the @#%*& DBA! Received on Fri May 08 1998 - 18:26:17 CDT

Original text of this message

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