DROP TABLE PEOPLE1;
DROP TABLE PEOPLE2;
DROP TYPE CHILD1;
DROP TYPE CHILD2;
CREATE OR REPLACE TYPE commun AS OBJECT (c1 integer, C2 date) NOT FINAL
/
CREATE OR REPLACE TYPE CHILD1 UNDER PARENT (c3 varchar2(20), c4 number(8,2))
/
CREATE OR REPLACE TYPE CHILD2 UNDER PARENT (c5 number(5,2), c6 varchar2(10))
/
CREATE TABLE PEOPLE1 OF CHILD1;
CREATE TABLE PEOPLE2 OF CHILD2;
insert into people1 values (1, sysdate, 'ABCDE', 3.14);
insert into people1 values (2, sysdate, 'FGGHJK', 2.24);
insert into people2 values (3, sysdate, 1.14, 'test');
insert into people2 values (4, sysdate, 8.24 , 'test1');
desc people1
desc people2
select * from people1;
select * from people2;
2条答案
按热度按时间mnemlml81#
Oracle不支持按表继承-它使用TYPE(对象)。在Oracle中执行类似操作的方法是声明父TYPE和子TYPE,然后创建一个表来包含PARENT的示例-类似于:
由于CHILD是PARENT的子类型,因此应该可以将CHILD示例存储在PEOPLE表中。
分享和享受。
jtoj6r0c2#
是的,它看起来像在postgres表继承中一样工作,上面提到的解决方案,例如。