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

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogWhite PaperLive 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.3
    iconOceanBase Database
    SQL - V 4.3.3
    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

    ALTER USER

    Last Updated:2025-11-27 02:38:06  Updated
    Share
    What is on this page
    Purpose
    Required privileges
    Limitations
    Syntax
    Parameters
    with_clause
    Examples

    folded

    Share

    Purpose

    You can use this statement to perform the following operations:

    • Change the password of a database user.

    • Change the profile used by a database user.

    • Change the encryption method of database user connections. For more information about how to change user passwords, see SET PASSWORD.

    • Change the default role of a database user.

    Required privileges

    To execute this statement to modify information of a user other than the current user, you must have the ALTER USER privilege. For more information about privileges in OceanBase Database, see Privilege types in Oracle mode.

    Limitations

    You can use a proxy user to connect to OceanBase Database on behalf of the target user through OceanBase Command-Line Client (OBClient). The version of OBClient must be 2.2.6 or later. At present, you cannot connect to OceanBase Database by using a Java driver or a C driver.

    Syntax

    ALTER USER user_name
        { IDENTIFIED BY password
        | PROFILE {"profile_name" | DEFAULT}
        | REQUIRE {NONE | SSL | x509 | tls_option_list}
        | DEFAULT ROLE
                { role_name[,role_name...]
                | ALL [EXCEPT role_name[,role_name...]]
                | NONE
                }
        | GRANT CONNECT THROUGH proxy_user_name [with_clause]
        };
    
    tls_option_list:
        tls_option
        | tls_option_list tls_option
    
    tls_option:
        CIPHER str_value
        | ISSUER str_value
        | SUBJECT str_value
    
    with_clause:
        WITH ROLE {role_name[, role_name,...]}
        | WITH NO ROLE 
        | WITH ROLE ALL EXCEPT {role_name[, role_name,...]}
    

    Parameters

    Parameter
    Description
    user_name The name of the login user or the name of the target user corresponding to the proxy user.
    IDENTIFIED BY The new password of the user.
    PROFILE The profile used by the user.
    • profile_name: The name of the profile.
    • DEFAULT: specifies to ignore this parameter.
    REQUIRE The encryption protocol for the user. Valid values: NONE, SSL, X509, and tls_option_list.
    DEFAULT ROLE The default role of the user during login.
    • ALL: specifies to set all roles owned by the user to default roles. The EXCEPT clause specifies the roles excluded. This clause is optional.
    • NONE: specifies not to set default roles, namely, to disable all roles of the user.

      Notice

      You cannot specify the following roles as the default roles of a user:

      • Roles that are not granted to the user
      • Roles that are granted to the user by other roles

    GRANT CONNECT THROUGH Specifies to use a proxy user. For more information about how to use a proxy user, see Use a 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 with the privileges of the target user.
    with_clause 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. For more information, see with_clause.

    with_clause

    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.

    Examples

    • Change the password of user1.

      obclient> ALTER USER user1 IDENTIFIED BY ******;
      Query OK, 0 rows affected
      
    • Change the connection encryption protocol to SSL for user1.

      obclient> ALTER USER user1 REQUIRE SSL;
      Query OK, 0 rows affected
      
    • Change the profile used by user1 to profile1.

      obclient> ALTER USER user1 PROFILE "profile1";
      Query OK, 0 rows affected
      
    • Set the default roles of user1.

      obclient> CREATE ROLE role1;
      Query OK, 0 rows affected
      
      obclient> CREATE ROLE role2 IDENTIFIED BY ******;
      Query OK, 0 rows affected
      
      obclient> CREATE ROLE role3 IDENTIFIED BY ******;
      Query OK, 0 rows affected
      
      obclient> GRANT role1,role2,role3 TO user1;
      Query OK, 0 rows affected
      
      obclient> ALTER USER user1 DEFAULT ROLE role1;
      Query OK, 0 rows affected
      

      Note

      user1 can directly use the privileges of role1. To use the privileges of role2 and role3, user1 must first enable role2 and role3 in the session.

      For more information about the statement for enabling roles, see SET ROLE.

    Previous topic

    ALTER TABLEGROUP
    Last

    Next topic

    COMMENT
    Next
    What is on this page
    Purpose
    Required privileges
    Limitations
    Syntax
    Parameters
    with_clause
    Examples