- 创建类型comm_info
CREATE TYPE comm_info AS OBJECT (
no number(3),
comm_type varchar2(20),
comm_no varchar2(30));
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201230151550995.png)
- 创建可变数组comm_info_list
CREATE TYPE comm_info_list AS VARRAY(50) OF comm_info;
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201230151725729.png)
- 创建表
create table user_info
(user_id number(6),
user_name varchar2(20),
user_comm comm_info_list);
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201230152017333.png)
- 向可变数组插入记录
insert into user_info
values(1,'mary',comm_info_list(comm_info(1,'手机','13651401919'),
comm_info(2,‘呼机’,‘1281234567’)));
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201230152218564.png)
insert into user_info
values(2,'carl',comm_info_list(comm_info(1,'手机','13901018888'),
comm_info(2,'呼机','1281234567')));
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201230152259944.png)
- 查询可变数组
select user_comm from user_info
where user_id=1;
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201230152347334.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk5NzgwMg==,size_16,color_FFFFFF,t_70)
select comm_type,comm_no
from table(select user_comm from user_info
where user_id=1)
where no=1;
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201230152417571.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk5NzgwMg==,size_16,color_FFFFFF,t_70)