Cause: The column name entered is either missing or invalid.
Action: Enter a valid column name. A valid column name must begin with a letter, be less than or equal to 30 characters, and consist of only alphanumeric characters and the special characters $, _, and #. If it contains other characters, then it must be enclosed in double quotation marks. It may not be a reserved word.
ORA-00904 is a very simple issue. ORA-00904 may occur when we try to create or alter a table with invalid column name. It also may occur when we try to reference a non existing column in a select / insert / update / delete statement.
Examples which may lead to ORA-00904 are following:
SQL> CREATE TABLE TEST
2 (
3 ID NUMBER,
4 NAME VARCHAR2(200),
5 COMMENT VARCHAR2(4000)
6 );
COMMENT VARCHAR2(4000)
*
ERROR at line 5:
ORA-00904: invalid identifier
SQL> select empid from scott.emp;
select empid from scott.emp
*
ERROR at line 1:
ORA-00904: "EMPID": invalid identifier
SQL> update scott.emp set salary=1000 where empno = 3625;
update scott.emp set salary=1000 where empno = 3625
*
ERROR at line 1:
ORA-00904: "SALARY": invalid identifier
SQL> delete scott.emp where empid = 3625;
delete scott.emp where empid = 3625
*
ERROR at line 1:
ORA-00904: "EMPID": invalid identifier
SQL> insert into scott.emp (empno, empname, sal)
2 values(3625, 'Amit', 10000);
insert into scott.emp (empno, empname, sal)
*
ERROR at line 1:
ORA-00904: "EMPNAME": invalid identifier
SQL> select emp.ename from scott.emp e;
select emp.ename from scott.emp e
*
ERROR at line 1:
ORA-00904: "EMP"."ENAME": invalid identifier
ORA-00904 can simply be avoided by using the valid column name in create or alter statement. Also for DML statements ORA-00904 can be avoided by making a valid reference to the column name or the alias.
A valid column name must follow following criteria
- The column name must begin with a letter.
- The column name can not be of more than 30 characters.
- The column name must be made up of alphanumeric characters
- The column name may contain following special characters: $, _, and #.
- If the column name uses any other characters, it must be enclosed in double quotation marks.