2

Can anyone explain what the internal operations are that takes place when an alter command is issued? How is column modified? Does it use created_tmp_tables or created_tmp_files?

As per my test, I created a table and with the alter command I added a column. After checking the created_tmp_file status variable, it increased by 3.

Can someone explain how this alter command works internally?

0

1 Answer 1

1

See the ALTER TABLE docs here:

http://dev.mysql.com/doc/refman/5.6/en/alter-table.html

"In most cases, ALTER TABLE makes a temporary copy of the original table."

1
  • To elaborate on this. In this specific case the table is locked for read and writes. A new temp table is created, the data is copied into the new table with the additional column, the table is renamed and the old one is dropped, finally the table is unlocked. Commented Feb 17, 2017 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.