Investigating transactions and concurrency

In this recipe we will see more details on locking and, specifically, on deadlocks .

Getting ready

In this recipe we will use two SQL*Plus sessions, to simulate two users concurrently accessing the database.

How to do it...

This recipe deals wits transactions and concurrency. Follow these steps:

  1. Connect SESSION 1 to the database as SH user:
    -- SESSION 1
    CONNECT sh@TESTDB/sh
    
  2. Update a row on the CUSTOMERS table in SESSION 1:
    UPDATE CUSTOMERS SET
      CUST_FIRST_NAME = 'TEST1-1'
      WHERE CUST_ID = 26;
    
  3. Connect SESSION 2 to the database as SH user:
    -- SESSION 2
    CONNECT sh@TESTDB/sh
    
  4. Update a row on the CUSTOMERS table in SESSION 2, different from the one updated in step 2 by SESSION 1:
    UPDATE CUSTOMERS SET
     CUST_FIRST_NAME ...

Get Oracle Database 11gR2 Performance Tuning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.