Mike Chamberlain Mike Chamberlain - 1 year ago 54
SQL Question

Get table names using SELECT statement in MySQL

In MySQL, I know I can list the tables in a database with:


However, I want to insert these table names into another table, for instance:

INSERT INTO metadata(table_name) SHOW TABLES /* does not work */

Is there a way to get the table names using a standard SELECT statement, something like:

INSERT INTO metadata(table_name) SELECT name FROM table_names /* what should table_names be? */

Answer Source


select * from information_schema.tables

See: http://dev.mysql.com/doc/refman/5.0/en/information-schema.html

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