Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Find_table_size.sql Oracle
  • To see how much time or progress of long transaction Oracle
  • get_vmstat.ksh for Solaris Oracle
  • Committing distributed transaction using commit force Oracle
  • Logic to chech # of parameters command line parameters Linux/Unix
  • Oracle 10g for solaris 10 Oracle
  • Find nth max and min. Oracle
  • Looping for remote servers and find its database from oratab file. Linux/Unix
  • This is from Temi Oracle
  • Read CSV file using PySpark Python/PySpark
  • Deleting first line and lastline of a file using sed Linux/Unix
  • Distributed Transaction Troubleshooting. Oracle
  • useful dg links Oracle
  • To see mem usage and CPU usage system wide. Linux/Unix
  • purge_trc.sh Linux/Unix

Insert cause enqueue locks

Posted on 23-Apr-2008 By Admin No Comments on Insert cause enqueue locks

Here is a much simpler version:

——————————-

Create table t1 (c1 number primary);

session1:

insert into t1 values (1);

session2:

insert into t1 values (1);

— would hang

v$lock would reveal session 1 blocking session2 on TX lock

why? because you have a constraint where you are asking Oracle to check uniqueness of data (unique index/unique constraint / primary key).

So Oracle looks as session-2’s data and checks the existing data..it sees session-1’s data uncommitted. Now Oracle doesn’t know if session-1 would commit or rollback. so it has to wait. this is by design.its always been like this.(so session 2 has to enqueue behind session 1 )

if session-1 commits, session would fail since unique key constraint is violated..if session-1 rolls back, session-2 would go through fine.

Its a lock based on “data” . It doesn’t matter what your statement is..(“insert into table values..” or “insert based on select” )..the behavior would be the same.

You don’t see the 2 sessions blocking each other (inserting the same key) when you don’t have any consistency checks (unique index/constraint). Oracle knows it can allow any data..so no locks based on data.

Reference : http://hemantoracledba.blogspot.com/2007/10/inserts-holding-locks-inserts-waiting.html

Oracle, SQL scripts

Post navigation

Previous Post: Reclaim temp tablespace for oracle 8, 8i
Next Post: alter database backup controlfile to trace

Related Posts

  • dbinv.sql Oracle
  • prepfiles.sh for step by step generating pending statistics files Oracle
  • Good Site for Oracle Internals Oracle
  • Monitor Long Running Job Oracle
  • DBMS_Shared_pool pinning triggers Oracle
  • longtx.sql with the flag whether session is blocking any DML locks or not. Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Django (0)
  • GIT (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (403)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (18)
  • rman-dataguard (26)
  • shell (150)
  • SQL scripts (350)
  • SQL Server (6)
  • Uncategorized (5)
  • Videos (0)

Recent Posts

  • Key Management in Oracle: The Core Issue: Missing Master Key12-May-2026
  • SAT Mathematics 10 questions and answer at the end.30-Apr-2026
  • top 10 AI news today30-Apr-2026
  • runon_allpdbs_show_conname.sh23-Apr-2026
  • runon_allcdbs_find_pdbs.sql23-Apr-2026
  • Running PDB on single node in RAC09-Apr-2026
  • find_arc.sql09-Apr-2026
  • pvm_pre_change.sql08-Apr-2026
  • find_encr_wallet.sql08-Apr-2026
  • find_pdbs.sql08-Apr-2026

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Proc code Oracle
  • crtgr.sql /* For creating trigger from data dictionary */ Oracle
  • USER_TABLES.Freelists Oracle
  • Standby Database File Management in 10g with STANDBY_FILE_MANAGEMENT Oracle
  • Specify the Rollback segment to use in Transaction Oracle
  • CTAS with LONG Column for 9i and higher Oracle
  • Rollback force for distributed transactions Oracle
  • copying/removing directory with all its subdirectory Linux/Unix

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme