Difference between number and integer datatype in oracle dictionary views

后端 未结 3 1663
傲寒
傲寒 2020-12-08 06:45

I used oracle dictionary views to find out column differences if any between two schema\'s. While syncing data type discrepancies I found that both NUMBER and INTEGER data t

3条回答
  •  北海茫月
    2020-12-08 07:02

    the best explanation i've found is this:

    What is the difference betwen INTEGER and NUMBER? When should we use NUMBER and when should we use INTEGER? I just wanted to update my comments here...

    NUMBER always stores as we entered. Scale is -84 to 127. But INTEGER rounds to whole number. The scale for INTEGER is 0. INTEGER is equivalent to NUMBER(38,0). It means, INTEGER is constrained number. The decimal place will be rounded. But NUMBER is not constrained.

    • INTEGER(12.2) => 12
    • INTEGER(12.5) => 13
    • INTEGER(12.9) => 13
    • INTEGER(12.4) => 12
    • NUMBER(12.2) => 12.2
    • NUMBER(12.5) => 12.5
    • NUMBER(12.9) => 12.9
    • NUMBER(12.4) => 12.4

    INTEGER is always slower then NUMBER. Since integer is a number with added constraint. It takes additional CPU cycles to enforce the constraint. I never watched any difference, but there might be a difference when we load several millions of records on the INTEGER column. If we need to ensure that the input is whole numbers, then INTEGER is best option to go. Otherwise, we can stick with NUMBER data type.

    Here is the link

提交回复
热议问题