I need to check if a database is totally empty (no tables) using an SQL query. How can this be done?
Thanks for the help!
Solution: In order to verify your databases is not empty you can watch list of tables and measure instances in it.
first: perform simple connection to your db mysql -u
,run show databases;
pick your database using use
and then run show tables;
and expect to have list of tables.
+----------------------------------------+
| Tables_in_databaseName |
+----------------------------------------+
| databaseA |
| databaseB |
| databaseC |
+----------------------------------------+
Second: Perform simple count action on primary key / main table on sql and count instances:
select count(*) from ;
count result should be > 0
+----------+
| count(*) |
+----------+
| 100 |
+----------+