In the dynamic scene of database management, having 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.
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.
This article explores the purpose, syntax, and practical applications of the SHOW DATABASES command, along with examples to demonstrate its use in various SQL implementations like MySQL, PostgreSQL, and SQLite.
Understanding the SHOW DATABASES Command
The SHOW DATABASES command is a universal SQL query that retrieves and lists all databases in the current DBMS accessible to the user. This eliminates the need to directly query system tables and simplifies database management tasks. SQL specification of the `SHOW DATABASES` command is not complex and is simple enough to be used on different SQL universally. 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. Here's the basic syntax:
Syntax
SHOW DATABASES;
Examples of SQL Show Databases
The Examples of SQL Show Databases demonstrate how to use the SHOW DATABASES
command in various scenarios. These examples include listing all databases, filtering results with LIKE
, and excluding specific databases using NOT LIKE
Example 1: Listing All Databases
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)
Query:
SHOW DATABASES;
Output
Database |
---|
information_schema |
mydatabase1 |
mydatabase2 |
testdb |
Example 2: Filtering Databases Using LIKE Command
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.
Query:
SHOW DATABASES LIKE ' my % ' ;
Output
Database |
---|
mydatabase1 |
mydatabase2 |
Example 3: Filtering Databases with SHOW DATABASES Using NOT LIKE Command
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.
Query:
SHOW DATABASES WHERE `Database` NOT LIKE 'test%' ;
Output
Database |
---|
information_schema |
mydatabase1 |
mydatabase2 |
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. By mastering this command and its advanced features, such as filtering with patterns and conditions, users can efficiently organize and navigate their database environments.
Similar Reads
SQL DROP DATABASE The SQL DROP DATABASE statement is an important command used to permanently delete a database from the Database Management System (DBMS). When executed, this command removes the database and all its associated objects, including tables, views, stored procedures, and other entities.In this article, w
4 min read
SQL Select Database The USE DATABASE statement is a command in certain SQL-based database management systems that allows users to select and set a specific database as the default for the current session. By selecting a database, subsequent queries are executed within the context of that database, making it easier to i
4 min read
MySQL Drop Database In Database Management Systems managing databases involves not only creating and modifying the data but also removing the databases when they are no longer needed and freeing the space occupied by them. MySQL offers a feature called DROP DATABASE, allowing users to delete databases. In this article,
3 min read
SQL Server Show/List Databases Listing all databases in SQL Server is a common task for database administrators and developers. SQL Server provides two main methods to solve this such as using SQL commands and using SQL Server Management Studio (SSMS). In this article, we will learn about how to Show/List the SQL Server Databases
4 min read
Types of Databases Databases are essential for storing and managing data in todayâs digital world. They serve as the backbone of various applications, from simple personal projects to complex enterprise systems. Understanding the different types of databases is crucial for choosing the right one based on specific requ
11 min read