Renaming Multiple MySQL Tables Within A Few Seconds

This can be used to rename the prefix or suffix of a table, but not the whole table name.

I came up with this simple tips on renaming multiple tables in your MySQL database within a few seconds.Recently, I was googling on how to rename multiple tables at once in MySQL Database. I came across few tips but they didn’t meet my needs. So I came up with this simple way of doing it.

First, you need to have a text editor having ‘Find and Replace‘ feature. Almost every text editor available will be having this feature. I am using Notepad++ for the text editor. The next thing you need to do is to export your database having the tables you need to rename. Export your database to an SQL file and save it on your computer. Now, fire up the text editor of your choice and open the SQL file you downloaded just now. Click the Find and Replace option from your text editor. Find your table name and then type the table name in the ‘Find‘ field, and type the replacement string in the ‘Replace‘ field. Then click ‘Replace All‘ and save the SQL file. For example, If your table name is tbl_mytable, you can find the string tbl_ and replace it with tl1_. The find and replace procedure might be different with different editors but they are likely to be similar.

Now, go to phpMyAdmin and drop or backup all the tables inside your database. Import the SQL file you have just edited from your phpMyAdmin and now you are good to go with your tables having new name.

One thought on “Renaming Multiple MySQL Tables Within A Few Seconds”

Leave a Reply to Manas Mitra Cancel reply