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: Number vs Number(x)

Re: Number vs Number(x)

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/12/09
Message-ID: <348e7364.8909290@inet16>#1/1

On Tue, 9 Dec 1997 14:21:44 GMT, Douglas Scott <Douglas.S.Scott_at_boeing.com> wrote:

>If you are defining a field in a table that will contain integer data is
>it better to define the field with respect to its associated length (if
>max value will be 999 then define field as NUMBER(3)) or to generically
>define it as NUMBER?
>
>Douglas Scott
>Douglas.S.Scott_at_boeing.com

Performance wise, storage wise it will have not have an impact if you use NUMBER or NUMBER(3).

Application wise, it will make a big difference. NUMBER(3) is similar to creating a table like:

create table T1
( x number check ( round(x) between -999 and 999 ) )

with a trigger:

...
begin

   :new.x := round(:new.x);
end;
...

The number(3) will behave like a constraint and a rule, it will - force the value of X to be between -999 and 999 and - to be 3 digits (inserting the value 1.5 into a number(3) returns 2).

If that fact is important to your application, or you wish to capture into the data dictionary the fact that the total number of digits is three and it contains no decimal points, then use NUMBER(3).....  

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  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Tue Dec 09 1997 - 00:00:00 CST

Original text of this message

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