Transactions does not work in structure creations/modifications?

Asked

Viewed 54 times

4

I was looking on the internet if there was any way to run Transactions for operations of the type ALTER TABLE or CREATE TABLE in the Mysql. This is because in one of our systems, we used Migrations and wanted that if something went wrong in the creation of the table, the changes had a rollback.

Eventually I discovered that is not possible do this in Mysql.

I saw it in that Answer of SOEN.

(If anyone can translate, be grateful, but I could understand more or less).

Some statements cannot be Rolled back. In general, These include data Definition language (DDL) statements, such as those that create or drop Databases, those that create, drop, or alter Tables or stored routines.

But then there were some doubts :

  • Knowing that they’re not all Statments that support Rollback, what are they that are always accepted?

  • Why is there such limitation regarding the structural changes in the tables?

1 answer

2

In accordance with the documentation Mysql speaks, in general DDL(create, alter, drop, trucante) commands are not supported within transactions, as their execution causes a commit implicit or is once executed the instruction your application is made in the bank on time in case of success.

Usually the concept of transaction is applied to manipulation (do/undo) of the data, some banks allow some DDL in transfers as per that answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.