Reputation: 25
I usually search column names in Oracle as we have 1000+ tables. Is there simpler way to search column names using regex.
For example Column name have CURRENCY or COUNTRY etc.
Upvotes: 2
Views: 1578
Reputation: 690
I would try something like this:
SELECT table_name, column_name from user_tab_columns
WHERE REGEXP_LIKE(column_name, 'country|currency', 'i' );
i : Perform case-insensitive matching.
Upvotes: 0
Reputation: 1997
I think it duplicate.
But can find it using below query.
SELECT column_name, table_name FROM user_tab_columns WHERE column_name like '%CURRENCY%' OR column_name Like '%COUNTRY%';
Upvotes: 1
Reputation: 1269883
If you really want to use a regular expression:
select c.*
from all_tab_cols
where regexp_like(column_name, 'CURRENCY|COUNTRY');
However, I would be more inclined to write:
select c.*
from all_tab_cols
where column_name like '%CURRENCY%' or
column_name like '%COUNTRY%';
Upvotes: 2
Reputation: 11607
I would use the answer of this SO question and dump all data to a text file.
At that point I'd use any good text editor with regex search to search the text file and have an immediate overview of what is what.
This works very well as long as tables and columns do not change too often.
Upvotes: 3