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.3.5

    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.3.5
    iconOceanBase Database
    SQL - V 4.3.5
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    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

    Use a proxy user

    Last Updated:2026-04-09 02:53:55  Updated
    Share
    What is on this page
    Prerequisites
    Background information
    Considerations
    Authorize a proxy user
    Revoke a proxy user
    References

    folded

    Share

    OceanBase Database supports the proxy user feature in Oracle mode. This feature authorizes a proxy user (such as user A) to connect to OceanBase Database on behalf of a target user (such as user B) and perform database operations under the privileges of the target user.

    Prerequisites

    You have the ALTER USER privilege. For more information about how to view your privileges, see View user privileges. If you do not have the ALTER USER privilege, contact the administrator to obtain the privilege. For more information about how to grant privileges to a user, see Grant direct privileges.

    Background information

    Assume that the USERA and USERB users are available in the current environment, the USERB user has privileges of the employee and developer roles, and the USERA user needs to be authorized as a proxy user of the USERB user.

    Considerations

    You can use a proxy user to connect to OceanBase Database on behalf of the target user through OceanBase Command-Line Client (OBClient), OceanBase Connector/J, or OceanBase Call Interface (OBCI). The versions of the components must meet the following requirements:

    • OBClient: V2.2.6 or later

    • OceanBase Connector/J: V2.4.10 or later

    • OBCI: V2.0.9 or later, excluding V2.1.0

    Authorize a proxy user

    1. Log in to an Oracle tenant of the cluster as a user with the ALTER USER privilege.

      Note that you must specify the corresponding parameters in the following sample code based on your actual database configurations.

      obclient -h10.xx.xx.xx -P2883 -usys@oracletenant#obdemo -p*****
      
    2. Authorize the USERA user as a proxy user of the USERB user.

      ALTER USER user_name GRANT CONNECT THROUGH proxy_user_name [with_clause];
      
      with_clause:
         {
             WITH ROLE {role_name[, role_name,...]}
           | WITH NO ROLE 
           | WITH ROLE ALL EXCEPT {role_name[, role_name,...]}
         }
      

      The parameters are described as follows:

      • user_name: the name of the target user corresponding to the proxy user.

      • proxy_user_name: the name of the proxy user. After authorization, the proxy user can connect to OceanBase Database on behalf of the target user and perform database operations under the privileges of the target user.

      • with_clause: specifies the roles of the target user that take effect when the proxy user connects to OceanBase Database on behalf of the target user. If this clause is not specified, all roles of the target user take effect when the proxy user connects to OceanBase Database on behalf of the target user.

        Notice

        If a role with a password is specified, you must execute the SET ROLE role_name IDENTIFIED BY role_password; statement to activate the role after you connect to OceanBase Database.

        • WITH ROLE {role_name[, role_name,...]}: specifies to automatically obtain and activate the specified roles of the target user when the proxy user connects to OceanBase Database on behalf of the target user. In this case, only the specified roles of the target user take effect.

        • WITH NO ROLE: specifies not to automatically obtain any roles of the target user when the proxy user connects to OceanBase Database on behalf of the target user. In this case, none of roles of the target user takes effect.

        • WITH ROLE ALL EXCEPT {role_name[ ,role_name,...]}: specifies to automatically obtain and activate all roles of the target user other than the specified roles when the proxy user connects to OceanBase Database on behalf of the target user.

      Here are some examples:

      • Authorize the USERA user to connect to OceanBase Database on behalf of the USERB user with all roles of the USERB user taking effect.

        obclient [SYS]> ALTER USER USERB GRANT CONNECT THROUGH USERA;
        
      • Authorize the USERA user to connect to OceanBase Database on behalf of the USERB user with only the employee role of the USERB user taking effect.

        obclient [SYS]> ALTER USER USERB GRANT CONNECT THROUGH USERA WITH ROLE employee;
        
      • Authorize the USERA user to connect to OceanBase Database on behalf of the USERB user with none of roles of the USERB user taking effect.

        obclient [SYS]> ALTER USER USERB GRANT CONNECT THROUGH USERA WITH NO ROLE;
        
      • Authorize the USERA user to connect to OceanBase Database on behalf of the USERB user with all roles of the USERB user other than the employee role taking effect.

        obclient [SYS]> ALTER USER USERB GRANT CONNECT THROUGH USERA WITH ROLE ALL EXCEPT employee;
        
    3. Exit the connection.

    4. Use the USERA user to log in to OceanBase Database on behalf of the USERB user.

      obclient -h10.xx.xx.xx -P2883 -uproxy_user_connection -p***** --proxy_user[=]user_name 
      

      The parameters are described as follows:

      • -h: the IP address for connecting to OceanBase Database. It is the IP address of an OceanBase Database Proxy (ODP) node when you connect to OceanBase Database through ODP or the IP address of an OBServer node when you directly connect to OceanBase Database.

      • -P: the port for connecting to OceanBase Database. When you connect to OceanBase Database through ODP, it is the listening port of ODP, and the default value is 2883, which can be modified when you deploy ODP. When you directly connect to OceanBase Database, it is the SQL port of the OBServer node, and the default value is 2881, which can be modified when you deploy OceanBase Database.

      • -u: the connection information of the proxy user. It is in the format of Name of the proxy user@Tenant name#Cluster name, Cluster name:Tenant name:Name of the proxy user, Cluster name-Tenant name-Name of the proxy user, or Cluster name.Tenant name.Name of the proxy user when you connect to OceanBase Database through ODP, or in the format of Name of the proxy user@Tenant name when you directly connect to OceanBase Database.

      • -p: the connection password of the proxy user. In this example, it is the connection password of the USERA user.

      • --proxy_user: the name of the target user corresponding to the proxy user. In this example, it is USERB.

      Here is an example to use the USERA user to connect to OceanBase Database on behalf of the USERB user through OBClient:

      obclient -h10.xx.xx.xx -P2883 -uUSERA@oracletenant#obdemo -p***** --proxy_user USERB 
      

      If the following information is returned, the connection is successful:

      Welcome to the OceanBase.  Commands end with ; or \g.
      Your OceanBase connection id is 3221487643
      Server version: OceanBase 4.3.2.0 (r200000272024061717-93c0ed73ebbcac6edbf7b585860b75d825935358) (Built Jun 17 2024 18:06:04)
      
      Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      obclient [USERB]>
      

      The connection information shows that the USERB user is connected to OceanBase Database. The USERB user has the privileges specified when it was authorized.

    Revoke a proxy user

    1. Log in to an Oracle tenant of the cluster as a user with the ALTER USER privilege.

      Note that you must specify the corresponding parameters in the following sample code based on your actual database configurations.

      obclient -h10.xx.xx.xx -P2883 -usys@oracletenant#obdemo -p*****
      
    2. Revoke the authorization of the USERA user as a proxy user.

      obclient [SYS]> ALTER USER USERB REVOKE CONNECT THROUGH USERA;
      

    References

    • ALTER USER

    • Overview of connection methods

    What is on this page
    Prerequisites
    Background information
    Considerations
    Authorize a proxy user
    Revoke a proxy user
    References