Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ Oracle database NUMBER (x, y) data types     - CentOS 6.5 installation VNCServer implement graphical access (Server)

- How to identify memory leaks in Java (Programming)

- Nginx concerning the location and rewrite applications proxy_pass (Server)

- Redis Design and Implementation study notes (Database)

- Java Database Programming JDBC configuration (Programming)

- xCAT Installation Kit (Linux)

- impdp error ORA-39001, ORA-39000, ORA-31619 (Database)

- Ubuntu users install the video driver Nvidia Driver 334.21 (Linux)

- Deploy Apache Spark cluster environment in Ubuntu (Server)

- How to publish projects to the Jcenter repository using Gradle in Android Studio (Programming)

- Android Studio Clear Project or Rebuild Project Error (Linux)

- Linux (CentOS) directory file management and file system file compression packing (Linux)

- Dalvik heap memory management and recycling (Linux)

- Ubuntu 14.04 and derivative versions of the user install Pantheon Photos 0.1 (Linux)

- Standardized UNIX command-line tool (Linux)

- Compare Oracle MySQL (ICP) index condition pushdown is described (Database)

- Weld a problem in JDK 8u60 environment (Programming)

- On the PC goes heavy security watch your startup items (Linux)

- The best tools and techniques to find data on a Unix system (Linux)

- Oracle Sql Loader tool has shown signs (Database)

  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].
- Android memory optimization of the disk cache (Linux)
- Oracle Linux 7.1 install Oracle 12C RAC (Database)
- Hackers is how the invasion and control of Things devices? (Linux)
- Quickly locate the mistakes by gdb location (Programming)
- Python-- for anomalies and reflection of objects articles (Programming)
- Linux disk management practices (Linux)
- Iptables in Ubuntu (Linux)
- Performance Optimization: Using Ramlog transfer log files to memory (Linux)
- Use netcat [nc] command on Linux and Unix port scan (Server)
- Use OpenSSL to generate a certificate (Linux)
- KVM virtualization of nested virtualization (Linux)
- EXP-00091 Error resolved (Database)
- Method under Linux GCC Compiler shared library function export control (Programming)
- How to install the Ruby runtime environment on Mac OS X (Linux)
- Java source implementation of the observer pattern instance (Programming)
- Linux firewall settings -DNS server articles (Server)
- Single-node Hadoop environment to build (Server)
- Linux batch copy data script (Linux)
- To install the Ubuntu Touch emulator on Ubuntu (Linux)
- Ubuntu 12.04 configure NVIDIA CUDA 5.5 Record (Linux)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.