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.