Show Databases - (MySQL Database)
In MySQL, the "SHOW DATABASES" statement is used to display the list of all databases available on the server. In this tutorial, we will learn how to use the "SHOW DATABASES" statement in MySQL.
Syntax
The syntax to display all databases in MySQL is as follows:
SHOW DATABASES;
This statement will display a list of all databases available on the server.
Example
Let's consider a scenario where we want to see the list of all available databases on our MySQL server. Here's an example using the "SHOW DATABASES" statement:
SHOW DATABASES;
The output of the above statement will be a list of all available databases on the MySQL server, something like this:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test_db |
+--------------------+
4 rows in set (0.00 sec)
Explanation
In the above example, we used the "SHOW DATABASES" statement to display a list of all databases on the MySQL server. The output displays all the databases along with the number of rows in each database that are present in the server.
Use
The "SHOW DATABASES" statement is useful when you want to get a list of all databases available on the MySQL server.
Important Points
- The "SHOW DATABASES" statement displays a list of all databases available on the MySQL server.
- MySQL system databases like "information_schema", "mysql", and "performance_schema" may be displayed in the list along with user-defined databases.
- Only users with the "SHOW DATABASES" privilege can view the list of all databases.
Summary
The "SHOW DATABASES" statement in MySQL is used to display a list of all databases available on the server. It is useful when you want to see all available databases or check if a particular database you are looking for exists on the server.