Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Read CSV file using PySpark Python/PySpark
  • Gathering statistics with DBMS_STATS Oracle
  • My Minimum Tuning Programs Oracle
  • Finding Oracle Patches with opatch Oracle
  • Oracle Metalink useful notes Oracle
  • Find execution plan from dba_hist_sql_plan for a specific SQL_ID and PLAN_HASH_VALUE fplan.sql Oracle
  • Check_recovery.sh program to run sqlplus and return its values remotely. Linux/Unix
  • Find Multiple levels of object dependencies : depen.sql Oracle
  • Important Solaris Commands Linux/Unix
  • get_vmstat_solaris Oracle
  • Finding last recovered file on DR and remove all chanracters before any “/” Linux/Unix
  • CPU speed on Linux Linux/Unix
  • Giving Grant on v$DATABASE Oracle
  • How to Make Trace Files Created by Oracle Readable by All Users ? Oracle
  • How to find where datafile is created dbf_info.sql Oracle

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

  • Renaming the column name Oracle
  • FRA Information. Oracle
  • DBMS_STATS Metalinks Notes Oracle
  • Btee and Bitmap Plans in Oracle 9i and higher Oracle
  • plan10g.sql good Oracle
  • DBMS_PROFILER for tuning PLSQL programs. 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 (400)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (18)
  • rman-dataguard (26)
  • shell (150)
  • SQL scripts (348)
  • SQL Server (6)
  • Uncategorized (3)
  • Videos (0)

Recent Posts

  • 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
  • Creating a Container Database using dbaascli08-Apr-2026
  • track_autoupgrade_copy_progress.sql01-Apr-2026
  • refre.sql for multitenant01-Apr-2026
  • prepfiles.sh for step by step generating pending statistics files10-Mar-2026
  • tracksqltime.sql05-Mar-2026

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Find Command Linux/Unix
  • To find all disk io ( EMC as well as local) Linux/Unix
  • fkwoindex.sql /* Find FK without Index */ Oracle
  • configUOCIOTTO.ora Oracle
  • How to change hostname in Linux Linux/Unix
  • move_arch_files.ksh Linux/Unix
  • _B_TREE_BITMAP_PLANS issue during 8.1.7 to 9.2.0.8 upgrade Oracle
  • find_pdbs.sql Uncategorized

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme