MySQL show tables - How do I list the tables in a MySQL database?

MySQL "show tables" FAQ: How do I show/list the tables in a MySQL database?

To list the tables in a MySQL database:

  1. Log into your database using the MySQL client,
  2. Issue the use command to connect to your desired database, and then
  3. Use the MySQL show tables command, like this:
show tables;

MySQL show tables - A complete example

Here's a slightly longer explanation. First, connect to your MySQL database using your MySQL client from your operating system command line:

$ mysql -u root -p

Next, after you're logged into your MySQL database, tell MySQL which database you want to use:

mysql> use mydatabase;

And now issue the MySQL show tables command to list the tables in the current database:

mysql> show tables;

For instance, if I issue this MySQL show tables command in one of my example MySQL databases, I'll see this output:

mysql> show tables;
+-----------------------+
| Tables_in_pizza_store |
+-----------------------+
| crust_sizes           | 
| crust_types           | 
| customers             | 
| orders                | 
| pizza_toppings        | 
| pizzas                | 
| toppings              | 
+-----------------------+
7 rows in set (0.00 sec)

That's how you show the tables in the MySQL database using the MySQL client.

Post new comment

The content of this field is kept private and will not be shown publicly.