Home >Database >Mysql Tutorial >Why Does My Oracle Query Return ORA-00904: Invalid Identifier?

Why Does My Oracle Query Return ORA-00904: Invalid Identifier?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-18 16:40:21307browse

Why Does My Oracle Query Return ORA-00904: Invalid Identifier?

ORA-00904 Error: Invalid Identifier Resolution

When executing a simple query in Oracle, you may encounter the "ORA-00904: Invalid Identifier" error. This issue typically arises when values are incorrectly quoted.

Problem:

A user attempts to fetch values from a table using the following query:

select fname, lname 
  from reg1 
 where uname="bbb";

However, this query results in the error:

ORA-00904: "bbb": invalid identifier

Solution:

The error indicates that the value "bbb" is not recognized as a valid identifier. In Oracle, string values must be enclosed in single quotes. To resolve the issue, use the following modified query:

select fname,lname 
  from reg1 
 where uname='bbb';

Enclosing the value in single quotes will identify it as a string literal and prevent it from being treated as an invalid identifier. By making this minor adjustment, the query should execute successfully and return the requested values.

The above is the detailed content of Why Does My Oracle Query Return ORA-00904: Invalid Identifier?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn