Link to home
Start Free TrialLog in
Avatar of PHIL Sawyer
PHIL SawyerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

search colum names in tables

Hi
Is there an efficient way to search all tables with column name - eg like ROR_MTD.
I would like the output to show the table name - preferably in what schema - and the column name.

eg
Schema        Table          Colum_Name
TEST1           TABLE1      A_ROR_MTD
TEST2           TABLE 2     RORMTD
etc
Regards
SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PHIL Sawyer

ASKER

Thanks guys
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Should also add that this shouldn't be necessary but some, not familiar with Oracle, does some 'bad' things from time to time and creates objects with forced case (lower case characters).

Again, this isn't the 'default' for Oracle and is a pretty BAD idea but I've seen some folks do it.

If this is a concern or possibility for you:
...
where upper(column_name) like '%ROR%MTD%'
Something to add to your bag-o-tricks to help with this in the future.

Oracle is very good about naming the views.

I created a script using the query below and named it find_view.sql.

Whenever I'm not sure of the 'exact' view I want, I run the script and give it the 'item' I think I'm looking for.

in this example, you were after a COLUMN names.

Run the select/script and type in COLUMN when prompted.

It will return all views that have that term in them.  You can then scan the list pretty quick and look up the views in the docs that you think might be what you need.

dba_tab_columns is in that list.  Given the name of the view, one might think that this might contain table columns?  A quick search of the docs would confirm it.

select view_name 
from dba_views 
where view_name like upper('%&view_to_find%') order by 1

Open in new window