MYSQL判断某个表是否已经存在

方法一、
You don't need to count anything. SELECT 1 FROM testtable LIMIT 1; If there's no error, table exists.
方法二、
Or, if you want to be correct, use INFORMATION_SCHEMA. SELECT * FROM information_schema.tables WHERE table_schema = 'yourdb' AND table_name = 'testtable' LIMIT 1;

方法三、 Alternatively, you can
use SHOW TABLES SHOW TABLES LIKE 'yourtable'; If there is a row in the resultset, table exists.

个人觉得方法三很不错

FROM: http://stackoverflow.com/questions/8829102/mysql-check-if-table-exists-without-using-select-from#8829109

posted @ 2013-11-07 11:49  清新每一天  阅读(1291)  评论(0编辑  收藏  举报