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

Home -> Community -> Usenet -> c.d.o.tools -> Re: char vs varchar2

Re: char vs varchar2

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 2000/07/01
Message-ID: <8jksl5$2nf$1@nnrp1.deja.com>#1/1

In article <8ji7rc$6u2$1_at_nnrp1.deja.com>,   Mark D Powell <markp7832_at_my-deja.com> wrote:
> In article <1kZ65.2367$Dr3.145406_at_monolith.news.easynet.net>,
> "gi" <gi_at_england.com> wrote:
> > Can someone tell me ...but who really knows
> > if I have filled with length is there any difference if I use char
 (1)
 or
> > varchar2(1)
> > I read somewhere that char is there only because COBOL programs but
 I'm not
> > sure is that true
> > Thanks
> >
> In general you should probably use varchar2(n) in preference to char
> (n). In the case of varchar2(1) vs char(1) [the default] then there
 is
> one byte per column of less overhead when using char. Varchar2 saves
> space by not storing trailing blanks which can result in more rows per
> block being stored and hence less I/O to retrieve the rows. It also
> helps elimanates mismatches caused by comparing columns with the same
> first x characters but a different number of trailing characters.

actually a CHAR is implemented as a VARCHAR that is always stored blank padded. Hence it too has the leading byte field. A char(1) and varchar2(1) take the same amount of space as both have the leading byte counts...

> --
> Mark D. Powell -- The only advice that counts is the advice that
> you follow so follow your own advice --

>

> Sent via Deja.com http://www.deja.com/
> Before you buy.

>
--
Thomas Kyte (tkyte_at_us.oracle.com) Oracle Service Industries
Howtos and such: http://osi.oracle.com/~tkyte/index.html
Oracle Magazine: http://www.oracle.com/oramag
Opinions are mine and do not necessarily reflect those of Oracle Corp


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Sat Jul 01 2000 - 00:00:00 CDT

Original text of this message

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