pls_integer 和 binary_integer 有什么区别?

What#39;s the difference between pls_integer and binary_integer?(pls_integer 和 binary_integer 有什么区别?)
本文介绍了pls_integer 和 binary_integer 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

其中一些由 binary_integers 索引,一些由 pls_integers 索引.两者有区别吗?

我查看了文档,但除了从这一行:

<块引用>

PL/SQL 数据类型PLS_INTEGERBINARY_INTEGER 是相同的.为简单起见,本文档使用 PLS_INTEGER 来表示 PLS_INTEGERBINARY_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 and BINARY_INTEGER are identical. For simplicity, this document uses PLS_INTEGER to mean both PLS_INTEGER and BINARY_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.

这篇关于pls_integer 和 binary_integer 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)