MySQL Database Refactoring Tool

Safely rename database objects and improve the design of your schemas using the advanced refactoring tool that comes with dbForge Studio for MySQL.

With the dbForge IDE for MySQL refactoring functionality you can perform smart structural refactorings - rename columns, tables, and\or views with the purpose to increase code readability or adopt database naming conventions. Try dbForge Studio for MySQL and enjoy faster database development with its Refactoring Tool:

  • Preview code changes
  • Rename aliases
  • Enclose identifiers in square brackets
  • Insert semicolons
  • Find invalid objects

MySQL Database Refactoring

Watch the video to see the MySQL Database Refactoring Tool in action. Find out how to rename MySQL tables, schemas, columns, or views without breaking any dependencies. With this handy tool, you can drastically save your time, increase readability, and keep up to coding standards.

Renaming MySQL tables

When manually renaming database tables using the ALTER TABLE statement, you run the risk of breaking database dependencies. And the consequences of the seemingly simple changes can be disastrous. Ensuring that all references to the renamed table reflect its new name can take much time and effort.

With the help of dbForge Refactoring tool, you can quickly and easily rename database tables, including the temporary ones, and the tool will automatically correct all references to the renamed objects.

Renaming MySQL schemas

MySQL Server doesn't support schema renaming. The RENAME DATABASE statement was added in MySQL 5.1.7 but then was found to be dangerous and was removed in MySQL 5.1.23.

To safely rename a database schema, you can use the following tools that come with dbForge Studio for MySQL:

  • Backup/Restore
  • Schema/Data Compare
  • Copy Database
The choice of a tool depends on your goals and project requirements.

Renaming columns referenced by other columns using foreign keys

When renaming a column, you always need to worry about references that use foreign keys - if you manually rename a column, these dependencies will be lost or you will have to find all foreign keys, delete them, then rename the column and recreate the keys.

The dbForge database refactoring tool for MySQL saves you the trouble. The application will find all foreign keys and will apply the new column name throughout the entire database.

Renaming columns used in creating views

It often happens that the column you need to rename is used in views. In case you just rename the column, you'll get an error when selecting data for the view. To avoid this, you will have to update all views that use the renamed column after you actually rename it. But that was before dbForge Studio for MySQL got the database refactoring tool. Now it will automatically update all views and the database behavioral and informational semantics will be retained.

Renaming objects with code

To rename an object that contains code, for example, a stored routine, you need to be twice as careful as you were in the previous situations. If you rename your stored routine and make a mistake in the code, the procedure or function will be lost and you will have to recreate it from memory.

dbForge Studio for MySQL refactoring tool uses an algorithm, that is different from the one available in all MySQL administration tools:
  • 1. A temporary stored routine is created. It contains the code of the procedure before renaming.
  • 2. All objects that use this routine are deleted.
  • 3. All objects that use this stored routine are recreated, but the routine is renamed.
  • 4. The routine with a new name and new code is created.
  • 5. The temporary stored routine is deleted.
  • In case the fifth step fails, the script execution stops and the original code can be restored from the temporary object.

Conclusion

dbForge Studio for MySQL has robust built-in capabilities for MySQL database refactoring. The tool helps smartly rename database columns, tables, views, schemas retaining overall semantic integrity. This functionality is provided by default in dbForge Studio for MySQL along with many other database management tools and features.

dbForge Studio for MySQL

The most intelligent MySQL database management tool

Availability in the editions of dbForge Studio for MySQL

Feature

Enterprise
Professional
Standard
Express
Database Refactoring
Yes
Yes
None
None