Oracle对象类型继承嵌套表创建报ORA-00904错误的解决求助
解决Oracle对象类型继承中子类型嵌套表存储的ORA-00904错误
错误原因
父类型temploye并未定义liste_cages属性,该属性仅属于子类型tgardien。直接在基于父类型创建的表中指定nested table liste_cages时,Oracle无法识别该标识符,因此抛出ORA-00904错误。
解决方案
需要明确指定嵌套表属性所属的子类型,使用FOR SUBTYPE子句关联子类型tgardien,有两种实现方式:
方式1:创建表时直接指定
修改表创建语句,在nested table子句后添加for subtype tgardien:
create table lesemployes of temploye ( PRIMARY KEY (nomE) ) nested table liste_cages store as cages for subtype tgardien;
方式2:先创建表,再通过ALTER TABLE配置
- 先创建父类型表:
create table lesemployes of temploye ( PRIMARY KEY (nomE) );
- 执行ALTER TABLE命令为子类型的嵌套表指定存储:
ALTER TABLE lesemployes ADD NESTED TABLE liste_cages STORE AS cages FOR SUBTYPE tgardien;
验证示例
插入子类型数据时,需使用tgardien类型构造对象:
INSERT INTO lesemployes VALUES( tgardien( 'Dupont', '12 Rue Paris', tspecialites('Garde', 'Nettoyage'), ens_cages() ) );
内容的提问来源于stack exchange,提问作者patricia100
相关产品推荐
相关产品推荐

