Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

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
0
PHIL Sawyer
Asked:
PHIL Sawyer
  • 3
2 Solutions
 
slightwv (䄆 Netminder) Commented:
select owner,table_name,column_name
from dba_tab_columns
where column_name like '%ROR%MTD%'
/
0
 
Steve WalesSenior Database AdministratorCommented:
You can do:

select owner, table_name, column_name
from dba_tab_columns
where column_name like '%YOUR_MATCH_PATTERN%'

Open in new window

0
 
PHIL SawyerAuthor Commented:
Thanks guys
0
 
slightwv (䄆 Netminder) Commented:
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%'
0
 
slightwv (䄆 Netminder) Commented:
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

0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now