OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.5

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the Al Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.5
    iconOceanBase Database
    SQL - V 4.3.5
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Overview

    Last Updated:2026-02-02 07:28:28  Updated
    share
    What is on this page
    Privileges
    Constants
    Rules and limitations
    Considerations
    Subprograms

    folded

    share

    The DBMS_LOCK package provides an interface to the lock management services of OceanBase Database.

    The system package provides the following features:

    • Exclusive access to a device, such as a terminal

    • Perception of a lock release when an application releases or cleans up a lock

    • Synchronization and coordination among different applications or processes

      Applicability

      This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.

    Privileges

    The database system may impose an upper limit on the maximum number of available locks. When you use locks or provide this package to other users, consider granting the EXECUTE privilege only to specific users or roles.

    Constants

    The following table lists the constants used in the DBMS_LOCK package.

    Constant Attribute Type Value OEM abbreviation Description
    NL_MODE Nul1 INTEGER 1 None Lock-free mode
    SS_MODE Sub Shared INTEGER 2 ULRS Intention read lock
    SX_MODE Sub eXclusive/Row Exclusive Mode INTEGER 3 ULRX Intention write lock
    S_MODE Shared/Row Exclusive Mode/Intended Exclusive INTEGER 4 ULRSX Read lock
    SSX_MODE Shared Sub eXclusive/Share Row Exclusive Mode INTEGER 5 None Shared intention write lock
    X_MODE Exclusive INTEGER 6 ULX Write lock

    Rules and limitations

    The following table describes the lock compatibility matrix. Y indicates that the application succeeds, and N indicates that the application fails.

    Lock held mode GET NL GET SS GET SX GET S GET SSX GET X
    NL Y Y Y Y Y Y
    SS Y Y Y Y Y N
    SX Y Y Y N N N
    S Y Y N Y N N
    SSX Y Y N N N N
    X Y N N N N N

    Specify maxwait for a lock to set the default wait time.

    maxwait  constant integer := 32767;
    

    Considerations

    • User locks are identified with the prefix "UL" and will never conflict with table locks.
    • Locks are automatically released when a session terminates.
    • The lock ID ranges from 0 to 1073741823.
    • A user lock acts in the same way as a table lock and has all the features of a table lock, such as deadlock detection.
    • Make sure that any user locks used in distributed transactions are released upon transaction commits; otherwise, an undetected deadlock may occur.
    • DBMS_LOCK is most efficient with a limit of a few hundred locks for each session.

    Subprograms

    The following table describes the DBMS_LOCK subprograms supported by the current OceanBase Database version.

    Subprogram Description
    ALLOCATE_UNIQUE Requests a unique lock ID in the range of 1073741824 to 1999999999 for a specified lock name.
    ALLOCATE_UNIQUE_AUTONOMOUS Requests a unique lock ID for a specified lock name.
    REQUEST Requests a lock.
    SLEEP Suspends the current session for a specific amount of time.
    RELEASE Releases a lock obtained by using the REQUEST function.

    Previous topic

    WRITEAPPEND
    Last

    Next topic

    ALLOCATE_UNIQUE
    Next
    What is on this page
    Privileges
    Constants
    Rules and limitations
    Considerations
    Subprograms