number(6,2) 插入0.00的时候数据库中就显示0.00,而不是0
现在效果是插入之后显示的是0,小数位后面的0都被去掉了,插入的时候是以什么格式插入?

解决方案 »

  1.   

    -- 你表面上看到的是0,这只是一种数据显式的形式,并不一定代表其表中实际存储的数据就是整数0!
    -- 请看示例:
    create public synonym T for scott.T表已创建。已用时间:  00: 00: 00.06
    scott@SZTYORA> insert into t(vnum) values(0);已创建 1 行。已用时间:  00: 00: 00.00
    scott@SZTYORA> select * from t;      VNUM
    ----------
             0已用时间:  00: 00: 00.01
    scott@SZTYORA> col vnum for 99.99
    scott@SZTYORA> l
      1* select * from t
    scott@SZTYORA> /  VNUM
    ------
       .00已用时间:  00: 00: 00.01
    scott@SZTYORA> col vnum for 90.99
    scott@SZTYORA> l
      1* select * from t
    scott@SZTYORA> /  VNUM
    ------
      0.00已用时间:  00: 00: 00.00
      

  2.   

    scott@SZTYORA> create table t(col1 number(6,2), col2 number(6,0));
    create public synonym T for scott.T表已创建。已用时间:  00: 00: 00.04scott@SZTYORA> insert into t values(0,0);已创建 1 行。已用时间:  00: 00: 00.00
    scott@SZTYORA> insert into t values(0.38,1);已创建 1 行。已用时间:  00: 00: 00.00
    scott@SZTYORA> insert into t values(1.48,5);已创建 1 行。已用时间:  00: 00: 00.01
    scott@SZTYORA> select * from t;      COL1       COL2
    ---------- ----------
             0          0
           .38          1
          1.48          5已用时间:  00: 00: 00.01
    scott@SZTYORA> commit;提交完成。已用时间:  00: 00: 00.01
    scott@SZTYORA>  select col1, col2, vsize(col1) v1, vsize(col2) v2 from t;      COL1       COL2         V1         V2
    ---------- ---------- ---------- ----------
             0          0          1          1
           .38          1          2          2
          1.48          5          3          2已用时间:  00: 00: 00.01
      

  3.   

    但是,我在oracle sql developer 中看到的就是0,我在oracle sql developer中直接改成0.00,提交之后刷新发现还是0没有小数位之后的0
      

  4.   

    -- 从下面的查询,你可以看到: 
      1*  select col1, col2, vsize(col1) v1, vsize(col2) v2, vsize(col2), dump(col1) d1, dump(col2) d2 from t
    scott@SZTYORA> /      COL1       COL2         V1         V2 VSIZE(COL2) D1                             D2
    ---------- ---------- ---------- ---------- ----------- ------------------------------ ------------------------------
             0          0          1          1           1 Typ=2 Len=1: 128               Typ=2 Len=1: 128
           .38          1          2          2           2 Typ=2 Len=2: 192,39            Typ=2 Len=2: 193,2
          1.48          5          3          2           2 Typ=2 Len=3: 193,2,49          Typ=2 Len=2: 193,6
       9788.48     555666          4          4           4 Typ=2 Len=4: 194,98,89,49      Typ=2 Len=4: 195,56,57,67已用时间:  00: 00: 00.01
      

  5.   

    直接用sqlplus测试吧,尽量少使用plsql developer来做测试
      

  6.   

    如果需要存储插入的格式,最好还是用varchar2来存储.