Now I am using something like:
dbResult = dbStatement.executeQuery("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '[e2]' AND table_name = '[emp101_messages]'");
while(dbResult.next())
{
int value = -1;
value= dbResult.getInt(1);
System.out.println(value + " table count");
}
Is this correct way to check if a table exists in a database?
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'dbname'
AND table_name = 'my_tablename';
+----------------------+
| table_name |
+----------------------+
| my_tablename |
+----------------------+
As most of the options are already provided. Please see if this can help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With