【问题标题】:Error: ORA-02267: column type incompatible with referenced column type [closed]错误:ORA-02267:列类型与引用的列类型不兼容 [关闭]
【发布时间】:2021-06-20 09:46:16
【问题描述】:

我在 SQLPLUS 中创建表

ICECREAM (Ice_cream_ID, Ice_cream_flavor, price, years_first_offered, selling _status)

引用:

INGREDIENT (Ingredient_ID, Ingredient_name, cost)

它又引用了这个表:

CREATE TABLE RECIPE 
(
    Ice_cream_ID CHAR(10) REFERENCES ICECREAM, 
    ingredient_ID CHAR(10) REFERENCES INGREDIENT,
    quantity_used CHAR(10),
    PRIMARY KEY (ice_cream_ID, ingredient_ID)
);

我在第 2 行遇到错误:

ORA-02267:列类型与引用的列类型不兼容

我需要 FK 吗?

【问题讨论】:

  • 错误信息的哪一部分你不明白?看起来很清楚。
  • @GordonLinoff 它一直说第 2 行有错误,我无法发现错误
  • 每个表中的列的数据类型是什么?看起来您在其他表中以不同方式定义了 ice_cream_id 和/或 ingredient_id
  • 请与冰淇淋和配料的数据类型共享表定义。
  • OK - 所以你可以看到NUMBER(5)VARCHAR2(10) 不兼容?

标签: sql oracle sqlplus


【解决方案1】:

icecream 表的Ice_cream_IDrecipe 表的Ice_cream_IDingredient 表的ingredient_IDrecipe 表的ingredient_ID 之间的数据类型可能不匹配。

请检查。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-29
    • 2013-10-30
    • 1970-01-01
    • 2013-04-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多