【NUMBER】有關Oracle NUMBER型別定義中precision和scale的測試和總結
NUMBER資料型別的定義格式是:NUMBER(p,s)。本文對定義中的p(precision)和s(scale)做一個解釋和總結。
1.官方文件中有關NUMBER資料型別的描述
p is the precision, or the total number of significant decimal digits, where the most significant digit is the left-most nonzero digit, and the least significant digit is the right-most known digit. Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point.
s is the scale, or the number of digits from the decimal point to the least significant digit. The scale can range from -84 to 127.
2.關於NUMBER資料型別的測試
create table test ( a number(1,3));
insert into test values(0.12);
*
第 1 行出現錯誤:
ORA-01438: 值大於此列指定的允許精度
insert into test values(0.012);
已建立 1 行。
insert into test values(0.0125);
已建立 1 行。
select * from test;
A
----------
.012
.013
3.小結
1)整數部分長度>p-s時,報錯;
2)小數部分長度>s時,舍入;
3)s為負數時,對小數點左邊的s數字進行舍入;
4)當s>p時,p表示小數後第s位向左最多可以有多少位數字,如果大於p則報錯,小數點後s位向右的數字被舍入.
Good luck.
secooler
10.09.11
-- The End --
1.官方文件中有關NUMBER資料型別的描述
p is the precision, or the total number of significant decimal digits, where the most significant digit is the left-most nonzero digit, and the least significant digit is the right-most known digit. Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point.
s is the scale, or the number of digits from the decimal point to the least significant digit. The scale can range from -84 to 127.
2.關於NUMBER資料型別的測試
create table test ( a number(1,3));
insert into test values(0.12);
*
第 1 行出現錯誤:
ORA-01438: 值大於此列指定的允許精度
insert into test values(0.012);
已建立 1 行。
insert into test values(0.0125);
已建立 1 行。
select * from test;
A
----------
.012
.013
3.小結
1)整數部分長度>p-s時,報錯;
2)小數部分長度>s時,舍入;
3)s為負數時,對小數點左邊的s數字進行舍入;
4)當s>p時,p表示小數後第s位向左最多可以有多少位數字,如果大於p則報錯,小數點後s位向右的數字被舍入.
Good luck.
secooler
10.09.11
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-557312/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 測試NUMBER型別的效能型別
- Oracle中number型別詳解Oracle型別
- 【NUMBER】Oracle的NUMBER資料型別特點Oracle資料型別
- Oracle的number資料型別Oracle資料型別
- ORACLE NUMBER資料型別Oracle資料型別
- Oracle中rownum和row_number()Oracle
- Oracle中Number(p,s)的意義Oracle
- ORACLE NUMBER型別內部實現Oracle型別
- [20150503]關於oracle的number型別.txtOracle型別
- 淺析number型別的值型別
- 征服number型別的input框型別
- EF:oracle的number型別對映為C#的boolean型別Oracle型別C#Boolean
- 10_深入解析Oracle number資料型別及os層number解析工具分享Oracle資料型別
- number型別的顯示問題型別
- MySQL和Oracle中的半連線測試總結(一)MySqlOracle
- number(p,s)型別詳解型別
- oracle中number型欄位長度、精度及實際儲存狀態測試(zt)Oracle
- oracle中dump函式及oracle NUMBER型別內部儲存機制Oracle函式型別
- number資料型別在查詢中的顯示資料型別
- JS中其他資料型別轉為number資料型別的方法JS資料型別
- JavaScript封裝方法,相容引數型別為Number和StringJavaScript封裝型別
- javascript型別系統——Number數字型別JavaScript型別
- Java Number和Math 類Java
- oracle 11.2.0.4 sequence之dba_sequences last_number含義測試之一OracleAST
- JS -- number資料型別詳解JS資料型別
- oracle insert插入number(1)列的資料小測試Oracle
- 巨集定義和列舉型別的區別型別
- Js中的NumberJS
- 從0.1+0.2=0.30000000000000004再看JS中的Number型別JS型別
- 有關lock的一點測試總結!
- [20160828]number型別.txt型別
- Oracle System Change Number (SCN) Number 完全筆記Oracle筆記
- vue中自定義指令,限制input值為number和小數點的位數Vue
- [20191001]關於oracle number型別的一些疑惑.txtOracle型別
- 軟體確認測試、系統測試和驗收測試有什麼區別和關係?
- 一個簡單函式—Number型別轉換Date型別函式型別
- Long raw和Long型別總結型別
- 關於筆試和麵試的反思總結筆試