Thursday, June 19, 2008

Grep For a Column

Sometimes when using MySQL, you need to know every table that contains a given column name. In the past I've accomplished this with a short script, but I've come to find out that you can simply use a SQL statement instead.

SELECT table_name FROM information_schema.COLUMNS WHERE table_schema='my_db' AND column_name='MyColumn';


Anonymous said...

For those desperately trying to find the Ingres version of this select:
SELECT table_name
FROM iicolumns
WHERE column_name = 'MyColumn';

Anonymous said...

Thanks for the credit, Travis. :p