可以指定table_pre表前缀:
$table_pre = 'cdb_';
mysql_connect('localhost','user','pwd');
mysql_select_db('databasename');
$rs=mysql_query("show tables like '".$table_pre."%'");
while($data=mysql_fetch_array($rs)){
$tmp_flag=strpos($data[0],$table_pre);
if($tmp_flag===0){
mysql_query("drop table $data[0]");
}
}
?>
或者:
mysql_connect('localhost','user','pwd');
mysql_select_db('databasename');
$rs=mysql_query('show tables');
while($data=mysql_fetch_array($rs)){
$tmp_flag=strpos($data[0],'cdb_');
if($tmp_flag===0){
mysql_query("drop table $data[0]");
}
}
?>