Doug Molineux
Doug Molineux

Reputation: 12431

Find out what tables are in a MySQL Db

Is there a query that will return all the names of the tables inside a mySQL database?

Thanks!

Upvotes: 0

Views: 70

Answers (3)

Mchl
Mchl

Reputation: 62359

If you're looking for something more versatile than SHOW TABLES; use

SELECT 
  TABLE_NAME 
  /*add some more columns if you need them*/ 
  /* add some aggregating functions!*/
FROM 
  information_schema.TABLES 
/* join some more tables! it's fun! */
WHERE 
  TABLE_SCHEMA = 'yourDatabaseName'
  /*add your own conditions!*/
  /* order, group, limit! */

Upvotes: 1

DVK
DVK

Reputation: 129363

If you don't want to use show tables;, you can access the information via an actual query against TABLES table which holds the info:

SELECT table_name FROM INFORMATION_SCHEMA.TABLES
  WHERE table_schema = 'db_name'

Upvotes: 1

Erik
Erik

Reputation: 20712

show tables;

Does what it says on the tin.

Upvotes: 4

Related Questions