Skip to content
Advertisement

How do I list all tables in a schema having specific column in oracle sql?

I have found the list of all tables using this query –

SELECT DISTINCT OBJECT_NAME 
  FROM USER_OBJECTS
 WHERE OBJECT_TYPE = 'TABLE' 

But I need to list all the tables having column name starttime_date or starttime.

Advertisement

Answer

You could use USER_TAB_COLS view.

For example,

SQL> select table_name, column_name, data_type from user_tab_cols where column_name ='DEPTNO';

TABLE_NAME COLUMN_NAM DATA_TYPE
---------- ---------- ----------
DEPT       DEPTNO     NUMBER
EMP        DEPTNO     NUMBER

SQL>

You could try,

select * 
   from user_tab_cols
 where column_name in ('STARTTIME_DATE', 'STARTTIME');
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement