Find databases containing a particular table in MySQL

The query below finds all databases (schemas) in MySQL Server instance containing a particular table.

Query

select table_schema as database_name
from information_schema.tables 
where table_type = 'BASE TABLE'
    and table_name = 'your table name'
order by table_schema;

Columns

  • database_name - name of the database (schema)

Rows

  • One row: represents one database (schema)
  • Scope of rows: all databases (schemas) containing the provided table name
  • Ordered by: database (schema) name

Sample results

The screen below shows all databases (schemas) that contain the country table.

0
There are no comments. Click here to write the first comment.