Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Metalink Note: Note:250655.1 : ADDM Basics USING THE AUTOMATIC DATABASE DIAGNOSTIC MONITOR Oracle
  • create database syntax Oracle
  • Recovering lost SYS password Oracle
  • Find Time Consuming SQL Statements in Oracle 10g Oracle
  • How to Use DBMS_STATS to Move Statistics to a Different Database Oracle
  • Goldengate document from Porus Oracle
  • Disbaling DBA_SCHEDULER_JOBS Oracle
  • Jai Shree Ram Oracle
  • oradebug ipcrm ipcs Oracle
  • Good notes for shared pool Oracle
  • How can I tell if ASO is installed ? Oracle
  • Search and Replace vi editor command. Linux/Unix
  • Oracle Recommended Patches — Oracle Database ID 756671.1 Oracle
  • move_arch_files.ksh Linux/Unix
  • Export Import with QUERY 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

  • pvm_rbs1.sql (to collect rbs info from db) Oracle
  • usnsql.sql Displays information about UNDO segments with sql statements Oracle
  • login.sql Oracle
  • How to set Processes Parameter Oracle
  • RAC 11g with vmware Oracle
  • shr1.sql for MTS or Shared server configuration Oracle

Leave a Reply Cancel reply

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

Categories

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

Recent Posts

  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • ORA-1841 Error Connecting to Upgraded Database After Set PASSWORD_LIFE_TIME Oracle
  • Vivek’s egrep commands to trace problem. (on linux x86-64) Linux/Unix
  • currwait.sql Oracle
  • Rman Notes -1 Oracle
  • switchover for primary database Oracle
  • Windows based Command line mailing program like mailx (Sednmail for windows) PHP/MYSQL/Wordpress
  • RAC with RHEL4 and 11g Oracle
  • How to stop OCSSD Daemon Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme