Notes

`SHOW DATABASES;` Query in DBMS (MySQL) [ English ]

< Prev Next >

Introduction

In a Database Management System (DBMS), a database server may contain multiple databases. Each database stores related tables, views, procedures, and other objects. Before working with any database, it is often necessary to see which databases exist on the server.

The SHOW DATABASES; query is a Data Definition Language (DDL) utility command used in MySQL and similar DBMS systems to display a list of all databases available on the server.

This command helps database administrators and users quickly identify the databases they can access.

Definition

The SHOW DATABASES; query is used to display the list of all databases present in the database server.

It retrieves database names from the system catalog and shows them in tabular form.

Syntax

SHOW DATABASES;

How It Works

When this query is executed:

  1. The DBMS checks the system catalog (metadata).
  2. It retrieves the names of all databases stored on the server.
  3. The server returns the result in a list format.

The user will only see databases for which they have permission.

Example

SHOW DATABASES;

Output Example

Database
information_schema
mysql
performance_schema
sys
student_db
library_db

In this example:

Practical Use

The SHOW DATABASES; command is commonly used in the following situations:

  1. Checking available databases

    • Before selecting a database to work with.
  2. Database administration

    • DBAs use it to verify that databases are created correctly.
  3. System exploration

    • Helps beginners understand what databases exist on a server.

Using SHOW DATABASES with Conditions

In MySQL, you can filter databases using the LIKE clause.

Syntax

SHOW DATABASES LIKE 'pattern';

Example

SHOW DATABASES LIKE 'student%';

This command will display only databases whose names start with student.

Example Output:

Database
student_db
student_records

Key Points

Summary

The SHOW DATABASES; query is a simple yet essential command in DBMS. It allows users and administrators to view all available databases on the server. By using this command, users can quickly identify the database they need before selecting it with the USE database_name; statement.

< Prev Next >