Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ Oracle database NUMBER (x, y) data types     - PLSQL Developer synchronization table tools (Database)

- Installing Linux and Windows 10 dual system (Linux)

- redis main building and disaster recovery from a cluster deployment (Database)

- SpringMVC the use of interceptors (Programming)

- Python programming style (Programming)

- expdp / impdp use version parameter data migration across versions (Database)

- SSH does not require a password to log on to a Linux server (Server)

- Dynamic programming Android (Programming)

- VirtualBox CentOS is configured as a local disk mirroring software source (Linux)

- Linux 101 hack book reading notes (Linux)

- Linux System Tutorial: How to browse the Linux command line, weather forecast (Linux)

- Android Studio commonly used shortcuts and how to follow the Eclipse Shortcuts (Linux)

- Upgrade installation manual CentOS6.5 GCC4.8.2 (Linux)

- Linux Shell introduces (Linux)

- Linux cd command Detailed (Linux)

- Node.js simple interface server (Server)

- OpenGL Superb Learning Notes - Depth Texture and Shadows (Programming)

- how to quickly find a file on Linux system (Linux)

- Linux Getting Started tutorial: 3D effects and beautify your desktop (Linux)

- Running the open-source Swift under Linux platform (Linux)

  Oracle database NUMBER (x, y) data types
  Add Date : 2017-08-31      
  Test preparation
Analysis and experiment
1 fractional part of the processing
2 The maximum value that can be saved
3 The minimum value that can be saved
to sum up
Oracle's NUMBER data type represents a decimal number that is limited by the number of integer bits and the number of decimal places. Let's take NUMBER (8,2) as an example.

1 Test preparation

To create a table with only one column, NUMBER (8,2) means that the total number of digits is at most 8 and the fractional part is at most 2 bits (the integer part is at most 8-2 = 6 bits).

Create table t1 (c1 number (8,2));
2 analysis and experiment

2.1 fractional part of the treatment

The fractional part represents the degree of precision, NUMBER (8,2) can hold up to 2 decimal places, so what happens to more than 2 digits?

SQL> insert into t1 values (1.234);

1 row created.

SQL> select * from t1;


SQL> delete from t1;

1 rows deleted.

SQL> insert into t1 values (1.235);

1 row created.

SQL> select * from t1;

Can be seen that the fractional part of the decimal point after the 2-bit part of the rounding algorithm used, 1.234 1.23 as 1.23 and 1.24.

2.2 The maximum value that can be saved

Since the integer part of up to 6, the fractional part of up to 2, then the number (8,2) can represent the largest number is 999999.99. We now insert this maximum value.

SQL> insert into t1 values (999999.99);

1 row created.

SQL> select * from t1;

This figure can be seen to be correctly stored.
Insert a more large number 999999.991 below.

SQL> insert into t1 values (999999.991);

1 row created.

SQL> select * from t1;

Can be inserted, but was truncated to 999999.99, in fact, the reason is very simple fractional part of the 0.991 will be rounded to 0.99, after rounding the value became 999999.99, within the scope.

Look at 999999.995.

SQL> insert into t1 values (999999.995);
Insert into t1 values (999999.995)
ERROR at line 1:
ORA-01438: value greater than specified precision allowed for this column
Insert failed! The reason is that the decimal part of 999999.995 becomes rounded to 1000000.00, beyond the 6-bit integer range.

2.3 The minimum value that can be saved

The range of negative numbers is symmetric with the positive number range, so the minimum value is -999999.99.

3 Summary

NUMBER (8,2) represents a range of numbers [-999999.99,999999.99]. To determine whether a given number can be in this range, the fractional part of the first rounded, and then to compare. Judgment step:

(1) Round the third decimal place to obtain a number with 2 decimal places;
(2) Determine whether the number is within the range of [-999999.99,999999.99].
- 3 ways to create a lightweight, durable system of Ubuntu Linux USB disk (Linux)
- Getting Started with Linux system to learn: how to install USB webcams come in raspberry (Linux)
- Python closure and function objects (Programming)
- Nagios (centreon) monitoring LVS (Server)
- Migu online music player for Linux (Linux)
- Binary search is really easy as you think you do (Programming)
- Linux find command usage practices (Linux)
- Mac OS X Server installation and application (Linux)
- Using Linux command line and execute PHP code (Programming)
- How to set IonCube Loaders in Ubuntu (Linux)
- C ++ function object (Programming)
- C ++ handling text input (Programming)
- Detailed PHP code optimization [section] (explain reasons) (Programming)
- Oracle and MySQL5.6 DDL comparison (Database)
- Deployment Kubernetes manage Docker example cluster on Ubuntu (Server)
- Oracle archive log deletion (Database)
- Android screen rotation processing and ProgressDialog the best AsyncTask (Programming)
- TWiki LDAP error appears the problem is solved (Linux)
- HBase cluster installation and deployment (Server)
- MySQL import large amounts of data (Database)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.