Notes

`SHOW TABLES` Query in DBMS (MySQL) [ English ]

< Prev Next >

Introduction

In a Database Management System (DBMS), a database can contain many tables used to store data in rows and columns. When working with a database, it is often necessary to view all the tables that exist within it.

The SHOW TABLES command is used to display the list of tables present in the currently selected database. This command helps users understand the structure of the database and identify the tables available for performing operations such as inserting, updating, or retrieving data.

Definition

The SHOW TABLES query is used to display all tables stored in the currently selected database.

It retrieves the names of tables from the database metadata and displays them in a list format.

Syntax

SHOW TABLES;

How It Works

When the SHOW TABLES command is executed:

  1. The DBMS checks the currently selected database.
  2. It retrieves the list of tables from the database system catalog.
  3. The names of all tables in that database are displayed.

If no database has been selected using the USE command, the system may produce an error.

Example

First select a database:

USE student_db;

Then execute the command:

SHOW TABLES;

Example Output

Tables_in_student_db
students
courses
teachers
results

This output shows that the student_db database contains four tables: students, courses, teachers, and results.

Using SHOW TABLES with Pattern Matching

MySQL allows filtering table names using the LIKE clause.

Syntax

SHOW TABLES LIKE 'pattern';

Example

SHOW TABLES LIKE 'stu%';

This command displays tables whose names start with stu.

Example Output:

Tables_in_student_db
students
student_records

Important Notes

Key Points

Summary

The SHOW TABLES command is used to display all the tables present in the currently selected database. It helps users explore the database structure and identify the tables available for performing SQL operations such as data insertion, retrieval, and modification.

< Prev Next >