0

I'm currently looking for a way, to rename all tables in my db. But I don't want to rename to whole table name (you can find a lot of question about renaming whole table names on SO). So in my case I've a prefix calles wp_ before each table name what I'll replace with tnd_.

So is there a smart way how I can do this? Because I've about 200+ tables and I don't want to change every table name by hand.

Thanks for your help!

Mr. Jo
  • 4,946
  • 6
  • 41
  • 100

1 Answers1

1

I think it would work:

SELECT Concat('ALTER TABLE `', TABLE_NAME, '` RENAME TO `dr_', TABLE_NAME, '`;') 
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '<name of your db>';

Reference: How to add prefix of all tables in mysql

If you use PHP admin, you can also check: Rename and add prefix to all tables with phpMyAdmin

Eray Balkanli
  • 7,752
  • 11
  • 48
  • 82