Presentation is loading. Please wait.

Presentation is loading. Please wait.

Temporary versus Permanent Changes to Data

Similar presentations


Presentation on theme: "Temporary versus Permanent Changes to Data"— Presentation transcript:

1 Temporary versus Permanent Changes to Data
DML statements (INSERT, UPDATE, DELETE) cause changes to be made to data in application tables These changes are initially only applied to a copy of data from the table(s) stored in memory (similar to how you make changes to document in memory using Word) Changes are only made permanently to the database tables stored on disk if a COMMIT command is issued (similar to how you save a file periodically when using an editor such as Word)

2 COMMIT A COMMIT causes changes made to data in memory to be made permanently to database tables stored on disk A COMMIT is automatically performed by the DBMS after any DDL statement (CREATE, ALTER, DROP) You should issue a COMMIT after a transaction (a group of related actions that may affect many database tables but that corresponds to a single logical task in an application) is complete

3 ROLLBACK If a transaction cannot be completed for any reason then all changes made to the tables should be rolled back using the ROLLBACK command You should also issue a ROLLBACK command if you realize that you have mistakenly changed some data A ROLLBACK command causes the DBMS to discard any changes made to the data in memory since the last COMMIT was performed or since the last DDL statement was performed

4 EXAMPLE CREATE TABLE stud(ID INT,name VARCHAR2(20));
INSERT INTO stud(ID, name) VALUES(1,’Bob’); INSERT INTO stud(ID,name) VALUES(2,’Sara’); COMMIT; INSERT INTO stud(ID,name) VALUES(3,’Roberto’); ROLLBACK; INSERT INTO stud(ID,name) VALUES(4,’Li’); ALTER TABLE stud ADD CONSTRAINT stud_pk PRIMARY KEY(ID); INSERT INTO stud(ID,name) VALUES(5,’Maria’); See next slide for result

5 EXAMPLE RESULT SELECT ID, name FROM stud; ID NAME 1 Bob 2 Sara 4 Li


Download ppt "Temporary versus Permanent Changes to Data"

Similar presentations


Ads by Google