1. 通过information_schema
判断一个表是否存在
SELECT table_name FROM information_schema.TABLES WHERE table_name ='yourname';
指定数据库指定表是否存在
SELECT table_name FROM information_schema.TABLES WHERE table_schema='dbname' and table_name ='yourname';
2. show tables
SHOW TABLES LIKE 'table_mode'
3. 在建表时不确定表是否存在
--格式 CREATE TABLE IF NOT EXISTS [Table Definition]; --示例 CREATE TABLE IF NOT EXISTS student(id int unsigned not null primary key,name varchar(32) not null)