user3745942
user3745942

Reputation: 193

Oracle SQL: How do I find the table name given the column names?

If I know the names of every column of a table but not the name of the table, how do I find the name of the table I need?

Upvotes: 10

Views: 63426

Answers (3)

souvik
souvik

Reputation: 1

select * from all_updatable_columns where column_name like 'reqd col name';

Upvotes: -4

Joshua Huber
Joshua Huber

Reputation: 3533

Based on @Roobie's solution, the code below searches in all schemas you have access to, in case the table is not in your own schema. Also added case-insensitive matching.

SELECT owner, table_name
  FROM all_tab_columns
  WHERE UPPER(column_name) = UPPER('MYCOL');

Upvotes: 15

Roobie
Roobie

Reputation: 1396

Try this (one known column):

CREATE TABLE mytab(mycol VARCHAR2(30 CHAR));

SELECT table_name FROM user_tab_columns WHERE column_name='MYCOL';

Note MYCOL is in upper case in column_name='MYCOL';

Cheers!

Upvotes: 10

Related Questions