oracle中INDEX BY BINARY_INTEGER 的作用
创建一个集合类型的时候:一般都会在后面添加 INDEX BY BINARY_INTEGER
TYPE Type_Value IS TABLE OF varchar2(15) INDEX BY BINARY_INTEGER;
加了”index by binary_integer ”后,varchar2类型的下标就是自增长。就不需要每次都 extend 了。
没加“index by binary_integer”时:
declare type numbers is table of number; m numbers := numbers(); begin m.extend; m(1) := 2; m.extend; m(2) := 3; for i in1 .. m.count loop dbms_output.put_line(m(i)); end loop; end;
而如果加了“index by binary_integer”,代码如下写就可以达到上面的效果
declare type numbers is table of number index by binary_integer; m numbers; begin m(1) := 2; m(2) := 3; for i in 1..m.count loop dbms_output.put_line(m(i)); end loop; end;