ITPub博客

首页 > 应用开发 > IT综合 > pls_integer类型

pls_integer类型

原创 IT综合 作者:itpremier 时间:2010-09-19 16:40:42 0 删除 编辑

今天在看一个触发器代码的时候碰到了一个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.

看来pls_integer是推荐使用的,以后可以尝试多使用一下.

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/350519/viewspace-1038602/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-11-27

  • 博文量
    253
  • 访问量
    773710