[support] Script to change collation on all mysql tables?

Sanduhrs sanduhrs at audiens.de
Tue Jun 27 16:17:37 UTC 2006


Ni Anisa,
I'm not a MySQL-Guru, but you may use something like the following in a simple 
PHP enabled Drupal page:

<?php
global $db_url;
$database = parse_url($db_url);
$result = db_query('show tables');
while($tables = db_fetch_array($result)) {
  foreach ($tables as $key => $value) {
    db_queryd("ALTER TABLE %s COLLATE utf8_general_ci",$value);
  }
}
?>

vg


Am Dienstag, 27. Juni 2006 16:53 schrieb Anisa:
> A lot of people, upgrading from 4.6 to 4.7, or having phpmyadmin issues,
> are interested in a script or some sort of file that will change the
> collation to utf8_general_ci on all tables. Anyone have any ideas?  I want
> to add it to the handbook.
>
> I think it would be pretty easy to make a sql thingy for default tables,
> how do you deal with prefixes?
>
> Anisa.
> OOO!  How about a list of tablenames in the handbook...


More information about the support mailing list