oracle ORA-02267: 列类型与引用的列类型不兼容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44153618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-02267: column type incompatible with referenced column type
提问by Fatin Nadia
This is my coding in SQL:
这是我在 SQL 中的编码:
CREATE TABLE TICKET (
TICKET_NO NUMBER,
VENUE_NO VARCHAR(3),
TICKET_DATE DATE,
TICKET_PRICE NUMBER(8,2),
PRIMARY KEY (TICKET_NO),
CONSTRAINT TICKET_VENUE_NO_FK
FOREIGN KEY (VENUE_NO) REFERENCES VENUE
);
This is error stated:
这是错误说明:
Error starting at line 1 in command:
CREATE TABLE TICKET (
TICKET_NO NUMBER,
VENUE_NO VARCHAR(3),
TICKET_DATE DATE,
TICKET_PRICE NUMBER(8,2),
PRIMARY KEY (TICKET_NO),
CONSTRAINT TICKET_VENUE_NO_FK
FOREIGN KEY (VENUE_NO) REFERENCES VENUE)
Error at Command Line:8 Column:13
Error report:
SQL Error: ORA-02267: column type incompatible with referenced column type
02267. 00000 - "column type incompatible with referenced column type"
*Cause: The datatype of the referencing column is incompatible with the
What wrong with my coding?
我的编码有什么问题?
回答by rafalg
Check that the VENUE_NO field in the VENUE table is of the same type as in this table, i.e. VARCHAR(3).
检查VENUE 表中的VENUE_NO 字段是否与该表中的类型相同,即VARCHAR(3)。
回答by MT0
You need to make sure that the data types match between the TICKET.VENUE_NOcolumn and the VENUE.VENUE_NOcolumn.
您需要确保TICKET.VENUE_NO列和VENUE.VENUE_NO列之间的数据类型匹配。
回答by Kaiyuan Zhang
It is often seen in the FOREIGN KEY (attr1) REFERENCES attr2. You need to check the data type you reference, it should keep the same as the previous table. Such as varcharand char.
它经常出现在FOREIGN KEY (attr1) REFERENCES attr2. 您需要检查您引用的数据类型,它应该与上表保持一致。比如varchar和char。

