You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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配置

  1. 先创建父类型表:
create table lesemployes of temploye ( PRIMARY KEY (nomE) );
  1. 执行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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 09:43:24