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

MySQLMySQLi Database

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)
raja
Published on 20-Feb-2018 13:57:57
Advertisements