Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4043059
  • 博文数量: 536
  • 博客积分: 10470
  • 博客等级: 上将
  • 技术积分: 4825
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-26 14:08
文章分类

全部博文(536)

文章存档

2024年(3)

2021年(1)

2019年(1)

2017年(1)

2016年(2)

2013年(2)

2012年(10)

2011年(43)

2010年(10)

2009年(17)

2008年(121)

2007年(252)

2006年(73)

分类: Oracle

2006-11-29 16:54:03

先来做一个有趣的实验(可以将这两条语句放到文件中运行):
建表numbers:
 

create table NUMBERS
(
number1 number(1),
negnumber1 number(1),
number2 number(2),
negnumber2 number(2),
number3 number(3),
negnumber3 number(3),
number4 number(4),
negnumber4 number(4),
number5 number(5),
negnumber5 number(5),
number6 number(6),
negnumber6 number(6),
number7 number(7),
negnumber7 number(7),
number8 number(8),
negnumber8 number(8),
number9 number(9),
negnumber9 number(9),
number10 number(10),
negnumber10 number(10),
number11 number(11),
negnumber11 number(11),
number12 number(12),
negnumber12 number(12),
number13 number(13),
negnumber13 number(13),
number14 number(14),
negnumber14 number(14),
number15 number(15),
negnumber15 number(15),
number16 number(16),
negnumber16 number(16),
number17 number(17),
negnumber17 number(17),
number18 number(18),
negnumber18 number(18),
number19 number(19),
negnumber19 number(19),
number20 number(20),
negnumber20 number(20),
number21 number(21),
negnumber21 number(21),
number22 number(22),
negnumber22 number(22),
number23 number(23),
negnumber23 number(23),
number24 number(24),
negnumber24 number(24),
number25 number(25),
negnumber25 number(25),
number26 number(26),
negnumber26 number(26),
number27 number(27),
negnumber27 number(27),
number28 number(28),
negnumber28 number(28),
number29 number(29),
negnumber29 number(29),
number30 number(30),
negnumber30 number(30),
number31 number(31),
negnumber31 number(31),
umber32 number(32),
negnumber32 number(32),
number33 number(33),
negnumber33 number(33),
number34 number(34),
negnumber34 number(34),
number35 number(35),
negnumber35 number(35),
number36 number(36),
negnumber36 number(36),
number37 number(37),
negnumber37 number(37),
number38 number(38),
negnumber38 number(38)
);


插入一条数据:

insert into numbers values (
9, -9,
99, -99,
999, -999,
9999, -9999,
99999, -99999,
999999, -999999,
9999999, -9999999,
99999999, -99999999,
999999999, -999999999,
9999999999, -9999999999,
99999999999, -99999999999,
999999999999, -999999999999,
9999999999999, -9999999999999,
99999999999999, -99999999999999,
999999999999999, -999999999999999,
9999999999999999, -9999999999999999,
99999999999999999, -99999999999999999,
999999999999999999, -999999999999999999,
9999999999999999999, -9999999999999999999,
99999999999999999999, -99999999999999999999,
999999999999999999999, -999999999999999999999,
9999999999999999999999, -9999999999999999999999,
99999999999999999999999, -99999999999999999999999,
999999999999999999999999, -999999999999999999999999,
9999999999999999999999999, -9999999999999999999999999,
99999999999999999999999999, -99999999999999999999999999,
999999999999999999999999999, -999999999999999999999999999,
9999999999999999999999999999, -9999999999999999999999999999,
99999999999999999999999999999, -99999999999999999999999999999,
999999999999999999999999999999, -999999999999999999999999999999,
9999999999999999999999999999999, -9999999999999999999999999999999,
99999999999999999999999999999999, -99999999999999999999999999999999,
999999999999999999999999999999999, -999999999999999999999999999999999,
9999999999999999999999999999999999, -9999999999999999999999999999999999,
99999999999999999999999999999999999, -99999999999999999999999999999999999,
999999999999999999999999999999999999, -999999999999999999999999999999999999,
9999999999999999999999999999999999999, -9999999999999999999999999999999999999,
99999999999999999999999999999999999999, -99999999999999999999999999999999999999);


现在来分析结果:
vsize函数为计算该字段在Oracle中存放占多少字节。

SQL> select length(number1), vsize(number1), length(negnumber1), vsize(negnumber1) from numbers;

LENGTH(NUMBER1) VSIZE(NUMBER1) LENGTH(NEGNUMBER1) VSIZE(NEGNUMBER1)
--------------- -------------- ------------------ -----------------

              1 2 2 3

SQL> select length(number38), vsize(number38), length(negnumber38), vsize(negnumber38) from numbers;

LENGTH(NUMBER38) VSIZE(NUMBER38) LENGTH(NEGNUMBER38) VSIZE(NEGNUMBER38)
---------------- --------------- ------------------- ------------------

              38 20 39 21


        
可以得出负数在Oracle中存放要比正数多占用一个字节的。

----------------------------------------------------------------------
以上内容部分来源于:
阅读(3257) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~