It is easy for all to make 1 row update or 1000 row update in database. Kust write code than wait some second and finally get xxx row updated.

It seems very easy right? But Let us see what happen when you update some rows at database.

I assume that We are updating or selecting data from one table in oracle database.

Let us see what is happening internally?

Let us first run simple queries

SQL>select * from emp;
SQL>update emp set sallary=30000 where empid=10;
SQL>commit;

Now Let us examine what is happening internally.. Here is the steps for single select and update queries:

1. Once we hit sqlplus statement as above client process(user) access sqlnet listener.

2. Sqlnet listener confirms that DB is open for business & create server process.

3. Server process allocates PGA.

4. ‘Connected’ Message returned to user.

5. User run:

SQL>select * from emp;

6. Server process checks the SGA to see if data is already in buffer cache.

7. If not then data is retrived from disk and copied into SGA (DB Cache).

8. Data is returned to user via PGA & server process.

9. Now another statement is:

SQL>Update emp set sallary=30000 where empid=10;

10. Server process (Via PGA) checks SGA to see if data is already there in buffer cache.

11. In our situation chances are the data is still in the SGA (DB Cache).

12. Data updated in DB cache and mark as ‘Dirty Buffer’.

13. Update employee placed into redo buffer and undo segments

14. Row updated message returned to user

15. Now the next steps is :

SQL>commit;

16. Newest SCN obtained from control file.

17. Data in DB cache is marked as ‘Updated and ready for saving’.

18. commit palced into redo buffer.

19. LGWR writes redo buffer contents to redo log files & remove from redo buffer.

20. Control file is updated with new SCN.

21. Commit complete message return to user.

22. Update emp table in datafile & update header of datafile with latest SCN.

23. SQL>exit;

24. Unsaved changes are rolled back.

25. Server process deallocates PGA.

26. Server process terminates.

27. After some period of time redo log are archived by ARCH process.

As you can see result comes very quickly but internally there are many process and workflow&logic is running at database side.