Sébastien Gicquel Sébastien Gicquel - 27 days ago 14
SQL Question

Rename and add prefix to all tables with phpMyAdmin

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

Answer Source

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.

See screenshot :

enter image description here

enter image description here