http://www.blogjava.net/decode360/archive/2008/10/16/286802.html
create or replace type person as object(
name varchar2(10),
sex varchar2(2),
birthday date,
age number(2)
);
两种创建对象表的方式
第一,
create table t(
person_col person,
emp_id number,
dep_id number
);
第二,
create table t of person;
delete from t;
insert into t values(‘ww‘,‘f‘,sysdate-1,23);
insert into t values(‘ni‘,‘m‘,sysdate-2,24);
insert into t values(‘ss‘,‘f‘,sysdate-3,25);
insert into t values (
person(‘张三‘,‘男‘,sysdate-1,23),
100,
10);
insert into t values (
person(‘张四‘,‘女‘,sysdate-2,44),
101,
11);
insert into t values (
person(‘wo‘,‘fe‘,sysdate-3,44),
102,
11);
insert into t values (
person(‘ni‘,‘f‘,sysdate-4,45),
103,
12);
delete from t where emp_id=101;
在sqlplus中用下面语句可以看到内容
select * from t;
但在sqldeveloper中看不到person_col列的值,是如下的值
[KYC_ACC.PERSON] 102 11
[KYC_ACC.PERSON] 103 12
一定要用别名,否则引起岐义(schema名字)
select t1.person_col.age from t t1;