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?

2

4 Answers

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

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

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.

2