简体   繁体   中英

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

如果我知道表的每一列的名称而不知道表的名称,我如何找到我需要的表的名称?

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');

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM