kauffee000 kauffee000 -3 years ago 106
MySQL Question

Is it possible to query table names in a database?

I just started working on a large project with hundreds of tables. I want to see all of the tables relating to DNS. I can't remember all of the table names that I'm working with, but I know they have "dns" in the name.

Is it possible to query the list of tables in a database and return just the names? It would be like

show tables;
, but filtering by table name.

An equivalent of
SHOW TABLES FROM <database> WHERE table_name LIKE '%dns%';

Version Info: MySQL Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using EditLine wrapper

Answer Source

You can use the information_schema database;

SELECT * FROM information_schema.tables WHERE table_schema = <database> AND table_name LIKE '%dns%'

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download