Background :

I'm just a beginner in MYSQL. And trying to do transaction operations in MYSQL.

Query:

I am trying to alter table in mysql, I am just changing data type of a column.
To do this operation, using a tansaction. What is the good way to rollback a transaction on error ?

SQL Sever Example to Handle The Exception:

```
USE XYDB

 BEGIN TRY

 BEGIN TRANSACTION;

    ALTER TABLE <table> ALTER COLUMN <column> MEDIUMTEXT;
 COMMIT TRANSACTION;  

END TRY 

BEGIN CATCH  

IF @@TRANCOUNT > 0  

    ROLLBACK TRANSACTION;  

    SELECT   

    ERROR_NUMBER() AS ErrorNumber  

,ERROR_SEVERITY() AS ErrorSeverity  

    ,ERROR_STATE() AS ErrorState  

    ,ERROR_PROCEDURE() AS ErrorProcedure  

    ,ERROR_LINE() AS ErrorLine  

    ,ERROR_MESSAGE() AS ErrorMessage;  

    END CATCH;  
GO  

```