ORACLE int number

Source: Internet
Author: User

When creating an ORACLE int number table, if it is a floating point number, it is generally set to number (m, n) [m is precision, n is decimal place, so the integer is m-n], set the integer to integer. For example: create table abc (a number (), B number (38) c integer, d number), then a, B, c, d. What are the differences? A and B are actually the same, all of which are 38 BITs. Is c the same as a and B? After the test, it is different. The maximum value of c can reach 9e125, which is obviously far greater than the 38-bit range. What is the difference between d and a, B, and c? First, d can be placed in decimal places, in addition, its scope is also far greater than 38 BITs. I am not clear about the specific differences between the, B, c, and d types. I hope some experts can explain it clearly, I am here to introduce myself. I used to think that integer = number (10,126) -- 38 is the maximum precision of number. I accidentally found that integer is an extremely large data type, and the maximum value can be expressed as power) -1: How many bytes is required for such a large number? Because one byte represents 256 at the maximum, N Bytes represent power (256, n)> = power (10,126) calculate the N: solution: select LOG (126) * from dual, the solution is 53, that is, an integer type uses at least 53 bytes. Therefore, I think the Integer type should be used as few as possible, and such a large number is rarely used. In particular, some people process the boolean type, because the Oracle table structure does not have a boolean type, so many people simply replace the Boolean Type with integer, which is a bit "luxury"; I usually use char (1) to represent the boolean type; '0' to indicate false, '1' indicates true. In addition, for example, varchar2 (200), it is dynamically allocated, so the string occupies space according to the actual usage, however, integer is fixed and uses at least 53 bytes for the time being. In most cases, the integer type is not recommended. Even in pl/SQL, integer is not used when defining variables; you can use binary_integer or pls_integer; A new integer exists in the 11g, which is more efficient. It is called simple_integer. It is better not to use integer anyway. Efficiency Test: simple_integer> pls_integer> binary_integer> integer;

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.