4

I want to add a prefix and rename all tables in a database with PhpMyAdmin.

I’ve tried these 2 scripts :

1)

select concat('rename table', table_name, ' to ', 'prefix_',table_name,';') from information_schema.tables where table_schema='db_name';

2)

SELECT Concat('ALTER TABLE ', TABLE_NAME, ' RENAME TO osc_', TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES where table_schema='db_name';

phpMyAdmin says the script is ok (see screen shot) but nothing change. What i am missing with phpMyAdmin ?

enter image description here

Sébastien Gicquel
  • 4,227
  • 7
  • 54
  • 84

1 Answers1

19

Finally, i found an easy way to do that :

  1. select all tables you want to add a prefix

  2. choose in the select option : replace prefix table

  3. fill the field with the prefix (including the underscore) as in pfx_

Screenshot of phpMyAdmin :

phpMyAdmin select all tables and add table prefix

phpMyAdmin add table prefix

result : prefix is added to all tables selected

Note : In case your website is no more connected to your data base after this modification, you can restart your serveur, MAMP, etc

Sébastien Gicquel
  • 4,227
  • 7
  • 54
  • 84