Join my Laravel for REST API's course on Udemy 👀

MySQL: Show the tables in your database

June 12, 2022  ‐ 1 min read

Inspecting the structure of your database is probably something that is more convenient with a GUI application. However, sometimes you need to do without. In that case you can jump into the MySQL shell to list the tables of your database. I'm a happy user of the MyCLI shell MySelf.

To list the tables of the tables in your MySQL database you can run the following snippet of SQL.

mysql> SHOW TABLES FROM [database_name];

The above requires you to specify the database name. However, if you already changed the database to the preferred one this last part is optional. You change or select a database by running USE <db> first. Afterwards just a SHOW TABLES is enough.

mysql> USE [database_name];
mysql> SHOW TABLES;

Running this against an actual MySQL database should give an output similar to the following.

mysql> SHOW TABLES FROM blog_dev;
+--------------------+
| Tables_in_blog_dev |
+--------------------+
| comments           |
| posts              |
| topics             |
| users              |
+--------------------+
4 rows in set (0,00 sec)