Last week, one of my coworkers was trying to figure out which tables in a database contained a particular column name. That’s something I’ve had to do in the past, and although I didn’t remember the exact details, a quick search turned up this gem from a Stack Overflow thread:
SELECT column_name, table_name FROM information_schema.columns WHERE column_name like '%{column name}%'
This query returns a list of all tables and views in the database that have column names containing the name for which you are searching.
If you know the exact name of the column, you can change the where
clause to WHERE column_name = '{column name}'
.