Oracle查找具有特定列的所有表

kh.*_*tab 3 sql oracle

我想找到我的数据库中有两个列的所有表LOCATIONASSET_ID

所以我尝试了这个:

select owner, table_name, column_name
from all_tab_columns
where column_name in ('LOCATION','ASSET_ID');
Run Code Online (Sandbox Code Playgroud)

问题是这个查询给出了所有具有LOCATIONASSET_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结果.

请帮忙.

mat*_*guy 7

在初始尝试中选择所有行.然后按ownertable_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)