“ORA-00904: invalid identifier” is a familiar error to Oracle developers. It occurs, for example, when you refer to a table column that does not exist.
What’s worse than an error that shows up when you don’t expect it? An error that does NOT show up when you totally expect it.
Here’s a puzzle for you to solve. You’re given two tables – EMPL and DEPT – in which column EMP_DEPT_ID of table EMPL references DEPT_ID of table DEPT.
SQL> desc dept
Name Null? Type
----------------- -------- ------------
DEPT_ID NUMBER(2)
DEPT_NAME VARCHAR2(6)
SQL> desc empl
Name Null? Type
----------------- -------- ------------
EMP_ID NUMBER(2)
EMP_NAME VARCHAR2(6)
EMP_DEPT_ID NUMBER(2)
Note that the foreign key column names in the two tables are not identical. The column is called DEPT_ID in table DEPT, EMP_DEPT_ID in table EMPL.
Read more