pls_integer和binary_integer有什么区别? [英] What's the difference between pls_integer and binary_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.
其中一些通过binary_integers进行索引,某些通过pls_integers进行索引.两者之间有什么区别吗?
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:
PL/SQL数据类型
PLS_INTEGER
和BINARY_INTEGER
是相同的.为简单起见,本文档使用PLS_INTEGER表示PLS_INTEGER
和BINARY_INTEGER
.
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?
我正在使用Oracle 10gR2
I'm using Oracle 10gR2
推荐答案
历史原因.它们以前在10g之前是不同的:
在8i和9i上,PLS_INTEGER明显比BINARY_INTEGER快.
On 8i and 9i, PLS_INTEGER was noticeably faster than BINARY_INTEGER.
在声明和处理整数时,Oracle提供了许多选项,包括:
When it comes to declaring and manipulating integers, Oracle offers lots of options, including:
INTEGER-在STANDARD软件包中定义为NUMBER的子类型,此数据类型以完全独立于平台的方式实现,这意味着您对NUMBER或INTEGER变量所做的任何操作均应相同,而不论使用哪种硬件数据库已安装.
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-在STANDARD包中定义为INTEGER的子类型.可将声明为BINARY_INTEGER的变量分配为-2 31 +1 .. 2 31 -1,即-2,147,483,647至2,147,483,647.在Oracle9i数据库第2版之前,BINARY_INTEGER是唯一允许关联数组(也称为索引表)的索引数据类型,如下所示:
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-在STANDARD包中定义为BINARY_INTEGER的子类型.可将声明为PLS_INTEGER的变量的值分配为-2 31 +1 .. 2 31 -1,即-2,147,483,647至2,147,483,647. PLS_INTEGER操作使用机器算术,因此它们通常比NUMBER和INTEGER操作快.另外,在Oracle Database 10g之前,它们比BINARY_INTEGER更快.但是,在Oracle数据库10g中,BINARY_INTEGER和PLS_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.
这篇关于pls_integer和binary_integer有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!