Ora-00904 Error Message “Invalid Identifier”

Error Ora-00904 means you are attempting to execute an SQL statement that is one of the following:

  1. The SQL statement includes an invalid column name.
  2. The SQL statement includes a column name which does not currently exist.

This error is most common when querying a SELECT statement.

To resolve this error, first check to make sure the column name being referenced exists. If it does not exist, you must create one before attempting to execute an SQL statement with the column. If the column name exists, be sure to check that the column name is in the proper syntax. To be valid, the column name must meet the following criteria:

  • The column name cannot be a reserved word.
  • The first letter of the column name must be a letter.
  • The column name must be less than or equal to 30 characters.
  • The column name must be made up of alphanumeric characters.
  • The column name can contain any of the following 3 characters: $, _, #. If the column name includes any other characters, it must be enclosed with double quotation marks.

The following is an example of an SQL statement containing Error Ora-00904:

SELECT column_name AS “column_id”

FROM table

ORDER BY column_id;

In this example, the name “column_id” is aliasing the column_name, which is later queried as column_id. Notice the missing double quotation marks in the second column_id. To resolve the error, follow the proper syntax by enclosing “column_id” in double quotation marks:

SELECT column_name AS “column_id”

FROM table

ORDER BY “column_id”;

To avoid seeing error Ora-00904 in the future, make sure the column name meets the criteria for a valid column name. Rewrite the query to follow this format. If you are attempting to query a column name which does not exist, you must create the column. Always double check spelling.