float datatype in Oracle database
作了一個測試,就像我們以前一直提醒的一樣。在使用非 number datatype 的 數字型別一定要注意。
create table t_float (f float(2),n number(2))
SQL> insert into t_float values (7,7);
1 row created.
SQL> insert into t_float values (11,11);
1 row created.
SQL> insert into t_float values (99,99)
1 row created.
1 row created.
SQL> select * from t_float;
F N
---------- ----------
7 7
10 11
100 99
---------- ----------
7 7
10 11
100 99
Why:
a FLOAT column with a binary precision of 2 bits, is implemented as a NUMBER column with 1 decimal digit of precision and no fixed scale. Thus the number 7, which requires 3 binary bits, will nevertheless be stored exactly, whereas the number 11, which has two decimal digits, will be rounded to 10 because only one decimal digit of precision is allowed.
It is legitimate for a database implementation to use higher precision than requested in this way. Therefore, database applications should always round data values explicitly when required, and should not rely on the precision of the datatype to round data implicitly.
暫時還有理解上面的含義 :(
[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/34596/viewspace-805109/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- float datatype in Oracle database 【Blog 搬家】OracleDatabase
- Oracle實驗(04):floatOracle
- WPF DataTemplate DataType
- partitioned by timestamp datatype
- oralce datatype-long
- Oracle Database Cloud - Database as a Service Quick StartOracleDatabaseCloudUI
- Types of Oracle Database Users : Database Users (6)OracleDatabase
- Oracle clone databaseOracleDatabase
- ORACLE database vaultOracleDatabase
- Oracle Database HistoryOracleDatabase
- Oracle Database ReplayOracleDatabase
- alter database in OracleDatabaseOracle
- Oracle Database ScriptOracleDatabase
- Oracle Database ServiceOracleDatabase
- Oracle Physical Database LimitsOracleDatabaseMIT
- Oracle sharding databaseOracleDatabase
- Oracle Database Resource ManagerOracleDatabase
- Oracle Database Scheduler整理OracleDatabase
- oracle full database backupOracleDatabase
- Oracle Active database duplicationOracleDatabase
- Oracle Database Memory StructuresOracleDatabaseStruct
- Oracle database buffer cacheOracleDatabase
- Oracle Database In-MemoryOracleDatabase
- oracle rat database replayOracleDatabase
- Oracle database instanceOracleDatabase
- Oracle Database Internals FAQOracleDatabase
- HP ORACLE DATABASE MACHINEOracleDatabaseMac
- oracle database linkOracleDatabase
- oracle 重建EM databaseOracleDatabase
- Types of Oracle Database Users : Database Administrators (1)OracleDatabase
- oracle plsql(一)_binary_float_binary_doubleOracleSQL
- Oracle Database Cardinality FeedbackOracleDatabase
- Secrets of the Oracle Database筆記OracleDatabase筆記
- 初識 "Oracle Database Vault"OracleDatabase
- Oracle Database Documentation LibraryOracleDatabase
- oracle 之recovery directory databaseOracleDatabase
- Oracle Database Link ProblemsOracleDatabase
- Oracle Database ApplianceOracleDatabaseAPP