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.
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.
SHOW TABLES;
When the SHOW TABLES command is executed:
If no database has been selected using the USE command, the system may produce an error.
First select a database:
USE student_db;
Then execute the command:
SHOW TABLES;
| Tables_in_student_db |
|---|
| students |
| courses |
| teachers |
| results |
This output shows that the student_db database contains four tables: students, courses, teachers, and results.
SHOW TABLES with Pattern MatchingMySQL allows filtering table names using the LIKE clause.
SHOW TABLES LIKE 'pattern';
SHOW TABLES LIKE 'stu%';
This command displays tables whose names start with stu.
Example Output:
| Tables_in_student_db |
|---|
| students |
| student_records |
USE command before running SHOW TABLES.DESCRIBE command can be used.SHOW TABLES is used to list all tables in the current database.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.