Modify Table Name
ALTER table name RENAME to new table name;
A single SQL statement can only modify one table
Show tables;
1.
SELECT CONCAT ( ', table_name, ' RENAME to Db_ ' , 4 ), '; ' ) from information_schema. Tableswhere 'ct%';
Bulk copy to notepad++, keep only SQL statements, and then copy to MySQL to execute
2.PHP script to bulk modify MySQL database table prefix
<?PHP//set up relevant information.$dbserver ='localhost';//the server you are connecting to is typically localhost$dbname ='Corethink';//Database name$dbuser ='Root';//Database user name$dbpassword ='Root';//Database Password$old _prefix='ct_';//the prefix of the database$new _prefix='New_';//the database prefix is modified toif(!is_string ($dbname) | |!is_string ($old _prefix) | |is_string ($new _prefix)) { return false;} if(!mysql_connect ($dbserver, $dbuser, $dbpassword)) {Print'Could not connect to MySQL'; Exit;}//get all the table names in the database$result =mysql_list_tables ($dbname);if(!$result) {Print"DB Error, could not list TABLESN"; Print'MySQL Error:'. Mysql_error (); Exit;}//Save the table name in $data while($row =mysql_fetch_row ($result)) {$data []= $row [0];}//Filter the name of the table to modify the prefixforeach($data as$k =$v) {$preg= Preg_match ("/^ ($old _prefix{1}) ([a-za-z0-9_-]+)/ I", $v, $v 1); if($preg) {$tab _name[$k]= $v 1[2]; }}if($preg) {foreach($tab _name as$k =$v) {$sql='RENAME TABLE ''. $old _prefix. $v.'' to ''. $new _prefix. $v.'`'; mysql_query ($sql); } Print data table prefix:. $old _prefix."<br>". has been modified to:. $new _prefix."<br>"; }Else{Print the prefix of your database table. $old _prefix. Input error. Please check the prefix of the related database table; if(Mysql_free_result ($result)) {return true; }}?>
Since the Mysql_list_tables method is obsolete, it will give the method outdated hints when running the above program.
Deprecated:function mysql_list_tables () is Deprecated in ... on line xxx
Set error_reporting in php.ini, do not display method obsolete prompt information
3. Deleting a table in bulk
SELECT CONCAT ( ', table_name ,'; ' ) from information_schema. Tableswhere 'uc_%';
Executes a query that automatically generates SQL statements such as the DROP table table_name
MySQL bulk modify table prefix with table name SQL statement