OceanBase logo

OceanBase

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

Product Overview
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

OceanBase

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

Product Overview
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.1.0

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    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.1.0
    iconOceanBase Database
    SQL - V 4.1.0
    SQL
    KV
    • V 4.6.0
    • 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:2023-08-01 06:02:28  Updated
    share
    What is on this page
    Considerations and matching principles for rewrite binding rules
    Privileges
    Subprograms

    folded

    share

    The DBMS_UDR package provides the rewrite binding feature, which rewrites an SQL statement received by the database before execution based on the rewrite binding rule that the statement matches. At present, the package supports the rewrite of the following types of statement: SELECT, INSERT, REPLACE, UPDATE, DELETE, MERGE, and SET. You can query the DBA_OB_USER_DEFINED_RULES view for rewrite binding rules.

    OceanBase Database provides the tenant-level parameter enable_user_defined_rewrite_rules for you to enable or disable the rewrite binding feature. By default, the feature is disabled. After you enable the rewrite binding feature, it checks whether to rewrite each SQL statement received by the server based on user-defined rules.

    ALTER SYSTEM SET enable_user_defined_rewrite_rules = 'True';
    ALTER SYSTEM SET enable_user_defined_rewrite_rules = 'False';
    

    Considerations and matching principles for rewrite binding rules

    Take note of the following considerations and principles:

    • Define a rule with the same syntax as prepared statements.
    • Use a question mark (?) or :{name} in a rule pattern as a placeholder to match a constant parameter.
    • Do not use constant parameter placeholders in SQL keywords, identifiers, or functions.
    • Perform an exact match for constant values that are not represented by a question mark (?) or :{name}.
    • Use the first randomly matched rule if multiple rules are matched at the same time.
    • Perform an exact match for the database name specified when a rule was created. In Oracle mode, you do not need to specify this parameter, and the rule applies to the current user.

    The following example uses :{name} as the placeholder in a rule pattern to match constant parameters:

    CALL DBMS_UDR.CREATE_RULE('rule1',
                              'test',
                              'select :A + 1 from dual',
                              'select :A + 10, 20 from dual');
    

    The following example uses a question mark (?) as the placeholder in a rule pattern to match constant parameters:

    CALL DBMS_UDR.CREATE_RULE('rule1',
                              'test',
                              'select ? + 1 from dual',
                              'select ? + 10, 20 from dual');
    

    The following table describes sample SELECT statements that match and do not match the preceding rules.

    SQL
    Rule matched?
    select 1 + 1 from dual Yes
    select ? + 1 from dual Yes
    select 1 + 2 from dual No
    select 1 + ? from dual No

    Privileges

    You can set the tenant-level parameter enable_user_defined_rewrite_rules to enable or disable the rewrite binding feature for a tenant. You can also specify a database when you create a rule for privilege control.

    Subprograms

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

    Subprogram
    Description
    CREATE_RULE Creates a user-defined rewrite binding rule.
    DISABLE_RULE Disables a user-defined rewrite binding rule.
    ENABLE_RULE Enables a user-defined rewrite binding rule.
    REMOVE_RULE Removes a user-defined rewrite binding rule.

    Previous topic

    UNLOCK_TABLE_STATS
    Last

    Next topic

    CREATE_RULE
    Next
    What is on this page
    Considerations and matching principles for rewrite binding rules
    Privileges
    Subprograms