Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find table name/s if a column name is known

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can any one help me write a PL/SQL statement that does the following in Oracle 8/8i:

Given a column name, output all the table names that contain that column and also the data type of the column in those tables.

Thanks in advance.
 
select table_name,column_name,data_type from dba_tab_columns
where column_name='MY_COLUMN'
 
I've tried this example, but I can't get any results! Am I missing something? The answer I get is "table or view does not exist". It's pointing to "dba_tab_columns". :-(

Can anyone please help me?
 
The id you are using to execute the query may not have access to "dba_tab_columns". You can try "all_tab_columns" instead, but you may miss some tables. "All_tab_columns" is restricted to tables which your id has privileges to view.
 
Select table_name from all_tab_columns where
column_name= '<columnname>'
 
Beware type the column name with capslock ON
eg With Caps Letters
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top