Is “NUMBER” and “NUMBER(*,0)” the same in Oracle?

前端 未结 3 1432
死守一世寂寞
死守一世寂寞 2021-02-04 17:44

In Oracle documentation it is mentioned that

NUMBER (precision, scale)

If a precision is not specified, the column stores values as given. I

3条回答
  •  抹茶落季
    2021-02-04 18:37

    I think the sentence in the documentation

    If a precision is not specified, the column stores values as given. If no scale is specified, the scale is zero.

    is a bit confusing. The scale is zero if a precision is specified and a scale is not specified. So, for example, NUMBER(19) is equivalent to NUMBER(19,0). NUMBER, by itself, will have 38 digits of precision but no defined scale. So a column defined as a NUMBER can accept values of any scale, as long as their precision is 38 digits or less (basically, 38 numerical digits with a decimal point in any place).

    You can also specify a scale without a precision: NUMBER(*, ), but that just creates the column with 38 digits of precision so I'm not sure it's particularly useful.

    The table How Scale Factors Affect Numeric Data Storage on this page might be helpful.

提交回复
热议问题