Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

searching for a table field

Status
Not open for further replies.

FALCONSEYE

Programmer
Jul 30, 2004
1,158
US
Another 'how do i do this in oracle' question .

sql version >

Code:
SELECT dbo.sysobjects.name
FROM dbo.syscolumns INNER JOIN
dbo.sysobjects ON dbo.syscolumns.id = dbo.sysobjects.id
where dbo.sysobjects.xtype  = 'U' 
and dbo.syscolumns.name = 'description'

this will give me all the db tables (whatever schema i am in) that has a column named "description"

how do i do this in oracle?
I found this :

Code:
select * from all_tab_columns
where column_name like '%description%';

but it returns 0 rows. I know for a fact that my product table does have a description field in that schema.

thanks in advance.

 
keep forgetting that oracle is case sensitive.

Code:
select * from all_tab_columns
where column_name like '%DESCRIPTION%'

works fine.

Next question, what if I want to search stored procs, views, and functions for this column. Is it possible?

 
Falcon said:
keep forgetting that oracle is case sensitive.
Actually, Falcon, Oracle is not case sensitive:
Code:
SQL> select * from dual;

D
-
X

SQL> select * from DUAL;

D
-
X

SQL> SeLeCt * FrOm DuAl;

D
-
X
Oracle does, however, store all of its objects names, by default, in UPPERCASE, regardless of the case you use to create the object. If you want to create an object with a case-sensitive name, then you must do so using double quotes in all references to the name:
Code:
SQL> create table "falcon" (x number);

Table created.

SQL> select * from falcon;
select * from falcon
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "falcon";

no rows selected
Following this technique results in extreme derision from Oracle professionals...it is bad form in Oracle because it creates nothing but migraine headaches when writing code or referencing objects...Do Not Use Double Quotes to Create Objects or Columns in Oracle !!!


Does that clarify things a bit? If you have additional questions, please post.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”
 
I was talking about

Code:
select * from all_source
where upper(text) like '%DESCRIPTION%'

vs.

Code:
select * from all_source
where text like '%description%'


the second one returns 0 records.
It will save me some time if i don't keep forgetting this.

 
Hi,
Its all about knowing your data ( or Oracle's data) -
The LIKE operator ( and the = ), when given a literal, will look for that exact value.






[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top