
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
What will happen to the current MySQL transaction if a START TRANSACTION command is executed in the middle of that current transaction?
The current transaction will be committed and ended if START TRANSACTION is executed in the middle of a current transaction. All the database changes made in the current transaction will be made permanent. This is called an implicit commit by a START TRANSACTION command.
Example
Suppose we have the following values in table ‘marks’
mysql> select * from marks; +------+---------+-----------+-------+ | Id | Name | Subject | Marks | +------+---------+-----------+-------+ | 1 | Aarav | Maths | 50 | | 1 | Harshit | Maths | 55 | | 3 | Gaurav | Comp | 69 | +------+---------+-----------+-------+ 3 rows in set (0.00 sec) mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO Marks Values(4, 'Rahul','History',40); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO Marks Values(5, 'Yashraj','English',48); Query OK, 1 row affected (0.00 sec) mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec)
In this example, we can observe that when the START TRANSACTION statement is executed in the middle of the current transaction then it will implicitly end the current transaction and changes will be committed.
mysql> select * from marks; +------+---------+-----------+-------+ | Id | Name | Subject | Marks | +------+---------+-----------+-------+ | 1 | Aarav | Maths | 50 | | 1 | Harshit | Maths | 55 | | 3 | Gaurav | Comp | 69 | | 4 | Rahul | History | 40 | | 5 | Yashraj | English | 48 | +------+---------+-----------+-------+ 5 rows in set (0.00 sec)
- Related Articles
- What will happen to MySQL current transaction, if in the middle of that transaction, the DDL statement is executed?
- What happens to the current MySQL transaction if the session is ended in the middle of a transaction?
- What happens to the current MySQL transaction if the session is killed by DBA?
- How can a user explicitly end current MySQL transaction?
- How can a user implicitly end current MySQL transaction?
- How can we check the current MySQL transaction isolation level?
- How can we find out the current transaction mode in MySQL?
- Which statement, other than START TRANSACTION, is used for starting a transaction?
- What is transaction processing? Explain the properties of the transaction(DBMS)
- What happens when we use COMMIT in MySQL stored procedure and one of the transaction, under START transaction, fails?
- How can a user start new MySQL transaction?
- How to start a transaction in JDBC?
- What are the different ways the transaction can be executed(DBMS)?
- How changes, made in the current transaction, can be permanently recorded\nin MySQL database?
- How changes, made in the current transaction, can be permanently eliminated from MySQL database?

Advertisements