Open In App

SQL – Show Databases

Last Updated : 09 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

In the dynamic scene of database management, it is important to have a good insight into the available databases for effective administration and development tasks. SHOW DATABASES command is designed to present all databases located on the server.

This article explains the purpose of the SHOW DATABASES command syntax of this command and its practical importance in SQL database management with examples.

The purpose of exploring the SQL SHOW DATABASES command is to give database administrators and developers a basic tool that helps them manage and navigate their database environment more efficiently. The significance of this topic lies in the real world of everyday database management, it is necessary to understand how to use it.

Exploring SQL’s SHOW DATABASES Command

We shall expound on how `SHOW DATABASES` works in SQL in this article. Initially, we will elaborate on the significance and usefulness of this command in database management systems. Thereafter, we will guide users on how to effectively deploy `SHOW DATABASES` covering such different SQL implementations as MySQL, PostgreSQL, and SQLite.

Additionally, we’ll explore the various potential uses and situations where the value of the `SHOW DATABASES` command cannot be emphasized enough such as administration work, troubleshooting or simply gaining knowledge about your database environment.

Thus by the end of this article, readers can have a comprehensive understanding of how they can use `SHOW DATABASES` to obtain important information about their databases henceforth enabling them to navigate within their database systems more effectively than before.

SQL Show Databases

SHOW DATABASES command is one of the most fundamental ones in SQL to give a list of all the databases within the current DBMS that have been created. Not only does it make it convenient for the end user to catch up with what’s available, but also eliminates the need to query system tables directly.

Syntax:

SQL specification of the `SHOW DATABASES` command is not complex and is simple enough to be used on different SQL universally. Here’s the basic syntax:

SHOW DATABASES;

This is an easy-to-understand instruction of a database management system that fetches the list of all databases to which the current user has access and exhibits them.

Examples of SQL Show Databases

Example 1: Listing Databases with SHOW DATABASES Command

SHOW DATABASES;

Explanation: This command returns the list of all the databases available on a server or a host and its output is in tabular format. Thus, this command has been used for displaying the following information about each existing database: Database (name).

Output:

Database

information_schema

mydatabase1

mydatabase2

testdb

In this example, the output displays four databases: information_schema, mydatabase1, mydatabase2, and testdb.

Example 2: Filtering Databases with SHOW DATABASES Using LIKE Command

SHOW DATABASES LIKE ' my % ' ;  

Explanation: This statement filters out some items from a list based on certain criteria using the `LIKE` command. It only retrieves those with names containing ‘my’ as their starting characters.

Output:

Database

mydatabase1

mydatabase2

In this example, the output only includes databases whose names start with ‘my‘, which are mydatabase1 and mydatabase2.

Example 3: Filtering Databases with SHOW DATABASES Using NOT LIKE Command

SHOW DATABASES WHERE `Database` NOT LIKE 'test%'  ;

Explanation: This command gets rid of some items from a table using conditions specified by users. It brings back only those that do not have ‘test’ as part of their starting letters using the WHERE clause.

Output:

Database

information_schema

mydatabase1

mydatabase2

In this example, the output excludes the database testdb, which starts with ‘test‘, and includes all other databases available in the system.

Conclusion

SQL, `SHOW DATABASES` command is among them that plays a vital role in getting information about the databases within the RBDMS. The simplified syntax and identical SQL structure fabric embedded in different implementations enable users to quickly obtain such a list of available databases for most operations like database administration, problem-solving, and data insight.

With the mastery of the `SHOW DATABASES` command and its extra features, i.e. filtering with patterns and conditions, users can effortlessly manipulate and organize their database space in no time. Welding this fact to the database management process improves efficiency, and data-driven decisions can be made. This also guarantees smooth and productive database management processes.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads