Need a query to find a table by two of its column names

I work in software quality assurance. Oftentimes I am trying to figure out from which table data is being pulled, but the database has thousands of tables to look through. Instead of looking through all the tables, I just take a guess at one of the column names and execute a query like this:
SELECT table_name FROM information_schema.columns WHERE column_name like '%pur%code%'
That usually works, but occassionally it can return hundreds of table names which doesn't help me much. Instead, I'd like to form a query that could take two column names and return all the tables that have those columns.
So, in English, I want to say:
"Give me the names of all the tables that have a column named like %pur%code% and another column named like %client%loc%"
How do I do this?

One might have hoped that the QA guy actually had sufficient documentation to tell him which table information was "pulled from".
(or is he actually checking that the documentation is accurate and complete .... )
SQL> select phrase from well_known
         where upper ( phrase ) like '%PIG%' and upper ( phrase ) like '%FLY%'

Similar Messages

  • Need a query to list all table names

    I have more than 500 tables in my database.
    'insert_date' & 'update_date' columns are found in more than 100 tables with data type as date.
    I need a query to list all table names and 'insert_date' , 'update_date' column's content.
    Please Help
    Lee1212
    Message was edited by:
    LEE1212

    I have more than 500 tables in my database.
    'insert_date' & update_date column is found in more
    than 100 tables with data type as date.
    I need a query to list all table names and
    'insert_date' column's content.What do you mean by "column's content". A table can have many rows. Do you want to display all the distinct value for these columns?
    Below is the query to get the tables which has columns insert_Date and update_date
    select table_name
    from user_tab_columns
    where column_name ='INSERT_DATE'
    or column_name ='UPDATE_DATE'
    /You can write a PL/SQL block to retrive the distinct values of INSERT_DATE for these tables
    declare
    TYPE ref_cur IS REF CURSOR;
    insert_date_cur ref_cur;
    lv_insert_date DATE;
    cursor tables_list IS
    select table_name
    from user_tab_columns
    where column_name ='INSERT_DATE';
    begin
    for cur_tables in tables_list
    loop
      OPEN insert_date_cur for 'SELECT DISTINCT insert_date from '||cur_tables.table_name;
      DBMS_OUTPUT.PUT_LINE(cur_tables.table_name);
      DBMS_OUTPUT.PUT_LINE('--------------------------------');
      LOOP
      FETCH insert_date_cur into lv_insert_date;
      EXIT WHEN insert_date_cur%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE(lv_insert_date);
      END LOOP;
    CLOSE insert_date_cur;
    end loop;
    end;I haven't tested this code. There might be some errors. Just posted something to start with for you.

  • Writing a query to find out who is having a given responsibility name.

    Hi,
    I am new to Oracle Apps and have no idea about its tables. Can anyone please help me in writing a query to find out who is having a given responsibility name.
    Thanks in advance.
    Regards
    Himanshu

    Hi
    you can get required data by using this query
    select usr.user_name
    ,     res.responsibility_name
    from fnd_user usr
    ,     FND_USER_RESP_GROUPS_DIRECT usrrep
    ,     fnd_responsibility_tl res
    where usr.user_id=usrrep.user_id
    and usrrep.responsibility_id=res.RESPONSIBILITY_ID
    group by usr.user_name,res.responsibility_name
    Regards,
    Venky

  • Need a query to find Grops mapped on Folders

    Hi ,
    I need a query builder query to find out the list  of folder and mapped groups to those folder.
    Would you please let me know if that is possible I triead but no luck .
    Regards,
    Neo

    Hi,
    This query sound goods but I get error 
    Select SI_NAME, SI_KIND From CI_APPOBJECTS, CI_INFOOBJECTS
    Where PARENTS("SI_NAME='Myfolder'",'CHILDREN(''SI_NAME=''UserGroup''')")
    Please let me know if I am giong in right direction becuse I never used Parents and child concept bit confused.
    All I need is when I put in my folder name it has to show me all the groups mapped to it.
    If this query gives  the result , it will be the great logic I would say
    Thanks a ot.
    Neo A

  • Query to find out tables using view

    Hi
    I have a views using three tables.Now i wanted a query to find out number of views using three tables
    I have written a query
    select * from dba_views where text like '%SELECT%;
    It is giving me error as ora error EXPECTED NUMBER GOT LONG.
    Appreciate your help?

    SELECT DECODE(referenced_type, 'NON-EXISTENT', '.....',
    referenced_type) || ' ' || referenced_owner ||
    '.' || referenced_name r_name, ' is referenced by: ' ||
    type || ' ' || owner || '.' || name name,
    ' Referenced Link: ' || DECODE(referenced_link_name,
    NULL, 'none', referenced_link_name) r_link
    FROM dba_dependencies
    -- WHERE owner NOT IN ('SYS', 'SYSTEM')
    -- and rownum < 50
    ORDER BY 1,2;
    add your own where clause to it

  • Need a Query to find Unassigned Price Lists

    Hi
    I need a query which will show any Price List NOT assigned to a Business Partner.  I have the following:
    SELECT T0.[ListNum], T0.{ListName] From OPLN T0
    WHERE T0.[ListNum} NOT IN T1.[ListNum[ from OCRD T1
    Haven't worked that much with NOT IN statement.
    Thank you!

    Hi Daniel,
    Please check below Query.
    SELECT T0.[ListNum], T0.[ListName] From OPLN T0 WHERE T0.[ListNum] NOT IN ( SELECT DISTINCT T1.[ListNum] FROM OCRD T1 )
    Hope this help
    Regards::::
    Atul Chakraborty

  • Extract Time from date and Time and Need XLMOD Funtion to find the Difference between Two Time.

    X6 = "1/5/15 5:16 AM" & NOW ....................difference by Only Time
    not date
    X6 date and Time will be changing, Its not Constant
                Dim myDateTime As DateTime = X6
                Dim myDate As String = myDateTime.ToString("dd/MM/yy")
                Dim myTime As String = myDateTime.ToString("hh:mm tt")
                Dim myDateTime1 As DateTime = Now
                Dim myDate1 As String = myDateTime1.ToString("dd/MM/yy")
                Dim myTime1 As String = myDateTime1.ToString("hh:mm tt")
    Need to use this function to find the Difference between Two Time. due to 12:00 AM isuue
    Function XLMod(a, b)
        ' This replicates the Excel MOD function
        XLMod = a - b * Int(a / b)
    End Function
    Output Required
     dim dd  = XLMod(myTime - myTime1)
    Problem is myTime & myTime1 is String Need to convert them into Time, Later use XLMOD Funtion.

    Induhar,
    As an addendum to this, I thought I'd add this in also: If you have two valid DateTime objects you might consider using a class which I put together a few years ago
    shown on a page of my website here.
    To use it, just instantiate with two DateTime objects (order doesn't matter, it'll figure it out) and you'll then have access to the public properties. For this example, I'm just showing the .ToString method:
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim date1 As DateTime = Now
    Dim date2 As DateTime = #1/1/1970 2:35:00 PM#
    Dim howOld As New Age(date1, date2)
    MessageBox.Show(howOld.ToString, "Age")
    Stop
    End Sub
    End Class
    I hope that helps, if not now then maybe at some point in the future. :)
    Still lost in code, just at a little higher level.
      Thanx frank, can use this in Future....

  • Using "FIND IN TABLE" to search in selected columns

    Hi,
    I want to use "FIND" to search for a pattern in certain table columns only, but ABAP Keyword Documentation ([FIND IN TABLE itab|http://help.sap.com/abapdocu_70/en/ABAPFIND_ITAB.htm]) does not state about this option.
    Is it possible to do so?
    Thanks,
    Joon Meng

    Hi,
    1. if you want to find particular record u can use 
    READ TABLE itab { table_key  | free_key | index } result.
    2. if you want to compare the fied value level u can use
    log_exp - Logical Expressions
    CO, CN, CA, NA, CS, NS, CP, NP
    Regards,
    G

  • Can I create a view based on two tables that have the same column name?

    I have two tables A and B. Each table has 50+ columns.
    I want to create a view that includes all the columns in A and all the columns in B. I created a view with a select statement that says
    Select A.*, B.*
    From A, B
    where A.id = B.id
    It returns an error because in each table I have a column that keeps track if a record has been changed called Modified_By. That's where it chokes up on I figure. I would like to write the view without explicitly writing each column name from A and B as part of the select statement. The actual select statement works fine and only bombs when trying to turn the select statement into a view.

    You will have to type the full column list at least once. You can save a few keystrokes (i.e. alias. on every column) by providing the column names to the CREATE part instead of in the SELECT part. Something like:
    SQL> desc t
    Name                                      Null?    Type
    ID                                                 NUMBER
    NAME                                               VARCHAR2(10)
    SQL> desc t1
    Name                                      Null?    Type
    T_ID                                               NUMBER
    LOC_ID                                             NUMBER
    NAME                                               VARCHAR2(15)
    SQL> CREATE VIEW t_v (id, t_name, t_id, loc_id, t1_name) AS
      2  SELECT t.*, t1.*
      3  FROM t, t1
      4  WHERE t.id = t1.t_id;
    View created.HTH
    John

  • Need a query to find Table Dependancy

    Hi Experts,
    I am in a need to find out which are all tables refer to particular table 'ABC' and / or it's column 'column_1', since I am new to environment and have about 500 + tables.
    Please tell me what are the various ways, I can achieve above requirement?
    Regards,
    MS

    user_cons_columns
    Information about accessible columns in constraint definitions
    OWNER
    Owner of the constraint definition
    CONSTRAINT_NAME
    Name associated with the constraint definition
    TABLE_NAME
    Name associated with table with constraint definition
    COLUMN_NAME
    Name associated with column or attribute of object column specified in the constraint definition
    POSITION
    Original position of column or attribute in definition
    Also try this, DBMS_METADATA
    set long 9999
    select dbms_metadata.get_ddl('TABLE','ABC') FROM DUAL;
    Edited by: rajeysh on Jun 21, 2011 2:44 AM
    Edited by: rajeysh on Jun 21, 2011 2:44 AM

  • Need sql query to find out same item is used in open po and closed po

    Hi Experts,
    I have an requirement is that, i need to find out the item is used in open po and closed po.
      example: A is the item is used in closed PO and Open PO.
      i need to write down the scripts how many same items is used in open po and closed po.
    if any sql script is there please share.
    Please let us know if any concerns.
    Thanks
    bmn

    Hi
    Please try below query
    select
    distinct c.segment1
    from
    po_lines_all a,
    po_line_locations_all b,
    mtl_system_items_b c
    where
    a.po_line_id= b.po_line_id
    and a.item_id=c.inventory_item_id
    and b.closed_code='OPEN'
    and a.item_id in ( select 
    item_id
    from
    po_lines_all d,
    po_line_locations_all e,
    mtl_system_items_b f
    where
    d.po_line_id= e.po_line_id
    and d.item_id=f.inventory_item_id
    and e.closed_code in ('CLOSED','FINALLY CLOSED','CLOSED FOR INVOICE','CLOSED FOR RECEIVING'));

  • Need MDX query to find something like date diff and Date Range for last 10 days

    Hi ,
    I need two Query .First Query for below;
    I have below data in table like.
    Cat      StartDate    EndDate     
    A    2000-01-01     2000-01-15   
    B    2000-01-02     2000-01-30    
    C    2000-01-01     2000-01-31    
    D    2000-02-01     2000-02-28    
    A    2000-01-10     2000-01-31    
    I need if Startdate and Date completes whole one month then set status =1 else  0 using MDX query.
    like this ;
    Cat      StartDate    EndDate       Status
    A    2000-01-01     2000-01-15    1
    B    2000-01-02     2000-01-30    0
    C    2000-01-01     2000-01-31    1
    D    2000-02-01     2000-02-28    1
    A    2000-01-10     2000-01-31    1
    In second query I need last 10 days from current days like;
    Now = 8/20/2014
    output will be ;
    8/20/2014
    8/19/2014
    8/18/2014
    8/17/2014
    8/16/2014
    8/15/2014
    8/14/2014
    8/13/2014
    8/12/2014
    8/11/2014
    8/10/2014
    Please help me .
    Thanks

    Hi Prajapati,
    In your scenario, you can use Properties and Datediff function to achieve your requirement. Since not know the structure of your cube, we cannot give you the esact query.
     I have tested it on the AdventureWorks cube, the query below is for you reference.
    WITH MEMBER [Measures].[StartDate]
    AS
    [Employee].[Employee Department].CURRENTMEMBER.PROPERTIES('Start Date')
    MEMBER [Measures].[WorkYear]
    AS
    DATEDIFF('yyyy',[Measures].[StartDate],NOW())
    MEMBER [Measures].[Status]
    AS
    IIF(DATEDIFF('yyyy',[Measures].[StartDate],NOW())>10,1,0)
    SELECT {[Measures].[StartDate],[Measures].[WorkYear],[Measures].[Status]} ON 0,
    [Employee].[Employee Department].[Employee].MEMBERS ON 1
    FROM [Adventure Works]
    Results
    Reference
    http://msdn.microsoft.com/en-us/library/ms144821.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • Need a query to find newline characters data( either chr(10) or chr(13))

    I have 5 columns in a table and these columns have newline characters data( either chr(10) or chr(13)).
    Now I need to fetch data so that all the records which have new line character( either chr(10) or chr(13) ) in any of these 5 columns should be retrieved.
    Please help me with a correct query for this task.
    Edited by: nav on Jun 2, 2011 10:21 PM

    An example .. you can do it for all 5 columns adding "OR" conditions
    with t as
    (select 'Arun'||chr(10) a, 'Gupta'||chr(13) b from dual union all
    select 'Dinesh'||chr(10) a, 'Kumar'||chr(13) b from dual union all
    select 'Naresh'||chr(10) a, 'Raja' b from dual union all
    select 'Harish' a, 'Mahesh' b from dual union all
    select 'Jatin'||CHR(13) a, 'Mahesh' b from dual
    select * from t  
    where a like '%'||CHR(10)
           or a like '%'||CHR(13)
           or b like '%'||CHR(10)      
           or b like '%'||CHR(13)       Regards
    Arun

  • Need a Query to find whether the database needs any media recovery...

    Hi,
    I am at the mount stage of a database and yet be opened.at this stage any Query is available or any other way is there to find whether the database needs any media recovery or Instance recovery..?
    my objective is before opening the database i need to make sure it is consistent or inconsistent and any form of recovery is needed..
    thanks &regards,
    Ragunath
    Edited by: ragu.dba.in on Mar 6, 2013 12:57 AM

    Hi Ragunath,
    Use these queries , SCN should be consistent .. no fuzzy files, check for recovery of files in v$recover_file .. pass sufficient archives & fulfill the checks before open reset-logs
    set line 900
    set pages 900
    set echo on
    alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss';
    set numwidth 13
    col CHECKPOINT_CHANGE# for 9999999999999999
    col CHANGE# for 9999999999999999
    column error format a10
    column member format a60
    show parameter db_recover
    select * from v$recover_file;
    select file#, status from v$datafile;
    select file#, checkpoint_change#, checkpoint_time, error from v$datafile_header;
    select distinct status from v$backup;
    select distinct  checkpoint_change#  from v$datafile_header;
    select hxfil file_id, fhscn scn, fhthr thread, fhrba_seq sequence, fhsta status from x$kcvfh;
    select distinct fhscn from x$kcvfh;
    select hxfil file_id, fhtnm tablespace_name from x$kcvfh;
    ##### Fuzzy Check ####
    alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
    set feedback on
    set heading on
    set pagesize 1000
    set linesize 175
    column checkpoint_change# format 999999999999999999999
    select status, checkpoint_change#, fuzzy,
    to_char(checkpoint_time, 'DD-MON-YYYY HH24:MI:SS') as checkpoint_time,
    count(*)
    from v$datafile_header
    group by status, checkpoint_change#, fuzzy, checkpoint_time
    order by status, checkpoint_change#, fuzzy, checkpoint_time;Thanks,
    Ajay More
    http://www.moreajays.com

  • Query to find relevant Table name

    Hi i need a SQL query which should return me relevant table names. i.e. if there is table 'EMP' , then query should give table names with below result:
    EMP
    EMP_1
    EMP_2
    EMP_3
    EMP_4
    i.e. All tables which is starting with EMP (No Hardcoding of table, It should be dynamic way).I know we can achieve through SELECT * FROM USER_OBJECTS WHERE OBJECT_NAME LIKE 'EMP%'.
    But here object_name i will passing dynamically.
    Actually my main purpose is to create backup tables i.e. EMP is main table and EMP_1,EMP_2,EMP_3 .. EMP_100 is backup table.Now whenever i am making the any changes in EMP table, then i should take the backup of exiting EMP table and backup data should go to EMP_101 (as last table with sequence is EMP_100).
    Any idea in SQL , PL/SQL i would appreciate .
    Thanks

    here is a way:
    set serveroutput on
    declare
    tab_name varchar2(30) := 'EMP';
    new_tab_name varchar2(30);
    begin
      for i in (
            select * from (
                select t.*,
                        row_number() over(order by t.table_name desc) as row_nr ,
                        min(table_name) over () as originiall_table
                        from all_tables t
                where table_name like tab_name||'%'
            ) where row_nr = 1
      ) loop
        new_tab_name := substr(i.table_name, 1, instr(i.table_name, '_') - 1 )
                        ||'_'
                        || (TO_NUMBER(substr(i.table_name, instr(i.table_name, '_') + 1 )) + 1 ) ;
        execute immediate 'create table '||new_tab_name||' as select * from '||i.originiall_table;   
      end loop;
    end;but why do you want to keep too many copies of tables in db?
    anytime you will get problems with tablespaces.

Maybe you are looking for

  • Itunes error

    when i try and open itunes on my laptop i keep getting the error message Itunes new library and it wont let me open it. I've tried repairing it on control panel and i've also tried installing a newer version. Nothing works. Any ideas? Cheers

  • Modify stmt leads dump (urgent)

    PERFORM get_customer TABLES itab_futureorders. FORM get_customer TABLES p_itab STRUCTURE itab_orders .   DATA: wa_itab LIKE LINE OF itab_orders.   SELECT avbeln aparvw          b~name1     INTO TABLE itab_customer     FROM vbpa AS a     INNER JOIN kn

  • FEATURE REQUEST: Lasso Tool to help organize code into separate VI's

    Sometimes VI's can end up growing out of hand, and it is not so easy to re-organize sections of a VI into a separate VI. It would be fantastic if there was a tool we could use to select a portion of our code inside of a VI (see Lasso tool in Photosho

  • Link Column in Hierarchy Flat file

    Hi Gurus,       Good Evening. Can anyone please let me know the significance of the Link column (in between Node name and Parent ID) while doing the flat file extraction for Hierarchy. Warm regards, Warnie.

  • My nokia 5300 keeps turning itself off

    Help my nokia 5300 keeps turning itself off. It won't let me read my messages. Everytime I press the key to read my messages it just goes off. I only had it about 6 months!!!