difference between type int and number type in Oracle

Source: Internet
Author: User
Tags id3

The int type is a subtype of number type.
The following is a brief description:
(1) Number (p,s)
This data type defines the data type, where p represents the total number of digits (the maximum number of bytes), and s represents the number of digits after the decimal point. Suppose that the definition of the SAL column number (6,2) is 4 bits (6-2=4) and the maximum number of decimal digits is 2 bits.
(2) INT type
When defining an integer type, you can use the subtype int of number directly, as the name implies: int for integer data.

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.
The int type can only store integers;
Number can store a floating-point number, or it can store integers;
Number (8,1) stores a floating-point number with a scale of 1 bits and a total length of 8, with 0 completion if the decimal place is insufficient;
Number (8) stores integers with a total length of 8;
int equals number (22) and stores an integer with a total length of 22.
To illustrate:
--CREATE TABLE structure
Sql> CREATE Table tab (ID0 int,id1 number,id2 number (8,1), ID3 number (8));

Table created

Sql>
--Inserting test data
sql> INSERT INTO tab select 1,1.5,1.6,8 from dual;

1 row inserted
sql> INSERT INTO tab select 1,1.55,1.6,8 from dual;

1 row inserted
sql> INSERT INTO tab select 1,1.595,1,8 from dual;

1 row inserted

Sql> commit;

Commit Complete

Sql> select * from tab;

ID0 ID1 ID2 ID3
---------- ---------- ---------- ---------
1 1.5 1.6 8
1 1.55 1.6 8
1 1.595 1.0 8

--Query Data dictionary table dba_tab_columns
Sql> Select Table_name,column_name,data_type,data_length,data_precision,data_scale from Dba_tab_columns a
2 where table_name= ' TAB '
3 and owner= ' Netmax '
4 ORDER by column_id;

TABLE_NAME column_name data_type data_length data_precision Data_scale
--------------- -------------- -----------------  ----------------    -----------      ----------
TAB ID0 Number 22 0
TAB ID1 Number 22
TAB ID2 Number 22 8 1
TAB ID3 Number 22 8 0

Sql>

In the Dba_tab_columns table,
Data_type indicates the field type;
Data_length indicates the length of the field type;
Data_precision indicates the total length of the precision of the field type, if NULL, the total length of the precision is not fixed, the longest is data_length;
Data_scale represents the precision range of a field type, if 0, which means that only the integer is stored.
If NULL, indicates that an integer or floating-point number can be stored, and the number of float digits is indeterminate.
If an integer, represents the number of precision bits stored.

Query the Dba_tab_columns table and find that the ID0 field type int in the tab table has been converted to number (22).

Source: http://blog.csdn.net/ojuju10/article/details/4576446

--------------------------------------------------------------------------------------------------------------- -

The difference between NVARCHAR2 and VARCHAR2 in Oracle

VARCHAR2 is a specific data type provided by Oracle, and Oracle can guarantee that the data type is up and backwards compatible in any version of VARCHAR2.
VarChar is not recommended for use in Oracle.

Specific to the difference between NVARCHAR2 and VARCHAR2, from the point of view of the difference is: NVARCHAR2 in the calculation of length and character sets, such as the database is the Chinese character set with length 10 for example, then

1, NVARCHAR2 (10) is can be stored in 10 Chinese characters, if used to save English can only save 10 characters.

2, and VARCHAR2 (10), then only 5 characters can be stored in English, 10.

Source: http://www.cnblogs.com/flyingfish/archive/2010/01/15/1648448.html

difference between type int and number type in Oracle

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.