Combine ALTER statements

Discussion of open issues, suggestions and bugs regarding database management and administration tools for MySQL
Post Reply
gazuga
Posts: 3
Joined: Fri 07 Jun 2019 19:10

Combine ALTER statements

Post by gazuga » Fri 07 Jun 2019 19:43

When making multiple modifications to a table, the generated SQL script contains multiple ALTER statements. For example, If I were to add 3 new columns to a table, the resulting script would be something like...

Code: Select all

ALTER TABLE table ADD COLUMN newcolumn1 INT;
ALTER TABLE table ADD COLUMN newcolumn2 INT;
ALTER TABLE table ADD COLUMN newcolumn3 INT;
... when these could actually be combined into a single ALTER statement like...

Code: Select all

ALTER TABLE table 
ADD COLUMN newcolumn1 INT,
ADD COLUMN newcolumn2 INT,
ADD COLUMN newcolumn3 INT;
The 3 separate ALTER statements essentially take 3 times longer to run than the single combined ALTER statement. It might not seem like much, but this actually makes a gigantic difference when the table being altered is large, has many indexes, and/or has several things being altered... Imagine a large table that takes an hour to perform an ALTER on, and then having to unnecessarily multiply that hour by the number of things you're altering.

The same thing happens when doing a schema comparison.

alexa

Re: Combine ALTER statements

Post by alexa » Tue 18 Jun 2019 14:41

You can add a suggestion on the UserVoice forum where other users can vote for it https://devart.uservoice.com/forums/772 ... -for-mysql

We collect and analyze the information from this forum in order to make a proper roadmap for the future product releases.

Post Reply