我想找到我的数据库中有两个列的所有表LOCATION和ASSET_ID
所以我尝试了这个:
select owner, table_name, column_name
from all_tab_columns
where column_name in ('LOCATION','ASSET_ID');
Run Code Online (Sandbox Code Playgroud)
问题是这个查询给出了所有具有LOCATION或ASSET_ID不具有这两个表的表.
所以我改成了这个:
select owner, table_name, column_name
from all_tab_columns
where 1=1
and column_name ='LOCATION'
and column_name = 'ASSET_ID';
Run Code Online (Sandbox Code Playgroud)
它显示0结果.
请帮忙.
在初始尝试中选择所有行.然后按owner和table_name,只保留那些有两行初始查询返回.使用该having条款:
select owner, table_name
from all_tab_columns
where column_name in ('LOCATION','ASSET_ID')
group by owner, table_name
having count(*) = 2
;
Run Code Online (Sandbox Code Playgroud)