索引表+Pl/SQL集合类型

Pl/SQL集合类型(复合数据类型)
1.索引表
2嵌套表
3变长数组

索引表(保存单列多行)
1也称为PL/SQL表
2索引表是用来处理PL/SQL数组的数据类型
3索引表元素个数没有限制,且下标可以为负值。这是与数组区别的地方

语法
type type_Name is table of element_type
[not null] index by key_type;
identifier type_Name ;

type_Name :指定用户自定义数据类型的名称
element_type :指定索引表元素的数据类型
not null:表示索引表不允许引用null元素
key_type:用于指定索引表元素下标的数据类型
(binary_integer,pls_integer,varchar2)
identifier :定义索引表 的变量

declare
type sname_table_type is table of student.sname%type
index by binary_integer;
sname_table sname_table_type;

begin
select sname into sname_table(1) from student where sno=’s001’;
select sname into sname_table(2) from student where sno=’s002’;
dbms_output.put_line(sname_table(1)||’———’||sname_table(2));
end;
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值