MySql find all tables with specific column/field name

How to look up in the entire DB and list out all tables which have specific column name or field name?

Example belows looks for field `currency` from all database:

SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name LIKE 'currency'
LIMIT 0 , 30

To add specific database to the query, use:

SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name LIKE 'currency' AND TABLE_SCHEMA='database name';

By Keenlio, December 8, 2014

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


4 + eight =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>