The following method makes it easy to solve the problem. The Code is as follows.
Copy codeThe Code is as follows:
<? Php
$ Database = "databaseName"; // database Name
$ User = "root"; // database username
$ Pwd = "pwd"; // Database Password
$ Replace = 'pre _ '; // The prefix after replacement
$ Seach = 'pre1 _ '; // The prefix to be replaced
$ Db = mysql_connect ("localhost", "$ user", "$ pwd") or die ("Database Connection Failed:". mysql_error (); // connect to the database
$ Tables = mysql_list_tables ("$ database ");
While ($ name = mysql_fetch_array ($ tables )){
$ Table = str_replace ($ seach, $ replace, $ name ['0']);
Mysql_query ("rename table $ name [0] to $ table ");
}
?>
If you want to add a prefix, you only need to change it a little bit.
Copy codeThe Code is as follows:
$ Table = str_replace ($ seach, $ replace, $ name ['0 ']);
$ Table = $ replace. $ name ['0'];
You can.