search colum names in tables

Posted on 2014-08-07
Last Modified: 2014-08-07
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.

Schema        Table          Colum_Name
TEST1           TABLE1      A_ROR_MTD
TEST2           TABLE 2     RORMTD
Question by:PHIL Sawyer
    LVL 76

    Assisted Solution

    by:slightwv (䄆 Netminder)
    select owner,table_name,column_name
    from dba_tab_columns
    where column_name like '%ROR%MTD%'
    LVL 22

    Accepted Solution

    You can do:

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

    Open in new window


    Author Comment

    by:PHIL Sawyer
    Thanks guys
    LVL 76

    Expert Comment

    by: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%'
    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    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


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    PL/SQL Group by 2 34
    SQL Query 6 56
    Help on Oracle SQL queries 2 53
    Oracle Finace 3 17
    Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
    Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
    This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now