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

Home -> Community -> Usenet -> c.d.o.misc -> Re: efficient (in size) integer datatype?

Re: efficient (in size) integer datatype?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Tue, 19 Jan 1999 19:29:23 GMT
Message-ID: <36a7dcfc.5300061@192.86.155.100>


A copy of this was sent to wagner_at_cs.umn.edu (Paul Wagner) (if that email address didn't require changing) On 19 Jan 1999 17:53:54 GMT, you wrote:

>What would be the most efficient (in terms of minimizing storage
>space) of using INTEGER, SMALL_INT, NUMBER(3), BINARY_INTEGER, or
>NATURAL for a variable which can have values in the 0 to 255 range?
>
>I would have thought SMALL_INT, but a table in the Oracle PL/SQL
>Programming book by Steven Feuerstein/O'Reilly says that SMALL_INT
>is stored internally as NUMBER(38) (same as INT or INTEGER), which
>makes me wonder if the # of bytes to store a SMALL_INT is actually
>quite large (to handle the max. of 38 digits of precision).
>
>Thanks for any insights!
>
>Paul

Server concepts manual, chapter 6, section on "Number Datatype" includes this (and much more) about the number datatype:

<quote>
Oracle stores numeric data in variable–length format. Each value is stored in scientific notation, with one byte used to store the exponent and up to 20 bytes to store the mantissa. (However, there are only 38 digits of precision.) Oracle does not store leading and trailing zeros. For example, the number 412 is stored in a format similar to 4.12 x 10^2, with one byte used to store the exponent (2) and two bytes used to store the three significant digits of the mantissa (4, 1, 2). <quote>

So, the number 123 in a number(3) or a number(38) will consume the same exact amount of storage. Storage wise -- setting the scale and precision is not meaningful. Application wise -- setting the scale and precision is very meaningful. Fix the numbers not for the storage but for the fact that a number(3) is just that -- a number with 3 digits of precision. Consider the scale and precision to be constraints, they can edit your data.  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
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 Jan 19 1999 - 13:29:23 CST

Original text of this message

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