嵌套表和对象表

创建对象类型

create or replace type emp_type as object( name varchar2(200));


创建对象类型的表类型

create or replace type emp_tab_type is table of emp_type;


创建嵌套关系的表

create table include_dept
( name varchar2(100), emps emp_tab_type)
nested table emps store as emps_ct

创建一个include_dept表和emps_ct表

嵌套表不支持引用约束

delete include_dept;
begin
for i in 1..10 loop
insert into include_dept(name,emps )values(i, emp_tab_type( emp_type(i)));//插入数据
end loop;
end;
select name from table(select emps from include_dept where name=1);//查询数据


创建对象类型

create or replace type  address_type is object
(place varchar2(200),no varchar2(20));
使用对象类型创建表
create table person
(
   name varchar2(200),
   address address_type
)

插入数据

begin
   for i in 1..100 loop
       insert into person(name,address) values('name'||i,address_type('place'||i,'no'||i));
   end loop;
commit;
end;

select t.name,t.address.place,t.address.no from person t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值