I know how to run
RENAME TABLE onetable_test TO onetable;
But is there a method to rename many tables with a pattern and don\'t write a lot of
I wanted to update what worked for me since this post is pretty old. I needed to add the ` mark before and after the table names. And don't forget to add the last ; because this can sometimes throw a syntax error.
SET group_concat_max_len=5000;
SELECT group_concat(v.name separator '; ')
FROM (
SELECT concat('RENAME TABLE `', t.table_name, '` TO `', replace(t.table_name, 'wp_', 'wplocal_'), '`') name
FROM information_schema.tables t
WHERE table_name like 'wp_%'
) v;