prompt
prompt 创建类型eoda.address_type
--declare 
--    num number;
begin
--    select count(1) into num all_types where type_name = upper( 'address_type' ) and owner = upper( 'eoda' );
--    if num = 1 then 
--        execute immediate 'drop type eoda.address_type';
--    end if;
    execute immediate '
        create or replace type eoda.address_type
        as object 
        (
            city        varchar2(30),
            street      varchar2(30),
            state       varchar2(2),
            zip         number
        )
    ';
end;
/

prompt
prompt 创建类型eoda.person_type
begin
    execute immediate '
        create or replace type eoda.person_type
        as object 
        (
            name            varchar2(30),
            dob             date,
            home_address    address_type,
            work_address    address_type
        )
    ';
end;
/

prompt
prompt 创建表eoda.people
declare 
    num number;
begin
    select count(1) into num from all_tables where table_name = upper( 'people' ) and owner = upper( 'eoda' );
    if num = 1 then
        execute immediate 'drop table eoda.people';
    end if;
    execute immediate 'create table eoda.people of eoda.person_type';
end;
/

desc eoda.people;

prompt
prompt
begin
    execute immediate 'truncate table eoda.people';
    insert into eoda.people values ( 'Tom','15-mar-1965',
        address_type ( 'Denver','123 Main Street','Co','12345' ),
        address_type( 'Redwood','1 Oracle Way','Ca','23456' ) );
end;
/

begin 
    dbms_output.put_line( '查询1' );
end;
/
select name,dob,p.home_address Home,p.work_address work from eoda.people p;

begin 
    dbms_output.put_line( '查询2' );
end;
/
select name,p.home_address.city from eoda.people p;


select name,segcollength 
  from sys.col$
 where obj#= ( select object_id 
                 from user_objects
                where object_name = upper( 'people' )
             );

select sys_nc_rowinfo$ from eoda.people;
