My Operation
My Operation
COMMIT Commnand: COMMIT command is used to permanently save any transaction into the
database.
When we use any DML commands like INSERT UPDATE or
DELETE the changes made by these commands are not permanent, until the
current session is closed, the changes made by these commands can be rolled
back.
So to avoid this we use COMMIT command(TCL)
Syntax:
COMMIT;
Page No : ……
Objectives ( to do ) Procedural Point & Safety points
Before applying the COMMIT command we will create table EMPLOYEE.
Or Lets consider the EMPLOYEE table is having following records:
Following is an example which would delete those records from the table
which have age = 25 and then COMMIT the changes in the database.
Thus, two rows from the table would be deleted and the SELECT
statement would produce the following result.
This command restores the database to last commited state. It is also used
ROLLBACK Command: with SAVEPOINT command to jump to a savepoint in an ongoing
transaction.
Syntax:
ROLLBACK [To SAVEPOINT_NAME];
Page No : ……
Objectives ( to do ) Procedural Point & Safety points
If we have used the UPDATE command to make some changes into the
database, and realise that those changes were not required, then we can use
ROLLBACK command to rollback those changes, if they were not
commited using the COMMIT command.
Thus, the delete operation would not impact the table and the SELECT
statement would produce the following result.
Our table remain the same.
Syntax:
SAVEPOINT savepointname;
Rollback complete.
Page No : ……
Objectives ( to do ) Procedural Point & Safety points
Now After Selecting the table we will get :
Here only the first deletion took place since we rolled back to SP2(SavePoint
position no 2).
Exit from MYSQL: By Simply writing exit command we can exit/close from the mysql prompt
window.
MariaDB [test]>exit
Bye
C:\xampp\mysql\bin>cd\
C:\>
Then we will return back to command prompt.