Which MySQL query can be used with the help of which we can see the list of MySQL databases?


With the help of following MySQL query, we can see the list of MySQL database −

mysql> SELECT schema_name FROM information_schema.schemata;
+--------------------+
| schema_name        |
+--------------------+
| information_schema |
| gaurav             |
| mysql              |
| performance_schema |
| query              |
| query1             |
| sys                |
| tutorials          |
+--------------------+
8 rows in set (0.00 sec)

We can also use WHERE clause with this query as follows −

mysql> SELECT schema_name FROM information_schema.schemata WHERE schema_name LIKE '%schema' OR schema_name LIKE '%s';
+--------------------+
| schema_name        |
+--------------------+
| information_schema |
| performance_schema |
| sys                |
| tutorials          |
+--------------------+
4 rows in set (0.00 sec)

Updated on: 20-Jun-2020

52 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements