Wednesday, November 9, 2011

Obtaining a list of tables for a specific column in Oracle DB.

If you are a CNC you definitely know that there may be multiple ways to do the same thing because that’s imperative for success. Now if I have a column name and I need to know all the tables in the database which have the particular column, I can easily do a XREF in fastpath and search for all the tables that use a specific data item. But in case you haven’t build the cross reference and there is a need to find it out , here’s what can be done in the old school way:

DBA_TAB_COLUMNS is a view that will help us obtain a list of tables for a specific column in Oracle database
.
example:

SELECT owner, table_name, column_name
FROM DBA_TAB_COLUMNS
WHERE column_name like ‘%ADDJ’
ORDER BY owner, table_name

The ID used to login to the db must have dba privilege for the query to work….. after all  what’s life without any limitations

No comments:

Post a Comment