Friday, September 24, 2010

How to locate all instances of a field in all your tables

Hey all,

Lets say you create a field called IDNUM and you use that same field in 8 different tables. Now down the road you forget what tables that field is in and you need to know this in order to link it properly. Enter this command and you will see all the tables you have that include the IDNUM field

EXAMPLE

SQL> select column_name,table_name FROM all_tab_cols WHERE column_name
> = 'IDNUM'
> 2 /
>
> COLUMN_NAME TABLE_NAME
> ------------------------------ ------------------------------
> IDNUM DELIVERY
> IDNUM CUSTOMER


Hope it helps!