Oracle PL/SQL中创建UDT的复合类型时,index by binary_integer 作用
如语句:
type numbers is table of number index by binary_integer;
其作用是
,
加了
”index by binary_integer ”
后,
numbers
类型的下标就是自增长,
numbers
类型在插入元素时,不需要初始化,不需要每次
extend
增加一个空间。
而如果没有这句话“
index by binary_integer
”,那就得要显示对初始化,且每插入一个元素到
numbers
类型的
table
中时,都需要先
extend.
示例:
没加“
index by binary_integer
”时:
numbers
table
number
n numbers
;
n.extend;
1
2
n(
) :=
;
for
in
.. n.count
dbms_output.put_line(n(i));
end
;
;
输出:
2
,
3
|
而如果加了“
index by binary_integer
”,代码如下写就可以达到上面的效果
numbers
table
number
;
begin
1
2
n(
) :=
;
i
1
loop
loop
end<span color:="" navy;="" font-size:="" 10pt"="" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Courier New'; ">;
|
本文出自 “linux要从娃娃抓起” 博客,请务必保留此出处http://wanqiufeng.blog.51cto.com/409430/430987