Reputation: 5251
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!
Upvotes: 0
Views: 469
Reputation: 7960
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
Upvotes: 1