Search This Blog

Friday, September 7, 2012

COMMIT


COMMIT is a part of Transaction Control Language (TCL) that allows us to commit the database transactions. i.e.  To save the work in database permanently.

Commit plays a vital role when we work on DML operations because we need to explicitly save it.

Commit are of two types
Explicit Commit – User have to Commit explicitly when ever he performs any DML operations like insert, update, delete on the database table.
Syntax:
   SQL> Commit;

EX:-For example we are inserting record into EMP table Shown below

SQL>INSERT INTO EMP VALUES (7125,’SCOTT’,'ANALYST', 7902,'22-DEC-1982', 15000, 1000, 20);
Output:
1 row created
 
-- To save the record into the database execute commit. 
SQL> Commit;
Output:
Commit complete

If we don’t commit the record and if ‘system crashes’ or ‘if session is ended’ data will be lost.

Implicit Commit – system will automatically execute commit when ever we perform any DDL Commands like create, alter, drop.

That is the reason if we perform any DDL command we will not be able to revert back the operation.

Example:
SQL> truncate table EMP;
-- Data will be permanently deleted from EMP table. (AUTO COMMIT)

No comments:

Post a Comment