日期:2014-05-17  浏览次数:20859 次

oracle中number类型的问题
在oracle中有一个number类型,
现在我这样定义两个number类型的,number(1,0) number(38,0)
那么,我现在存入数据1到这两个不同的定义中去,那么它们占用的空间一样么?

------解决方案--------------------
SQL code
-- 占用的空间不一样,同一个字段中的数据不同,占用的空间甚至也不一样,例如:
create table t ( x number, y number );

insert into t ( x )
select to_number(rpad('9', rownum*2,'9'))
from all_objects
where rownum <= 14;

update t set y = x+1;

set numformat 99999999999999999999999999999
col v1 format 99
col v2 format 99
select x, y, vsize(x) v1, vsize(y) v2
from t order by x;

                             X                              Y  V1  V2
------------------------------ ------------------------------ --- ---
                            99                            100   2   2
                          9999                          10000   3   2
                        999999                        1000000   4   2
                      99999999                      100000000   5   2
                    9999999999                    10000000000   6   2
                  999999999999                  1000000000000   7   2
                99999999999999                100000000000000   8   2
              9999999999999999              10000000000000000   9   2
            999999999999999999            1000000000000000000  10   2
          99999999999999999999          100000000000000000000  11   2
        9999999999999999999999        10000000000000000000000  12   2
      999999999999999999999999      1000000000000000000000000  13   2
    99999999999999999999999999    100000000000000000000000000  14   2
  9999999999999999999999999999  10000000000000000000000000000  15   2

已选择14行。

------解决方案--------------------
是一样的,你dump看看