Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: varchar(2) use
Excellent!!!
You don't know how many times I've had to argue against the use of char(). I've heard a million people state how they use char() for "small" fields to save a byte or two.
Your post was right on the money.
I don't like char() because it messes up indexed searches (is it 'smith' or 'smith '), and because it wastes a lot of space in big fields.
char() is okay for 1 byte fields, but I'd rather use varchar2 everywhere.
Is anyone using varchar instead of varchar2 yet?
Thomas Kyte wrote:
>
> In Oracle, a char is a varchar that is blank padded to a maximum length. A char
> has the same leading byte(s) length field a varchar2 does.
>
> a char(5) will always take either 0, 1 or 6 bytes,
> - 0 if null and at end of table
> - 1 if null and in the 'middle' of the table
> - 5 for the string, 1 for the length if not null, even if it contains just
> 'x' it will really be 'x '
>
> a varchar2(5) will take somewhere between 0 and 6 bytes depending on the data.
>
> In the case of a varchar2(1) and a char(1), it would really be 6 one way, 1/2
> dozen the other... they will be the same.
-snip-
>
> 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
Will.
-- ====================================================================== Will Kooiman Computer Systems Authority Systems Consultant 6380 LBJ Freeway, Suite 181 (972) 960-0180 x236 Dallas, TX 75240 mailto:wkooiman@csac.com http://www.csac.comReceived on Thu May 29 1997 - 00:00:00 CDT