Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORA 00904 Error:Invalid Identifier

I have installed Oracle 10g in my virtual XP and created a table using

create table reg1 (
  fname varchar2(30),
  lname varchar2(30),
  addr varchar2(30),
  mail varchar2(30),
  occu varchar2(30),
  uname varchar2(30),
  passwd varchar2(30)
);

and the table created successfully.But when I am trying to fetch the values by simple query like

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

I am getting error like

ORA-00904: "bbb": invalid identifier

I cannot understand what I have done wrong here.

like image 922
Mistu4u Avatar asked Jun 30 '12 19:06

Mistu4u


People also ask

What does invalid identifier mean in Oracle?

Invalid identifier means the column name entered is either missing or invalid, this is one of the most common causes of this error but not the only one. Sometimes it comes if you use names, which happened to be reserved word in Oracle database.

What is missing expression error in SQL?

The ORA-00936 message is a missing expression error in Oracle. All that 'missing expression' means is that When attempting to operate a query, a particular part of the clause necessary for it to function was omitted in the text. Stated simply, you left out an important chunk of what you were trying to run.

Is ID a reserved word in Oracle?

By default, Oracle will upcase any identifiers. So if you need either lower case characters or special characters, or the identifier is an Oracle reserved word, it needs to be enclosed in double quotes. Since double quotes preserves case, the identifier also needs to be the correct case.

Is not a group by expression?

ORA-00979 “ Not a GROUP BY expression ” is an error issued by the Oracle database when the SELECT statement contains a column that is neither listed in GROUP BY nor aggregated. This error message can be confusing to beginners.


2 Answers

Use single quotes.

select fname,lname from reg1 where uname='bbb';
like image 101
Andrew Leach Avatar answered Oct 11 '22 12:10

Andrew Leach


Oracle uses double quotes " in order to identify cased object names. For instance the table "test" is not the same as the table test.

Strings should be enclosed by single quotes, '.

Making your query:

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

What's actually happening in your query is Oracle is trying to find the column "bbb" in the table reg1, as this column doesn't exist you get the error thrown.

like image 35
Ben Avatar answered Oct 11 '22 11:10

Ben