在 Oracle 数据库中搜索具有特定列名称的表?
在 Oracle 数据库中搜索具有特定列名称的表?
我们有一个庞大的Oracle数据库,有很多数据表。是否有一种查询或搜索的方式可以找出是否有任何带有特定列名的表格?
即展示所有包含以下列的数据表: id、fname、lname、address
我忘了提供详细信息:我需要能够搜索不同的模式(schema)。我必须使用的模式不拥有我需要搜索的表格。
admin 更改状态以发布 2023年5月19日
查找具有特定列的所有表:
select owner, table_name from all_tab_columns where column_name = 'ID';
查找具有任意或所有4个列的表:
select owner, table_name, column_name from all_tab_columns where column_name in ('ID', 'FNAME', 'LNAME', 'ADDRESS');
查找具有所有4个列(没有丢失任何列)的表:
select owner, table_name from all_tab_columns where column_name in ('ID', 'FNAME', 'LNAME', 'ADDRESS') group by owner, table_name having count(*) = 4;