TRANSACTION CONTROL LANGUAGE
COMMIT -- once commit means to save all pending changes permanent storage.
ROLLBACK -- To discard all pending clauses
SAVEPOINT -- It is marker
DDL operation is auto commit.
SQL> CREATE TABLE TCL(Cid Number);
Table created.
SQL> INSERT into TCL values(1);
SQL> INSERT into TCL values(2);
SQL> INSERT into TCL values(3);
SQL> commit;
Commit complete.
SQL> INSERT into TCL values(4);
SQL> INSERT into TCL values(5);
SQL> SAVEPOINT S5;
Savepoint created.
SQL> SELECT * FROM TCL;
CID
----------
1
2
3
4
5
SQL> ROLLBACK TO S5;
Rollback complete.
SQL> SELECT * FROM TCL;
CID
----------
1
2
3
4
5
SQL> INSERT into TCL values(6);
SQL> INSERT into TCL values(7);
SQL> SELECT * FROM TCL;
CID
----------
1
2
3
4
5
5 rows selected.
SQL> CREATE TABLE A1(ID Number);
Table created.
SQL> INSERT into A1 values(1);
SQL> commit;
Commit complete.
SQL> INSERT into A1 values(2);
SQL> INSERT into A1 values(3);
SQL> CREATE TABLE A2(ID Number);
Table created.
SQL> INSERT into A2 values(4);
SQL> INSERT into A2 values(5);
SQL> INSERT into A2 values(1);
SQL> INSERT into A2 values(2);
SQL> rollback;
Rollback complete.
SQL> SELECT * FROM A1;
ID
----------
1
2
3
SQL> SELECT * FROM A2;
no rows selected
No comments:
Post a Comment