如果用pls_integer值运算,oracle会使用原生机器算法其他的所有数值型的数据类型都和number数据类型一样使用c语言算法库结果就是
如果用pls_integer值运算,,oracle会使用原生机器算法
其他的所有数值型的数据类型都和number数据类型一样使用c语言算法库
结果就是pls_integer值的处理速度比number型的整数快很多
而且,pls_integer在移植硬件平台时不会遇到兼容性问题
对于密集型的整数运算,think建议大家使用pls_integer
不过,如果频繁的pls_integer和number型的数据交互,还是建议一开始就使用number
如果对精度有要求,也请不要使用,因为pls_integer用于整数运算,结果会取整
小实验测试一下:
hr@orcl> ed
wrote file afiedt.buf
1 declare
2 j pls_integer :=0;
3 begin
4 for i in 1..1000000
5 loop
6 j:=i+1;
7 if j=1000
8 then
9 dbms_output.put_line('hello think');
10 end if;
11 end loop;
12* end;
hr@orcl> /
hello think
pl/sql procedure successfully completed.
elapsed: 00:00:00.28
hr@orcl> ed
wrote file afiedt.buf
1 declare
2 j number :=0;
3 begin
4 for i in 1..1000000
5 loop
6 j:=i+1;
7 if j=1000
8 then
9 dbms_output.put_line('hello think');
10 end if;
11 end loop;
12* end;
hr@orcl> /
hello think
pl/sql procedure successfully completed.
elapsed: 00:00:00.36