Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORA-02267: column type incompatible with referenced column type

Tags:

sql

oracle

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?

like image 612
Fatin Nadia Avatar asked May 24 '17 08:05

Fatin Nadia


2 Answers

Check that the VENUE_NO field in the VENUE table is of the same type as in this table, i.e. VARCHAR(3).

like image 130
rafalg Avatar answered Nov 11 '22 07:11

rafalg


You need to make sure that the data types match between the TICKET.VENUE_NO column and the VENUE.VENUE_NO column.

like image 2
MT0 Avatar answered Nov 11 '22 07:11

MT0