ORA-02267: column type incompatible with referenced column type

Viewed 25350

This is my coding in 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?

4 Answers

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 varchar and char.

It could be due to non correspondence of data types. Make sure that venue_no has the same type in both tables.

Related