0% found this document useful (0 votes)
15 views2 pages

5 Advanced Rdbms Concepts 10xii

Uploaded by

h0762281
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

5 Advanced Rdbms Concepts 10xii

Uploaded by

h0762281
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ADVANCED RDBMS CONCEPTS 1

Transaction : A transaction is a unit of work that must be done in logical order and
successfully as a group or not done at all.

 START TRANSACTION statement


 COMMIT statement
 ROLLBACK statement

START TRANSACTION Statement:

START TRANSACTION statement commits the current transaction and starts a new transaction.
It tells MySQL that the transaction is beginning and the statements that follow should be treated
as a unit, until the transaction ends. It is written like this:

START TRANSACTION;

The START TRANSACTION statement has no clauses.

COMMIT Statement:

The COMMIT statement is used to save all changes made to the database during the transaction
to the database. Commit statement is issued at a time when the transaction is complete- all the
changes have been successful and the changes should be saved to the database. COMMIT ends
the current transaction. COMMIT statement is used like this:

COMMIT;
Or
COMMIT WORK;

Here WORK is a keyword and is optional.

ROLLBACK Statement:

When a transaction is being executed, some type of error checking is usually performed to
check whether it is executing successfully or not. If not, the entire transaction is undone using
the ROLLBACK statement. The ROLLBACK statement cancels the entire transaction i.e. It rolls
the transaction to the beginning. It aborts any changes made during the transaction and the
state of database is returned to what it was before the transaction began to execute and does
not save any of the changes made to the database during the transaction. ROLLBACK statement
is used like this:

Amit Kumar Singhal


ADVANCED RDBMS CONCEPTS 2

ROLLBACK;
Or
ROLLBACK WORK;

Here WORK is a keyword and is optional.

SAVEPOINT:

The SAVEPOINT statement defines a marker in a transaction. These markers are useful in rolling
back a transaction till the marker.

We can add a savepoint anywhere in a transaction. When you roll back to that savepoint, any
changes made to the database after the savepoint are discarded, and any changes made prior
to the savepoint are saved. It is like semicomitting a transaction. To define a savepoint, we
enter the SAVEPOINT statement like this:

SAVEPOINT <savepoint-name>;

Example :

SAVEPOINT Mark1;

In the above statement a marker (savepoint) with the name Mark1 is defined. It becomes a
bookmark in the transaction. Now we can write the following statement:

ROLLBACK TO SAVEPOINT Mark1;

to rollback the transaction till the bookmark named Mark1.

AUTOCOMMIT:

When AutoCommit is ON, each SQL statement is a transaction. The changes resulting from each
statement are automatically committed.
When Auto Commit is Off then changes made to database are not committed unless explicitly
requested.

Amit Kumar Singhal

You might also like