Quote:
I tried using this statement below to find the corresponding column based on what I think it should be called, but it did not get any results. *
SELECT * from dba_objects WHERE object_name like '%DTN%'
The column is not an object. If you mean that you expect the column name to be like "% DTN%", the query you want is the following:
SELECT owner, table_name, column_name FROM all_tab_columns WHERE column_name LIKE '%DTN%';
But if the string "DTN" is just a hunch on your part, it probably won't help.
By the way, how confident are you that "1/22 / 2008P09RR8" is a value directly selected from a single column? If you donβt know where it comes from at all, it can be a concatenation of several columns or the result of some function or a value located in a nested table object. Thus, you may end up on a wild goose hunt, trying to check each column for this value. Could you start with which client application displays this value and try to figure out which request it uses to receive it?
In any case, diciu's answer provides one method for generating SQL queries to check each column of each table for a value. You can also do similar things completely in one SQL session using PL / SQL block and dynamic SQL. Here is some hastily written code for this:
SET SERVEROUTPUT ON SIZE 100000 DECLARE match_count INTEGER; BEGIN FOR t IN (SELECT owner, table_name, column_name FROM all_tab_columns WHERE owner <> 'SYS' and data_type LIKE '%CHAR%') LOOP EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || t.owner || '.' || t.table_name || ' WHERE '||t.column_name||' = :1' INTO match_count USING '1/22/2008P09RR8'; IF match_count > 0 THEN dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count ); END IF; END LOOP; END; /
There are several ways to make it more effective.
In this case, given the value you are looking for, you can clearly exclude any column of type NUMBER or DATE, which will reduce the number of queries. Perhaps even limit it to columns where the type is like "% CHAR%".
Instead of a single query per column, you can build one query for a table as follows:
SELECT * FROM table1 WHERE column1 = 'value' OR column2 = 'value' OR column3 = 'value' ... ;