Pool of oblivion: Rename multiple tables in MySQL database

I've been searching for an easy way to rename 38 mediawiki tables in MySQL using phpmyadmin, but I failed. You can rename databases but not tables. Copy yes, rename no. Weird.

Anyway Pool of oblivion provided me with a lifesaver PHP script to rename multiple tables in MySQL database. The script lists a way replace a pattern with a new pattern. So you need to change the line that builds the new table name if you just want to prefix or postfix a table name with a set string (as I did). I'll include that code here, for your convenience:

// replacement
$new_table_name = str_replace ( $pattern, $new_pattern, $table_name);
//$new_table_name = $new_pattern . $table_name;
// postfix aka suffix
//$new_table_name = $table_name . $new_pattern;

No comments: