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.

SQL – Show Databases

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.

Similar Reads

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....

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....

Examples of SQL Show Databases

Example 1: Listing Databases with SHOW DATABASES Command...

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....