8

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.

2 Answers 2

19

Use single quotes.

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

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.

1
  • Not just Oracle, all SQL databases
    – OMG Ponies
    Jun 30, 2012 at 19:53

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.