Remove prefix name from every table

Remove prefix name from every table

Posted By: pmietlicki

Published to SQL on Mar 21, 2015

You'll have to adapt this script to your situation. The second parameter of substr indicates the position of the string to get rid of beginning with zero (so it would be 9 for "october_").

select concat('RENAME TABLE ', concat(table_name, concat(' TO ', concat(substr(table_name, 9), ';')))) from information_schema.tables where table_name like 'october_%';

The "where" part is to filter just the tables that begins with "october_". You should know that this script will generate all the rename instructions that you'll have to execute. You can use the options "printable export" inside phpmyadmin.

Tags: MySQL, SQL

Archive