Oracle Database Numeric type

Source: Internet
Author: User
Tags rounds

---restore content starts---

Content excerpted from the network

Oracle's numeric types are int,number,float,decimal,numberic and so on.

Number Type
definition

Definition Format number (Precision,scale)

The precision represents a valid bit in a number (from the first number on the left that is not 0, the decimal point and minus sign do not count toward the number of significant digits), and the value range is "1-38" by default 38.

The scale represents the exact number of bits, with a value range of "84-127" and a default value of 0. Greater than zero, indicating the number of digits to the right of the decimal point, less than 0 o'clock, the number will be selected to the left of the decimal point of the specified number of digits, so the length of the integer part of number is (Precision-scale), whether the scale is positive or negative, and, If precision is less than scale, it means that there are no integers stored in decimals.

The accuracy (p) and scale (s) of number are subject to 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

Case

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

Subclass of Number Type

Decimal,numeric,int, such as SQL, DB2, and other database data types, Oracle for compatibility before they are introduced, but in fact, inside Oracle or number in the form of the deposit, so on the collection relationship they are also a subset of number.

The int type can only store integers;

When the Oracle database is built, the decimal,numeric is not precision, and Oracle automatically handles it as an integer, with precision, and Oracle automatically processes it to number.

Oracle can represent any complex numeric data using only number (M,N).

---restore content ends---

Oracle Database Numeric 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.