pls_integer 和 binary_integer 有什么区别?
我继承了一些代码,这些代码将成为一些额外工作的基础.查看存储过程,我看到了很多关联数组.
其中一些由 binary_integers 索引,一些由 pls_integers 索引.两者有区别吗?
我查看了文档,但除了从这一行:
<块引用>PL/SQL 数据类型PLS_INTEGER
和BINARY_INTEGER
是相同的.为简单起见,本文档使用 PLS_INTEGER 来表示 PLS_INTEGER
和 BINARY_INTEGER
.
我找不到两者之间的任何区别.那么有什么区别呢?出于历史/兼容性原因,两者都存在吗?
我使用的是 Oracle 10gR2
解决方案历史原因.它们在 10g 之前是不同的:
<块引用>在 8i 和 9i 上,PLS_INTEGER 明显快于 BINARY_INTEGER.
<块引用>
在声明和操作整数方面,Oracle 提供了许多选项,包括:
INTEGER - 在 STANDARD 包中定义为 NUMBER 的子类型,此数据类型以完全独立于平台的方式实现,这意味着您对 NUMBER 或 INTEGER 变量所做的任何事情都应该以相同的方式工作数据库已安装.
BINARY_INTEGER - 在 STANDARD 包中定义为 INTEGER 的子类型.声明为 BINARY_INTEGER 的变量可以在 -231+1 .. 231-1,也就是 -2,147,483,647 到 2,147,483,647 之间赋值.在 Oracle9i 数据库第 2 版之前,BINARY_INTEGER 是唯一允许用于关联数组(也称为索引表)的索引数据类型,如下所示:
TYPE my_array_t IS TABLE OF VARCHAR2(100)索引 BINARY_INTEGER
<块引用>
PLS_INTEGER - 在 STANDARD 包中定义为 BINARY_INTEGER 的子类型.声明为 PLS_INTEGER 的变量可以在 -231+1 .. 231-1,也就是 -2,147,483,647 到 2,147,483,647 之间赋值.PLS_INTEGER 操作使用机器算术,因此它们通常比 NUMBER 和 INTEGER 操作快.此外,在 Oracle 数据库 10g 之前,它们比 BINARY_INTEGER 快.但是,在 Oracle 数据库 10g 中,BINARY_INTEGER 和 PLS_INTEGER 现在完全相同,可以互换使用.
I've inherited some code which is going to be the base for some additional work. Looking at the stored procs, I see quite a lot of associative-arrays.
Some of these are indexed by binary_integers, some by pls_integers. Are there any differences between the two?
I had a look at the documentation, but apart from this line:
The PL/SQL data types
PLS_INTEGER
andBINARY_INTEGER
are identical. For simplicity, this document uses PLS_INTEGER to mean bothPLS_INTEGER
andBINARY_INTEGER
.
I couldn't find any difference between the two. So what's the difference? Are both around for historical/compatibility reasons?
I'm using Oracle 10gR2
解决方案Historical reasons. They used to be different before 10g:
On 8i and 9i, PLS_INTEGER was noticeably faster than BINARY_INTEGER.
When it comes to declaring and manipulating integers, Oracle offers lots of options, including:
INTEGER - defined in the STANDARD package as a subtype of NUMBER, this datatype is implemented in a completely platform-independent fashion, which means that anything you do with NUMBER or INTEGER variables should work the same regardless of the hardware on which the database is installed.
BINARY_INTEGER - defined in the STANDARD package as a subtype of INTEGER. Variables declared as BINARY_INTEGER can be assigned values between -231+1 .. 231-1, aka -2,147,483,647 to 2,147,483,647. Prior to Oracle9i Database Release 2, BINARY_INTEGER was the only indexing datatype allowed for associative arrays (aka, index-by tables), as in:
TYPE my_array_t IS TABLE OF VARCHAR2(100)
INDEX BY BINARY_INTEGER
PLS_INTEGER - defined in the STANDARD package as a subtype of BINARY_INTEGER. Variables declared as PLS_INTEGER can be assigned values between -231+1 .. 231-1, aka -2,147,483,647 to 2,147,483,647. PLS_INTEGER operations use machine arithmetic, so they are generally faster than NUMBER and INTEGER operations. Also, prior to Oracle Database 10g, they are faster than BINARY_INTEGER. In Oracle Database 10g, however, BINARY_INTEGER and PLS_INTEGER are now identical and can be used interchangeably.
相关文章