PHP中判断表是否存在的方法:

if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '". $table."'")==1) {
    echo "Table exists";
} else {
    echo "Table does not exist";
}

MySQL中判断表是否存在的方法:

1.  使用show tables命令

1. SHOW TABLES LIKE   '%table_name%';  

2. 使用select命令

select `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` where `TABLE_SCHEMA`='dbname' and `TABLE_NAME`='tablename' ;

3. 如果表不存在就建立这个表,那么可以直接用 

create table if not exists tablename

这样的指令来建立,不需要先去查询表是否存在。

4. 判断是否已经存在

create table if not exists like old_table_name;