"Go" Oracle Database Number data type

Source: Internet
Author: User
Tags rounds

Original: http://www.jb51.net/article/37633.htm Number (precision, scale)
A) precision represents a valid bit in the number, and if no precision is specified, Oracle uses 38 as the precision.
b) If scale is greater than 0, indicates the number of digits to the right of the decimal point, the default setting of scale is 0, and if scale is less than 0, Oracle will trade the number to the specified number of digits to the left of the decimal point.
c) The value range for precision is "1---38" and the value range for scale is " -84---127".
d) The number integer part allows the length to be (Precision-scale), regardless of whether the scale is positive or negative.
e) If precision is smaller than scale, it means that there are no integers stored in decimals.
f) Precision indicates the number of significant digits, valid digits: The decimal point and the minus sign do not count toward the number of significant digits from the first number on the left that is not 0Scale indicates the exact number of bits, which means The exact number of digits to the left or right of the decimal point (+-).
G Example of number value type:

Actual value

Data type

Store value

1234567.89

Number

1234567.89

1234567.89

Number (8)

1234567

1234567.89

Number (6)

Error

1234567.89

Number (9,1)

1234567.9

1234567.89

Number (9,3)

Error

1234567.89

Number (7,2)

Error

1234567.89

Number (5,-2)

1234600

1234511.89

Number (5,-2)

1234500

1234567.89

Number (5,-4)

1230000

1234567.89

Number (*,1)

1234567.9

0.012

Number (2,3)

0.012

0.23

Number (2,3)

Error


h) For precision, scale can also be expressed as follows
The precision of the fixed-point number (p) and scale (s) follows the following rules:
1) Oracle will error when the length of the integer part of a number > P-s
2) When the length of a number of decimal parts > S, Oracle rounds.
3) when S (scale) is negative, Oracle rounds the s number to the left of the decimal point.
4) When s > P, p indicates the number of digits to the left of the S bit after the decimal point, and if the Oracle error is greater than P, the number of s bits to the right after the decimal point is rounded

Subclass of Number Type
A) Oracle does not already have an int type, and in order to be compatible with another database, the int type is added as a subset of the number type.
b) The int type can store only integers, number can store floating-point numbers, or integers can be stored.
c) When the Oracle database is built, Decimal,numeric does not have precision, and Oracle automatically handles it as an integer, with precision, and Oracle automatically processes it to number.
d) Oracle can represent any complex digital data using only number (M,N).
e) decimal,numeric,int such as SQL, DB2 and other database data types, Oracle for compatibility before the introduction of it, but in fact inside Oracle or in the form of a number to deposit.

"Go" Oracle Database Number data type

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.