Possible Duplicate:
Oracle Search all tables all columns for string
I'm looking for a simple way to search in Oracle for a ID/Text in all tables. Any ideas?
I'm using currently SQL Developer. Thank you!
You can use the USER_TABLES
and USER_TAB_COLUMNS
system tables to read what tables and columns you have.
Using that information, you can write a procedure or anonymous code block to dynamically build a query for searching those tables. Then execute it using EXECUTE IMMEDIATE
.
But beware that this will probably not perform too well in large databases. Also, you might want to check the data type of the column to decide wether to include it in your search or not.
You can execute this in sql-developer. (you might need to change %ID% to meet your naming convention)
SELECT
TABLE_NAME
, COLUMN_NAME
FROM
USER_TAB_COLUMNS
WHERE
column_name like '%ID%'
精彩评论