Php batch deletes tables with the specified prefix in the database. prefix _ is used as an example.

Source: Internet
Author: User
This article describes how to use php to batch delete all tables prefixed with prefix _ in the database. This function is more practical, for more information, see how to use php to batch delete all tables prefixed with prefix _ in the database.

For example, delete all tables with the prefix "prefix.

<? Php // Set the database connection information. Database server address, database username, data password mysql_connect ('database host', 'database username ', 'database password '); // Set the queried database name mysql_select_db ('database name'); $ rs = mysql_query ('Show tables '); while ($ arr = mysql_fetch_array ($ rs )) {// Set the database table prefix to be deleted in batches, for example, prefix _ $ TF = strpos ($ arr [0], 'prefix _'); if ($ TF = 0) {$ FT = mysql_query ("drop table $ arr [0]"); if ($ FT) {echo "$ arr [0] deleted successfully!
";}}?>

Operation instance:

Create a new php file and save it as deletedata. php.
For example, if you want to delete the back-end data of www.jb51.net or http://www.jb51.net/, you can perform the following two steps:

1. Upload the saved deletedata. php file to the root directory of your website;

2. enter www.jb51.net/deletedata.php?http://www.jb51.net/deletedata.phpto delete the script.
The script displays information about the successful deletion of all tables in the browser.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.