How does Update Statement Works in Architecture Level?

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarANKUSH THAVALI
  • 13 Sep, 2023
  • 0 Comments
  • 1 Min Read

How does Update Statement Works in Architecture Level?

How does Update Statement Works in Architecture Level?

Sqlplus sys/oracle@prim
SQL>select * from emp;
SQL>update emp set salary=50000 where empid=40;
SQL>commit;

So now  we will understand How update statement works internally.

  1. Once we hit sqlplus statement client process(user) access sqlnet listener.
  2. Sql net listener confirms that DB is open & create server process.
  3. Server process allocates PGA.
  4. ‘Connected’ Message returned to user.
  5. 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 salary=50000 where empid=40;

  1. Server process (Via PGA) checks SGA to see if data is already there in buffer cache.
  2. In our situation chances are the data is still in the SGA (DB Cache).
  3. Data updated in DB cache and mark as ‘Dirty Buffer’.
  4. Update employee placed into redo buffer.
  5. Row updated message returned to user
  6. SQL>commit;
  7. New SCN obtained from control file.
  8. Data in DB cache is marked as ‘Updated and ready for saving’.
  9. commit placed into redo buffer.
  10. LGWR writes redo buffer contents to redo log files & remove from redo buffer.
  11. Control file is updated with new SCN.
  12. Commit complete message return to user. 
  13. Update emp table in datafile & update header of datafile with latest SCN.
  14. exit from SQL prompt. 
  15. Unsaved changes are rolled back.
  16. Server process deallocates PGA.
  17. Server process terminates.
  18. After some time redo log are archived by ARCH process. 

Hope it Helps!