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

使用php批量删除数据库下所有前缀为prefix_的表

Jun 06, 2016 pm 08:22 PM

这篇文章主要介绍了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 of this Website
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)