gpt4 book ai didi

oracle - pls_integer 和 binary_integer 有什么区别?

转载 作者:行者123 更新时间:2023-12-03 10:11:41 24 4
gpt4 key购买 nike

我继承了一些代码,这些代码将成为一些额外工作的基础。查看存储过程,我看到了很多关联数组。

其中一些由 binary_integers 索引,一些由 pls_integers 索引。两者之间有什么区别吗?

我看了the documentation ,但除了这一行:

The PL/SQL data types PLS_INTEGER and BINARY_INTEGER are identical. For simplicity, this document uses PLS_INTEGER to mean both PLS_INTEGER and BINARY_INTEGER.



我找不到两者之间的任何区别。那么有什么区别呢?两者都出于历史/兼容性原因吗?

我正在使用 Oracle 10gR2

最佳答案

历史原因。他们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.

关于oracle - pls_integer 和 binary_integer 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7412731/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com