Reputation: 506
I tried looking out on web about how we can list out the empty databases in MySQL but couldn't find any solution it. I know we can do it for the tables but is it possible to do it for the databases as well?
Upvotes: 1
Views: 1805
Reputation: 407
just use
show databases;
will show all databases even there is no table in that database.
Upvotes: 0
Reputation: 562358
Like databases that contain no tables?
mysql> show tables from test;
Empty set (0.01 sec)
mysql> SELECT S.SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA S
LEFT OUTER JOIN INFORMATION_SCHEMA.TABLES T ON S.SCHEMA_NAME = T.TABLE_SCHEMA
WHERE T.TABLE_SCHEMA IS NULL;
+-------------+
| SCHEMA_NAME |
+-------------+
| test |
+-------------+
Upvotes: 1