Search Tables with Known Column Name

Have you ended up in a situation wherein, you know the Column Name but you have no clue about the Table Name ? I recently came across the situation and following is one query which help me out of the situation.The Query is for Firebird Database.


select f.rdb$relation_name, f.rdb$field_name
from rdb$relation_fields f
join rdb$relations r on f.rdb$relation_name = r.rdb$relation_name
and r.rdb$view_blr is null
and (r.rdb$system_flag is null or r.rdb$system_flag = 0)
where f.rdb$field_name like '%ColName%'
order by 1, f.rdb$field_position;

Advertisements