Largest number of digits for NUMBER datatype?

What is the largest length of a NUMBER that Oracle will "support"?
The documentation says the following:
     Datatype Limits indicates:
         "Can be represented to full 38-digit precision"
     NUMBER Data Types indicates:
          "Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point."
I realize if I define a column as simply NUMBER, I can insert numbers with a size up to 126 digits.  However, Oracle seems to only maintain the first 40 digits IN MOST cases.  The most number of digits it seems to allow is 40 before it starts to replace with 0's.
With numbers that have more than 40 digits, Oracle will sometimes replace any numbers after the 38th digit with a 0 and other times will replace with 0 after the 39th or 40th digit.
Therefore, what is the most number of digits we can have confidence in Oracle storing safely?
This was the code I used for testing this process.
create table max_num (num number);
declare
  l_x number;
begin
  for x in 1..200
  loop
    l_x := x;
    insert into max_num values (rpad(1, x, 1));
  end loop;
  exception
  when others then
    dbms_output.put_line('STOP: '||l_x);
    dbms_output.put_line(sqlerrm);
end;
select num, length(replace(num, 0)) from max_num;

Hi,
user109389 wrote:
What is the largest length of a NUMBER that Oracle will "support"?
The documentation says the following:
     Datatype Limits indicates:
         "Can be represented to full 38-digit precision"
     NUMBER Data Types indicates:
          "Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point."
I realize if I define a column as simply NUMBER, I can insert numbers with a size up to 126 digits.  However, Oracle seems to only maintain the first 40 digits IN MOST cases.  The most number of digits it seems to allow is 40 before it starts to replace with 0's.
With numbers that have more than 40 digits, Oracle will sometimes replace any numbers after the 38th digit with a 0 and other times will replace with 0 after the 39th or 40th digit.
Therefore, what is the most number of digits we can have confidence in Oracle storing safely?...
If the documentation says 38, then I'll say 38, too.
If you put in a number greater than or equal to 1E39, then Oracle may round it to 38 significant digits; that is, the last digits you entered may get turned to 0's, or rounded up.

