Show Tables in MySQL

Introduction

After creating tables in a database, you may want to view all available tables.

MySQL provides a simple command called SHOW TABLES to display all tables present in the currently selected database.

This helps you easily check which tables exist before performing operations on them.


What is SHOW TABLES

The SHOW TABLES statement is used to display a list of all tables in the selected database.

Important:
You must select a database first using the USE statement before running this command.


Basic Syntax

SHOW TABLES; 

Example

USE school_db; SHOW TABLES; 

Output may look like:

  • Students

  • Teachers

  • Courses


Why SHOW TABLES is Important

This command is useful when:

  • You want to check available tables

  • You forgot the table name

  • You want to verify table creation

  • You are working with multiple tables


Show Tables with Pattern (Optional)

You can filter tables using LIKE.

Example:

SHOW TABLES LIKE 'S%'; 

This will display tables starting with S.


Example Scenario

Suppose you created tables:

CREATE TABLE Students (...); CREATE TABLE Courses (...); 

You can verify them using:

SHOW TABLES; 

Common Mistakes

  • Running SHOW TABLES without selecting a database

  • Typing incorrect table names

  • Expecting tables from all databases (it shows only the current database)


Key Points to Remember

  • SHOW TABLES displays tables in the current database

  • Always use USE database_name before it

  • Helps verify table creation

  • Can be filtered using LIKE