Is it possible to search every field of every table for a particular value in Oracle.
I want to do it without using any procedure..
Can we do it with query?
You can do it with a single query though it's a bit convoluted. This query will search all CHAR and VARCHAR2 columns in the current schema for the string 'JONES'
select table_name,
column_name
from( select table_name,
column_name,
to_number(
extractvalue(
xmltype(
dbms_xmlgen.getxml(
'select count(*) c from ' || table_name ||
' where to_char(' || column_name || ') = ''JONES'''
)
),
'ROWSET/ROW/C'
)
) cnt
from (select utc.*, rownum
from user_tab_columns utc
where data_type in ('CHAR', 'VARCHAR2') ) )
where cnt >= 0
Note that this is an adapted version of the Laurent Schneider's query to count the rows in every table with a single query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With