方法一、
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.
个人觉得方法三很不错
相关文章: