number
n u m b e r类型数据可用来表示所有的数值数据,说明格式为:
num_field number(precision, scale );
其中,precision 可以有1~3 8个数字位,而s c a l e表示在p r e c i s i o n位数字中小数点后的数字位数,下面的定义:
num_field number(12,2);
表示n u m _ f i e l d是一个整数部分最多1 0位、小数部分最多2位的变量。計算方法:
SQL> declare
2 my_num number(10);
3 your_num number(10);
4 total_num number(10);
5 begin
6 my_num:=1;
7 your_num:=2;
8 total_num:=my_num+your_num;
9 dbms_output.put_line('the total is:'||total_num);
10 end;
11 /
the total is:3
n u m b e r类型数据可用来表示所有的数值数据,说明格式为:
num_field number(precision, scale );
其中,precision 可以有1~3 8个数字位,而s c a l e表示在p r e c i s i o n位数字中小数点后的数字位数,下面的定义:
num_field number(12,2);
表示n u m _ f i e l d是一个整数部分最多1 0位、小数部分最多2位的变量。計算方法:
SQL> declare
2 my_num number(10);
3 your_num number(10);
4 total_num number(10);
5 begin
6 my_num:=1;
7 your_num:=2;
8 total_num:=my_num+your_num;
9 dbms_output.put_line('the total is:'||total_num);
10 end;
11 /
the total is:3
默认没有占用多少个字节
0在oracle存储占一个字节为:0x80
其他的可以用下面的语句来看占用了多少字节:
[email protected] >desc t
名称 是否为空? 类型
----------------------------------------------------------- -------- --------- N [email protected] >insert into t values(1);已创建 1 行。[email protected] >select dump(n,16) from t;DUMP(N,16)
-------------------------------------------------------------------------------Typ=2 Len=2: c1,2这里的 Len=2 就是占用的字节数