[20181207]sqlplus下显示数据精度.txt

来源:这里教程网 时间:2026-03-03 12:42:58 作者:

[20181207]sqlplus下显示数据精度.txt --//这个是一个细节问题,昨天看了链接:http://nimishgarg.blogspot.com/2018/12/minus-query-giving-results-on-exactly.html --//以该网站的数字作为测试说明问题. 1.环境: SCOTT@book> @ ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- -------------------------------------------------------------------------------- x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production create table t1 ( id number); insert into t1 values (1408.921128110362243397676441929671192844); insert into t1 values (1408.921128110362243397676441929671192846); insert into t1 values (1408.921128110362243397676441929671192845); insert into t1 values (1408.92113); commit; SCOTT@book> select * from t1 ;         ID ---------- 1408.92113 1408.92113 1408.92113 1408.92113 --//你可以发现在sqlplus下缺省仅仅显示小数点5位. SCOTT@book> create table t2 as select * from t1 where rownum<=2; Table created. SCOTT@book> select * from t1 minus select * from t2;         ID ---------- 1408.92113 1408.92113 SCOTT@book> select rowid,t1.* from t1 where id=1408.92113; ROWID                      ID ------------------ ---------- AAAWGpAAEAAAAIMAAD 1408.92113 --//你会觉得奇怪仅仅查询到1条,如果没有第4条插入,你根本查询不到. SCOTT@book> column id format 9999.999999999999999999999999999999999999999999999 SCOTT@book> select rowid,t1.* from t1 ; ROWID                                                               ID ------------------ --------------------------------------------------- AAAWGpAAEAAAAIMAAA  1408.921128110362243397676441929671192844000000000 AAAWGpAAEAAAAIMAAB  1408.921128110362243397676441929671192846000000000 AAAWGpAAEAAAAIMAAC  1408.921128110362243397676441929671192845000000000 AAAWGpAAEAAAAIMAAD  1408.921130000000000000000000000000000000000000000 --//如果在toad下就不会存在这个问题. select * from t1; ID 1408.921128110362243397676441929671192844 1408.921128110362243397676441929671192846 1408.921128110362243397676441929671192845 1408.92113 --//顺便说一下,生产系统数据库number最好定义精度,不然可能占用空间很大.有一些数字是计算得来. SCOTT@book> select rowid,t1.id,dump(id) c80  from t1 where rowid='AAAWGpAAEAAAAIMAAE'; ROWID                                                               ID C80 ------------------ --------------------------------------------------- -------------------------------------------------------------------------------- AAAWGpAAEAAAAIMAAE      .333333333333333333333333333333333333333300000 Typ=2 Len=21: 192,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34 --//占用21字节. --//另外可以参考我以前遇到的问题:http://blog.itpub.net/267265/viewspace-1257036/->[20140823]在sqlplus使用copy注意.txt  --//另外我还遇到的情况:http://blog.itpub.net/267265/viewspace-2148998/->[20171220]toad plsql显示整形的bug.txt 总结: 1.生产系统number类型最好定义精度. 2.sqlplus下显示数据类型,缺省仅仅精确到小数点5位.在工作中注意.

相关推荐

热文推荐