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;
12
n() := ;
forin ..
n.count dbms_output.put_line(n(i));
end ;
;
輸出:2,3
|
而如果加了“index
by binary_integer”,代碼如下寫就可以達到上面的效果
numbers table number ;
begin
12
n() := ;
i 1loop
loopend<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