Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default Precision and Scale for a Number in Oracle?

When creating a column of type NUMBER in Oracle, you have the option of not specifying a precision or scale. What do these default do if you don't specify them?

like image 374
Matt Avatar asked Feb 27 '09 01:02

Matt


People also ask

What is the default precision for number in Oracle?

The default precision for this data type is 126 binary, or 38 decimal.

What is precision and scale in number Oracle?

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. s is the scale, or the number of digits from the decimal point to the least significant digit. The scale can range from -84 to 127.

What is precision and scale in numeric data type?

Precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in a number. For example, the number 123.45 has a precision of 5 and a scale of 2. In SQL Server, the default maximum precision of numeric and decimal data types is 38.


2 Answers

NUMBER (precision, scale)

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

A lot more info at:

http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1832

like image 172
Angelo Marcotullio Avatar answered Sep 20 '22 22:09

Angelo Marcotullio


The NUMBER type can be specified in different styles:

                 Resulting  Resulting  Precision Specification   Precision  Scale      Check      Comment ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― NUMBER          NULL       NULL       NO         'maximum range and precision',                                                  values are stored 'as given' NUMBER(P, S)    P          S          YES        Error code: ORA-01438 NUMBER(P)       P          0          YES        Error code: ORA-01438 NUMBER(*, S)    38         S          NO 

Where the precision is the total number of digits and scale is the number of digits right or left (negative scale) of the decimal point.

Oracle specifies ORA-01438 as

value larger than specified precision allowed for this column

As noted in the table, this integrity check is only active if the precision is explicitly specified. Otherwise Oracle silently rounds the inserted or updated value using some unspecified method.

like image 22
maxschlepzig Avatar answered Sep 23 '22 22:09

maxschlepzig