PL/SQL VARRAY 的最大大小

我正在尝试找出 PL/SQL 中 VARRAY 可能的上限.

I'm trying to figure out the possible upper bound of VARRAY in PL/SQL.

我们肯定可以将 VARRAY 类型定义为

We sure can define VARRAY type as

TYPE type_name IS {VARRAY | VARYING ARRAY} (size_limit) 
   OF element_type [NOT NULL];

Oracle 文档是这样说的:

Oracle documentation has this to say:

每个 Varray 都存储为单个对象,或者在表中它是一列(如果 varray 小于 4KB)或在列之外表但仍在同一个表空间中(如果 varray 大于4KB).您必须在以下位置更新或检索 varray 的所有元素同时,这在执行某些操作时最合适一次完成所有元素.但是您可能会发现存储不切实际并以这种方式检索大量元素.

Each varray is stored as a single object, either inside the table of which it is a column (if the varray is less than 4KB) or outside the table but still in the same tablespace (if the varray is greater than 4KB). You must update or retrieve all elements of the varray at the same time, which is most appropriate when performing some operation on all the elements at once. But you might find it impractical to store and retrieve large numbers of elements this way.

但是size_limit 参数的上限是多少?是否等于无符号整数(4,294,967,295)?

But what is the upper bound of size_limit parameter? Is it equal to unsigned integer (4,294,967,295)?

推荐答案

在 PL/SQL 中,限制为 2147483647.同样的限制适用于架构变化的数组类型.

Within PL/SQL the limit is 2147483647. The same limit applies to schema varying array types.

DECLARE
    TYPE t IS VARRAY(2147483647) OF NUMBER;
BEGIN
    NULL;
END;

如果你增加它,它会抛出 PLS-00325: non-integral numeric literal 2147483648 在这种情况下是不合适的.

If you increase it it throws PLS-00325: non-integral numeric literal 2147483648 is inappropriate in this context.

相关文章