|
|
Check if a MySQL table exists - Mysql
|
Views : 623
|
|
Tagged in : Mysql
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
Using show tables
The easiest way is using the "show tables" function. If your database (called "test" in this example) had three tables name "test1", "test2" and "another_test", running "show tables" would display this:
Tables_in_test
another_test
test1
test2
3 rows in set (0.01 sec)
You can use show tables like this to see if a single table exists:
mysql> show tables like "test1";
which would return:
Tables_in_test (test1)
test1
1 row in set (0.00 sec)
If you ran show tables on a table that didn't exist you would get this:
mysql> show tables like "test3";
Empty set (0.01 sec)
|
|
By Rekha, On - 2010-01-28 |
|
|
|