Possible Duplicate:
Search All Fields In All Tables For A Specific Value (Oracle)
Search for a given string in all fields of an entire schema for Oracle
I have this:
select * from
{select table_name
from user_tab_columns
where data_type = 'VARCHAR2')
but, of course, it's not working. I'm only using SQL Developer and not sure how to proceed.
I thought I was asking in the above query to select all from each table, but that is not correct. I saw some answers on SO, but they didn't help. I don't need just column_name
in user_tab_columns
, I need the values of the columns
I really just want to find where the name 'JONES,' is in the database. I don't know the table or the column, just that the value is there...somewhere.
Thanks.
When I ran the code from:
Search All Fields In All Tables For A Specific Value (Oracle)
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 'JONES%';
IF match_count > 0 THEN
dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count );
END IF;
END LOOP;
END;
/
I received:
Error report:
ORA-00920: invalid relational operator
ORA-06512: at line 8
00920. 00000 - "invalid relational operator"
*Cause:
*Action:
EDIT: for some reason oracle does not like the not equal <>
tried !=
as well.
EDIT: if I run just:
SELECT owner, table_name, column_name
FROM all_tab_columns
WHERE owner != 'SYS' and data_type LIKE '%CHAR%'
I get no error.
If I run without the owner != 'SYS'
, I get insufficient privilege (I own the db though)
remove owner != 'SYS'
runs, put it back with !=
or <>
, fails
EDIT: trying CONNECT BY
at the moment