find column names and table names referenced in SQL

前端 未结 3 1111
春和景丽
春和景丽 2021-01-07 03:32

How to find all the tables and column names used in a SQL? It is on ORACLE database. Below is an SQL example.

SELECT 
   A.ENAME,
   A.AGE as EMP_AGE,
   B         


        
3条回答
  •  孤街浪徒
    2021-01-07 03:50

    If you can convert your query into VIEW and then use INFORMATION_SCHEMA.VIEW_COLUMN_USAGE

    Here is an example:

    let's say your view name is ABC

    then use this one

    SELECT VIEW_NAME, TABLE_NAME, COLUMN_NAME  
    FROM    INFORMATION_SCHEMA.VIEW_COLUMN_USAGE 
    WHERE   VIEW_NAME = 'ABC'
    

    Let me know if it works..

提交回复
热议问题