Similar Messages

  • How to convert number datatype to raw datatype for use in data warehouse?

    I am picking up the work of another grad student who assembled the initial data for a data warehouse, mapped out a dimensional dw and then created then initial fact and dimension tables. I am using oracle enterprise 11gR2. The student was new to oracle and used datatypes of NUMBER (without a length - defaulting to number(38) for dimension keys. The dw has 1 fact table and about 20 dimension tables at this point.
    Before refining the dw further, I have to translate all these dimension tables and convert all columns of Number and Number(n) (where n=1-38) to raw datatype with a length. The goal is to compact the size of the dw database significantly. With only a few exceptions every number column is a dimension key or attribute.
    The entire dw db is now sitting in a datapump dmp file. this has to be imported to the db instance and then somehow converted so all occurrences of a number datatype into raw datatypes. BTW, there are other datatypes present such as varchar2 and date.
    I discovered that datapump cannot convert number to raw in an import or export, so the instance tables once loaded using impdp will be the starting point.
    I found there is a utl_raw package delivered with oracle to facilitate using the raw datatype. This has a numbertoraw function. Never used it and am unsure how to incorporate this in the table conversions. I also hope to use OWB capabilities at some point but I have never used it and only know that it has a lot of analytical capabilities. As a preliminary step I have done partial imports and determined the max length of every number column so I can alter the present schema number columns tp be an apporpriate max length for each column in each table.
    Right now I am not sure what the next step is. Any suggestions for the data conversion steps would be appreciated.

    Hi there,
    The post about "Convert Numbers" might help in your case. You might also interested in "Anydata cast" or transformations.
    Thanks,

  • Using number datatype for date column

    Hi
    Is there a side effect for using "number" datatype for "date" column?
    If so, what is the disadvantage?
    Many thanks

    Hi,
    Ora_83 wrote:
    Hi
    Is there a side effect for using "number" datatype for "date" column?
    If so, what is the disadvantage?Yes, there's a definite disadvantage.
    Oracle provides date arithmetic and a number of functions for manipulating DATEs. None of them work with numbers.
    For example,
    SELECT    TRUNC (order_date, 'MONTH')     AS order_month
    ,       AVG (ship_date - order_date)     AS avg_delay
    FROM       orders
    GROUP BY  TRUNC (order_date, 'MONTH')
    ;order_month involves a DATE function; it's pretty easy to find the month that conatins order_date.
    avg_delay involves date arithmetic. It's extrememly easy to find how much the time passed between order_date and ship_date.
    Depending on how you code dates as numbers, doing either one of the above may be just as easy, but doing the other will be very difficult. You'll waste a lot of effort converting the NUMBERs to real DATEs whenever you need to manipulate them.
    Validation can be very difficult for NUMBERs, also.
    Watch this forum. It's a rare day when there's not some question about how to get around a problem caused by storing dates in a NUMBER (or VARCHAR2) column. Don't add to that. Always use DATE columns for dates.

  • Understanding number datatype [A help for beginners]

    I would like to share some practical aspects of Oracle Number datatype. Please visit following link.
    http://mamohiuddin.blogspot.com/2007/03/practical-approach-to-understand-oracle.html
    Thank you,
    aijaz

    My only comment would be, since this posting of yours is being made in March 2007, wouldn't it make sense to ensure that it's all correct for the latest version of Oracle (10.2) as 9iR2 is a little "old hat" now. I'm not saying that there is anything wrong with what you've demonstrated, but you only quote it as being compatible with 9iR2 and 10.2 has now been available for a good couple of years.

  • Number datatype

    Hi
    Assume I have 5 digits 2 numbers (as below). I notice that they do not occupy the same space.(First one consumes more storage.)
    What is the reason for this?
    99999
    10000
    Edited by: Pascal Nouma on Aug 15, 2009 6:42 PM

    Justin Cave wrote:
    Oracle, like all programs, stores numbers in binary. It takes more binary bits to store larger numbers than smaller numbers even if they have the same number of decimal digits.Actually, NUMBER datatype is not stored in binary - [Understanding Oracle NUMBER Datatype|https://metalink2.oracle.com/metalink/plsql/f?p=130:14:7587170171678335381::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,1007641.6,1,1,1,helvetica]. And yes, 99999 and 10000 do not occupy same number of bytes:
    SQL> select dump(99999) from dual;
    DUMP(99999)
    Typ=2 Len=4: 195,10,100,100
    SQL> select dump(10000) from dual;
    DUMP(10000)
    Typ=2 Len=2: 195,2Reason is 10000 is exact value of POWER(100,2). As soon as we, for example, add or subtract 1 space occupied will increase:
    SQL> select dump(10001) from dual;
    DUMP(10001)
    Typ=2 Len=4: 195,2,1,2
    SQL> select dump(9999) from dual;
    DUMP(9999)
    Typ=2 Len=3: 194,100,100
    SQL> As you can see, number with more decimal digits can occupy less space.
    SY.

  • Finding the 25th largest number in an array

    How would I say find the 25th largest number in an array?
    Or nth largest number?
    Chris

    I find most of these answers correct, but without previous knowledge of the size of the array, I would do things differently.
    In the enclosed VI, a cluster is formed of all array values and their index. When the array is then sorted, the first cluster element is used as the first sort criterium, then the second cluster element. This allows a single array operation (Sorting) to take care of any searching, whilst the cluster retains the index of the original array.
    Coupling this method with an unitialised shift register, you can also cache the sorted array to allow for more rapid processing if you require more than a single indexed value.
    Another way to achieve this is (Assuming you`re seeking the 25 largest) to simply get the max and min at t
    he very beginning, feed the array into a loop with a shift register, set the value at the index returned for max each run to the initial min value -1, and repeat another 24 times.
    Regarding memory use and execution speed, I`m not sure if searching an array 25 times is quicker than a single sort or not (No new array is created), but both versions are viable.
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    Get_Nth_largest-smallest_(6.1).vi ‏31 KB
    Get_Nth_largest-smallest_(6.1)_-_version_2.vi ‏42 KB

  • Find - tables with largest number of records?

    Hi,
    I need to find tables with largest number of records. Any transaction show this details?
    aRs

    Go to transaction DB02,  then click on the button that reads,  "Space Statistics", the dialog box, click ok, leave the "*" for all tables,   In the next screen put your cursor in the appropriate column labeled as Rows and click the sort button.  Now you will see your biggest tables at the top of the list.
    Regards,
    Rich Heilman

  • Problem with number datatype dimension in BIB

    Hi,
    I've got a problem. When I create dimension with number datatype and I assign it to my cube, I cannot use my cube with my BIB presentation object - such as Crosstab. Is this possible only with varchar dimensions?

    It should work, but it would be helpful if you could specify more information, for example which errormessage you are seeing and where.

  • Compute two largest number

    i created an array. i am able to compute the largest number in array but my problem now is how can i compute the second largest number? do i need an if/else statement again to compute the second largest number if i have to then i am pretty much sure i need a condition so that it will not print the 1st largest number again. or do i need another for loop to compute the second largest number ? any idea how can i do that i dont want to post the code since i want to complete the exercise by myself. after your suggestions if i cannot solve it then i will be happy to post my code. But i will solve it :).
    Thanks
    Message was edited by:
    fastmike

    got it.
    import java.io.* ;
    class TwoLargest
      public static void main ( String[] args ) throws IOException
        int[] data = {3, 1, 5, 7, 4, 12, -3, 8, -2};
        int max = data[0];
        int max1 = data[0];
        int min = data[0];
        // compute the two largest
        for ( int index=0 ; index < data.length; index++)
             if(data[index]>max ) {
             max = data[index]; }
             if(data[index]<min) {
                  min = data[index];
          if(data[index]>max1 && data[index]<max) {
               max1 = data[index];
        // write out the two largest
        System.out.println( "the max is " + max + "The largest is " + max1);
    }      Thanks a bunch guys time to go to bed now thanks conan and Cap.

  • Preceeding Zeros in Number datatype

    Hello all
    Is there any way to store values with preceeding zeros in Oracle Number datatype (eg : person code: 00089034)
    Thanks in advance

    Yes it is possible, by storing it as a varchar2. However I would advice you to store the number as a number, and use a format mask for display:
    SQL> select to_char(89034,'00000009') from dual;
    TO_CHAR(8
    00089034
    1 rij is geselecteerd.Regards,
    Rob.

  • Problem while modifying number datatype.

    Hi All,
    I have modified a column, which is of number datatype.
    Initially it was number(8,2), now I have changed this to Number(10,2).
    But, due to some change in requirement, I have to revese the changes. Now, I am trying to make it Number(8,2), but it is giving me the following error.
    Error report:
    SQL Error: ORA-01440: column to be modified must be empty to decrease precision or scale
    01440. 00000 - "column to be modified must be empty to decrease precision or scale"
    Is there a way to make it?
    Please suggest..
    I am using Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production.
    Thnx in advance..
    Bits..

    You'd have to jump through some hoops to decrease the allowable number of digits in a column. You'd either have to re-create the table, i.e.
    -- Save off the data in FOO
    ALTER TABLE foo
      RENAME TO foo_bkup;
    CREATE TABLE foo (
      -- New column definitions
    INSERT /*+ APPEND */ INTO foo( list_of_columns )
      SELECT list_of_columns
        FROM foo_bkupOr you could create a new column, copy the data, and rename the old column
    ALTER TABLE foo
       ADD( temp_col_name number(8,2) );
    UPDATE foo
       SET temp_col_name = old_col_name;
    ALTER TABLE foo
      DROP COLUMN old_col_name;
    ALTER TABLE foo
      RENAME COLUMN temp_col_name TO old_col_name;Justin

  • Domain of Number datatype

    Hi all,
    Recently i came across one of the most wierd situation across my whole Oracle experience of almost 3 Yrs. I created a table TESTAB (using Oracle 9i) as
    NUMBER_F NUMBER
    NUMBER_PS NUMBER(5,2)
    VARCHAR_F VARCHAR2(10)
    CHAR_F CHAR(10)
    Then i inserted a row as
    Insert into testab values ('0123.23', '099.34','Asim','Ahmed');
    and it accepted the data for Number datatype in single qoutes and automatically parse it for Number datatype.!!!
    SQL> select * from testab;
    NUMBER_F NUMBER_PS VARCHAR_F CHAR_F
    1 3.34
    23 34.34
    2.23 2.33 asim ahmed
    123.23 99.34 Asim Ahmed
    Can somebody explain is that the correct behaviour ! If it is, then i must say it is really shocking behavious for such a mature database like Oracle !
    Asim Ahmed.

    This feature is called 'implicit conversion'
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/03_types.htm#3435

  • Number datatype precision

    Hello,
    Do you know what is the highest precision can be used for Number fields in CRMOD?
    In our setup we can use max 2 digits for decimal part, if you enter more value is just rounded to 2 digits.
    Is there any global setting to control it or 2 is a max precision we can use for Number fields?
    Thank you,
    Alex

    Well in terms of storing the number the 0 is not important at all. If it is important that you see the zero then you just have to apply a format mask
    SQL> r
      1  SELECT TO_CHAR(1.25, 'fm999.990')
      2* FROM sys.dual
    TO_CHAR(
    1.250Regards,
    Steve Rooney

  • How do i check number datatype with precision is 6

    Hello,
    If a variable is declared as number datatype with precision 6.
    Foe testing purpose ,i want to check which value is having precision >6
    because iam getting ORA-06502 error PL/SQL numeric or value error
    what can be the reason

    Hi Kamal,
    In my case everyday a nightly job is executed to execute the stored procs
    and stores the errors in error table,
    The complete eror description is
    error in updating grant_vest_estm_amrtzn redistributing the overlapping expense ORA-06502:PL/SQL numeric or value error
    Here is the query-- which is placed ina stored proc
    o_Error_Text := 'Error in updating GRANT_VEST_ESTM_AMRTZN redistributing the overlapping expense ' ;
    EXECUTE IMMEDIATE 'UPDATE GRANT_VEST_ESTM_AMRTZN
    SET GRN_ESTM_TRNCHE_EXPS_Y = :1,
    GRN_AMRTN_ORIGL_TRNCHE_EXPS_Y = :2,
    GRN_VEST_ADJST_OPT_Q = :3
    WHERE ORG_GRP_I = :4
    AND GRN_N = :5
    AND GRN_VEST_D = :6'
    USING V_GRN_ESTM_TRNCHE_EXPS_Y(I), V_GRN_AMRTN_ORIG_TRNC_EXP_Y(I), V_GRN_VEST_NEW_ADJST_OPT_Q(I),
    I_ORG_GRP_I, NEW_GRN(I), V_GRN_VEST_D(I);
    V_GRN_ESTM_TRNCHE_EXPS_Y(I) are calculated based on some conditions
    for example
    V_GRN_ESTM_TRNCHE_EXPS_Y (I) := V_GRN_ESTM_TRNCHE_EXPS_Y(I) +
    ( (V_REM_GRN_VEST_ORIGL_OPT_Q(I) / V_GRN_VEST_OLD_ORIGL_OPT_Q(J)) * V_GRN_ESTM_EXPS_Y(J));
    V_GRN_AMRTN_ORIG_TRNC_EXP_Y(I) := V_GRN_AMRTN_ORIG_TRNC_EXP_Y(I) +
    ( (V_REM_GRN_VEST_ORIGL_OPT_Q(I) / V_GRN_VEST_OLD_ORIGL_OPT_Q(J)) * V_GRN_ESTM_ORIGL_A(J));
    V_GRN_VEST_NEW_ADJST_OPT_Q(I) := V_GRN_VEST_NEW_ADJST_OPT_Q(I) +
    ( (V_REM_GRN_VEST_ORIGL_OPT_Q(I) / V_GRN_VEST_OLD_ORIGL_OPT_Q(J)) * V_GRN_VEST_OLD_ADJST_OPT_Q(J));
    V_REM_GRN_VEST_OLD_ORIGL_OPT_Q(J) := V_GRN_VEST_OLD_ORIGL_OPT_Q(J) - V_REM_GRN_VEST_ORIGL_OPT_Q(I);
    V_REM_GRN_VEST_ORIGL_OPT_Q(I) := 0;
    Looking forward for the response

  • When -ve scale in number datatype is used??????????

    dear friends,
    in the number datatype we specify precision and scale
    limit of precision is 1-38 & scale is -64 to 127 if i m right
    so i wll like 2 know when & how -ve scale value is used for data design
    also plz tell me how 2 declare col if expected values 2 b entered in it r like 0.0000078 etc.
    waiting for reply
    thanking you
    ganesh

    Perhaps the following will help
    SQL> create table test1 (
      2  a number(5,0),
      3  b number(5,1),
      4  c number(5,2),
      5  d number(5,-1),
      6  e number(5,-2)
      7  );
    Table created.
    SQL> insert into test1 values (1.234, 1.234, 1.234, 1.234, 1.234);
    1 row created.
    SQL> insert into test1 values (12.34, 12.34, 12.34, 12.34, 12.34);
    1 row created.
    SQL> insert into test1 values (123.4, 123.4, 123.4, 123.4, 123.4);
    1 row created.
    SQL> insert into test1 values (.1234, .1234, .1234, .1234, .1234);
    1 row created.
    SQL> insert into test1 values (.01234, .01234, .01234, .01234, .01234);
    1 row created.
    SQL> select * from test1
      2  ;
             A          B          C          D          E
             1        1.2       1.23          0          0
            12       12.3      12.34         10          0
           123      123.4      123.4        120        100
             0         .1        .12          0          0
             0          0        .01          0          0
    SQL>

  • Number datatype in designer import

    Having Designer model number datatype columns or domains that do not have Col Decimal Places defined. Only maximum length is populated. Data Modeler designer import do not populate values to Precision nor Scale. Precision should be set.

    Identifed as a code bug. According to former metalink. Tobe fixed in a future version.

Maybe you are looking for