MySQL started supporting transactions in version 3.23.0. In MySQL, support for transactions was added using new storage engines – InnoDB and Berkeley DB. The reason that a new storage engine was used to add transaction support was because of upward compatibility – so that the software written to support transactions would also be able to run successfully on newer versions of the software.
MyISAM is the default storage engine in MySQL, and if a table is created using the MyISAM storage engine, then that table does not actually have transaction support.
If you want to enable transaction support in MySQL then you must explicitly say that you want to use either the BDB (which stands for Berkeley DB) or InnoDB storage engine when creating a table. Here is an example of how to say which storage engine to use in MySQL:
CREATE TABLE EMPLOYEE( EMPLOYEE_ID CHAR(5) NOT NULL, EMPLOYEE_NAME VARCHAR(50) NOT NULL,PRIMARY KEY (EMPLOYEE_ID))ENGINE = INNODB;
If an when you decide to use a different storage engine in MySQL, there are a lot of considerations to take into account, because different storage engines behave differently. Read up on the MySQL documentation to see what exactly is different.
If a table is created with one of the storage engines that supports transactions in MySQL – either BDB or InnoDB – then there are two modes in which transaction support is available:
SET AUTOCOMMIT=0;SET AUTOCOMMIT=1;
COMMITROLLBACKSAVEPOINTSTART TRANSACTION
Would you like to thankProgrammerInterview.com for being a helpful free resource?Then why not tell a friend about us, orsimply add a link to this page from your webpage using the HTML below.
Link to this page:
Please bookmark with social media, your votes are noticed and appreciated: