1

I am new to SQL and recently installed Oracle 11g. I read the post here on selecting all tables from user_tables. I'm trying to select a specific table and following some of the suggestions in the post does not appear to work.

The following executes fine and returns all tables available to me including a table named faculty_t:

select * from user_tables;
select * from dba_tables;
select * from all_tables;
desc faculty_t;

But I get error when I do the following:

select * from user_tables where table_name = FACULTY_T;

The first set of statements confirm that I do have a table named faculty_t. However, trying to select this table from user_tables, all_tables, or dba_tables does not appear to work for me right now. The error message reads something like:

ORA-00904: "FACULTY_T": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:
Error at Line: 208 Column: 8

Any thoughts? Thanks!

Community
  • 1
  • 1
sedeh
  • 6,213
  • 6
  • 44
  • 59

1 Answers1

3

String literals in SQL are wrapped in '. So:

select * from user_tables where table_name = 'FACULTY_T';

When you did a desc faculty_t, the SQL engine knew that a table name was expected at that spot (the syntax expects a table name there). But in your select query, sql is just looking for the value of a column that happens to have a string data type, so you need to use the ' for a string literal.

DWright
  • 9,152
  • 4
  • 35
  • 53