search
Homephp教程php手册使用php批量删除数据库下所有前缀为prefix_的表

这篇文章主要介绍了php如何批量删除数据库下所有前缀为prefix_的表,需要的朋友可以参考下

以下就是统一删除前缀为“prefix_”的表的脚本:

复制代码 代码如下:


//设置数据库连接信息。数据库服务器地址,数据库用户名,数据密码
mysql_connect('数据库主机','数据库用户名','数据库密码');
//设置查询的数据库名称
mysql_select_db('数据库名');
$rs=mysql_query('show tables');
while($arr=mysql_fetch_array($rs))
{
//设置要批量删除的数据库表前缀,如:prefix_
$TF=strpos($arr[0],'prefix_');
if($TF===0){
$FT=mysql_query("drop table $arr[0]");
if($FT){
echo "$arr[0] 删除成功!
";
}
}
}
?>


新建一个php文件,,保存为deletedata.php

比如,你要删除或者的后台数据,操作两个步骤就ok:

1. 首先将这个保存好的deletedata.php文件上传至你的网站根目录;

2. 直接在地址栏输入:或者执行这个删除脚本就OK了,该脚本会在浏览器中显示出所有表删除成功的信息。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools