`

pls_integer类型

    博客分类:
  • sql
阅读更多

今天在看一个触发器代码的时候碰到了一个pls_integer类型,以前没碰到过,记录一下:

PLS_INTEGER可以存储一个有符号的整形值,其精度范围和BINARY_INTEGER一样,是:-2^31~2^31。

PLS_INTEGER和NUMBER比较起来,其优点是:
1).占有较少的存储空间;
2).可以直接进行算术运算(在NUMBER上不能直接进行算术运算,如果要计算,NUMBER必须先被转换成二进制)。所以在进行算术的时候PLS_INTEGER比NUMBER和BINARY_INTEGER快一些。

PLS_INTEGER和BINARY_INTEGER区别:
PLS_INTEGER进行的运算发生溢出的时候,会触发异常。但是当BINARY_INTEGER运算发生溢出时,如果可以指派给一个NUMBER变量(没有超出NUMBER的精度范围)的话就不会触发异常。

Benefits of Using PLS_INTEGER Datatype in PL/SQL
If you have a whole-number counter, for example in a loop or record counter, consider using a datatype of PLS_INTEGER instead of INTEGER or NUMBER. When declaring an integer variable, PLS_INTEGER is the most efficient numeric datatype because its values require less storage than INTEGER or NUMBER values, which are represented internally as 22-byte Oracle numbers. Also, PLS_INTEGER operations use machine arithmetic, so they are faster than BINARY_INTEGER, INTEGER, or NUMBER operations, which use library arithmetic.
分享到:
评论
1 楼 snail_fish 2010-08-19  

相关推荐

Global site tag (gtag.js) - Google Analytics