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.2.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.2.5
    iconOceanBase Database
    SQL - V 4.2.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

    MODIFY REPLICA

    Last Updated:2026-04-09 09:38:52  Updated
    Share
    What is on this page
    Purpose
    Limitations and considerations
    Required privileges
    Syntax
    Parameters
    Examples
    References

    folded

    Share

    Purpose

    You can use this statement to convert the type of a replica.

    Limitations and considerations

    • Make sure that the log stream still meets the majority principle after the type of replica is converted. Otherwise, the O&M command returns an error.

    • This statement converts the type of one replica at a time.

    • One log stream of a tenant supports only parallel replica migration tasks and only one replica task at a time, such as a task to add replicas, remove replicas, convert the type of a replica, and modify the number of Paxos replicas of a log stream.

      Note

      You can query ongoing replica tasks from the CDB_OB_LS_REPLICA_TASKS view in the sys tenant or from the DBA_OB_LS_REPLICA_TASKS view in a user tenant.

    Required privileges

    To execute this statement, you must have the ALTER SYSTEM privilege. For more information about privileges in OceanBase Database, see Privilege types in MySQL mode and Privilege types in Oracle mode.

    Syntax

    ALTER SYSTEM MODIFY REPLICA
        LS [=] ls_id
        SERVER [=] 'svr_ip:svr_port'
        REPLICA_TYPE [=] 'replica_type'
        [PAXOS_REPLICA_NUM [=] paxos_replica_num]
        [TENANT [=] 'tenant_name'];
    

    Parameters

    Parameter
    Description
    ls_id The ID of the log stream for which you want to convert the type of a replica.
    svr_ip:svr_port The IP address and port number of the OBServer node on which you want to convert the type of the replica, for example, xxx.xx.xxx.001:2882.
    replica_type The replica type to convert to. Conversion between the following two types of replicas is supported:
    • Full-featured replica: A full-featured replica is denoted as FULL or F.
    • Read-only replica: A read-only replica is denoted as READONLY or R.

    Note

    A full-featured replica can be elected as the leader, whereas a read-only replica cannot.

    paxos_replica_num Optional. The number of Paxos members for electing the leader for the log stream. If this parameter is not specified, the default value is used. A log stream supports a maximum of seven full-featured replicas.

    Notice

    When you specify the value of the paxos_replica_num parameter, take note of the following considerations:

    1. Converting a full-featured replica to a read-only replica is equivalent to removing a leader. In this case, you must decrease the value of the paxos_replica_num parameter by 1.
    2. Converting a read-only replica to a full-featured replica is equivalent to adding a leader. In this case, you must increase the value of the paxos_replica_num parameter by 1.
    3. After the value of the paxos_replica_num parameter is modified, the available replicas must be the majority.
    4. The value of the paxos_replica_num parameter must be greater than or equal to the number of members in the MEMBER_LIST of the leader. You can query the MEMBER_LIST from the CDB_OB_LS_LOCATIONS view in the sys tenant or from the DBA_OB_LS_LOCATIONS view in a user tenant.
    5. The absolute value of the variation of the paxos_replica_num value cannot be greater than 1. For example, if the value of the paxos_replica_num parameter is 3, you can change it only to 2 or 4.
    If any of the preceding conditions is not met, the system will return an error.

    tenant_name Optional. The name of the target tenant. If this parameter is not specified, the name of the current tenant is used.

    Notice

    You can specify another tenant in the sys tenant and specify only the current tenant in a user tenant. You cannot use the ALL, ALL_USER, or ALL_META option in this statement to specify all tenants, all user tenants, or all meta tenants.

    Examples

    Execute the following statement in the sys tenant to convert a full-featured replica of a log stream in the mysql001 tenant to a read-only replica:

    ALTER SYSTEM MODIFY REPLICA 
        LS = 1001
        SERVER = 'xxx.xxx.xxx.001:2882'
        REPLICA_TYPE = 'R'
        PAXOS_REPLICA_NUM = 2
        TENANT = 'mysql001';
    

    For information about how to convert the type of a replica, see Convert the type of a replica.

    References

    • For information about how to add a replica, see ADD REPLICA.
    • For information about how to drop a replica, see REMOVE REPLICA.
    • For information about how to migrate a replica, see MIGRATE REPLICA.
    • For information about how to modify the PAXOS_REPLICA_NUM parameter for a replica, see MODIFY PAXOS_REPLICA_NUM.
    • For information about how to cancel a replica task, see CANCEL REPLICA TASK.

    Previous topic

    MODIFY PAXOS_REPLICA_NUM
    Last

    Next topic

    MODULE DATA
    Next
    What is on this page
    Purpose
    Limitations and considerations
    Required privileges
    Syntax
    Parameters
    Examples
    References