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: Key Columns: char vs. number

Re: Key Columns: char vs. number

From: Nuno Souto <nsouto_at_nsw.bigpond.net.au>
Date: Fri, 25 Jun 1999 01:32:54 +1000
Message-ID: <7ktkk4$htm$1@m2.c2.telstra-mm.net.au>


This "number better than char for key" thing unfortunately made the rounds a few years ago. Some "experts" who consider that all tables must have a numeric PK and other such pearls of wisdom were given too much importance. Probably their DB2 background made them into "ORACLE experts", although I still fail to see why that should be so...

As a result, there is a crop of people around who think these things are in any way true.

There is no such thing as numeric fields being better for PK or indexes than char or varchar. Each case has to be examined and the required data type used for PK or index, that's all.

BTW, number types are not necessarily fixed length. If you define them as NUMBER(n) with "n" being the precision you want, they do NOT take up 22 bytes! There was an old version of ORACLE where any column defined as NUMBER (without the precision) would always take 22 bytes, but I believe that has been fixed. Nowadays, number columns are variable length as is the length of a number value. Check out the "book" on section data types.

--
Cheers
Nuno Souto
nsouto_at_nsw.bigpond.net.au.nospam
Is there a nospam domain?
http://www.users.bigpond.net.au/the_Den Jens Mayer <jmayer_at_ratundtat.com> wrote in message news:3771df06.6172285_at_news.space.net...
> Hi folks,
>
> yesterday I had a discussion with an Oracle-experienced friend about
> the question: is ist better to use CHAR or NUMBER datatypes in Key
> Columns, eg. in a Primary Key ?
>
> Until now I thought that it's better to use CHAR, because NUMBER
> takes 22 Bytes of Space in each case. My friend mentioned, that using
> NUMBER in Key Columns makes better performance.
>
> Who is right ?
Received on Thu Jun 24 1999 - 10:32:54 CDT

Original text of this message

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