-
-
$database = "databaseName"; //Database name - $user = "root"; //Database user name
- $pwd = "pwd"; //Database Password
- $replace ='pre_';//Prefix after replacement
- $seach = 'pre1_';//Prefix to be replaced
- $db=mysql_connect("localhost","$user","$pwd") or die("Failed to connect to database:".mysql_error()); //Connect to 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");
- }
- // bbs.it-home.org
- ?>
-
Copy the code
If you add a prefix, you can make the following modifications:
$table = str_replace($seach,$replace,$name['0']);
change into:
$table = $replace.$name['0'];
|