开发者

How to distinguish if a database object (in Oracle) is a table or view

开发者 https://www.devze.com 2023-03-23 00:24 出处:网络
I want to distinguish between a view and table. Basically, I want to find all the tables which has a partic开发者_JAVA技巧ular column name.

I want to distinguish between a view and table. Basically, I want to find all the tables which has a partic开发者_JAVA技巧ular column name.

select table_name from user_tab_columns x where column_name='STUDENTID';

The above query also returns views which have the same column. I tried using the following, however, I feel it take long time to run and return...

select table_name from user_tables where table_name in (select x.table_name from user_tab_columns x where x.column_name='PLAN_NAME');

any suggestions please.


I guess a join will be quicker than a subselect. Try this:

select c.table_name 
from user_tab_columns c, user_tables t
where c.table_name = t.table_name
and c.column_name='STUDENTID';
0

精彩评论

暂无评论...
验证码 换一张
取 消