When multiple Web sites share a MySQL database, in order to make the database management is not confused, the general use of different sites using different prefix names to distinguish. And how do you batch modify the prefix name of an existing database? Export all changes and then import? Or is it a table modified by tables? Today I would like to introduce a relatively simple method of batch modification of table prefixes in the database, which is suitable for modifying the same prefix in the database and more data tables.
This example assumes that a table with the prefix "phpcms_" in the database named "WWW_SDCK_CN" is modified and that the prefix for all qualifying tables is modified to "sdck_".
1, with phpMyAdmin open to modify the prefix of the database WWW_SDCK_CN, execute the following SQL statement (which bold italic is required to replace the actual requirements):
Select CONCAT (' ALTER TABLE ', table_name, ' RENAME to ', replace (table_name, 'phpcms_', 'sdck_'), '; ')
From Information_schema.tables
where Table_schema = 'www_sdck_cn' and table_name like 'phpcms_% ';
2, in the execution of the SQL statement generated page click "Export", select "Custom"-> "direct display as text", CSV format, empty "content separator" empty
3, to perform the export function, the results window to the following, copy the contents of the text box
4, into the database "www_sdck_cn" SQL execution window, paste the code into the SQL text box, execute. See if the relevant data sheet has been modified.
Attention matters
Data manipulation is risky, back up your data before you operate.
Because of the software version and other reasons, the operation is for reference only, because this article modifies the database to cause loss or error, the author is not responsible.