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

    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.2
    iconOceanBase Database
    SQL - V 4.2.2
    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 SEQUENCE

    Last Updated:2026-04-15 08:27:15  Updated
    share
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples

    folded

    share

    Purpose

    You can use this statement to modify the increment, minimum value, maximum value, cache size, and action of the current sequence. The modification affects only subsequent sequence values.

    Note

    You can modify only sequences in your schema or those for which you have the ALTER privilege.

    Syntax

    ALTER SEQUENCE [ schema. ] sequence_name
    { RESTART [ START WITH int_value ]
    |[ MINVALUE int_value | NOMINVALUE ]
    |[ MAXVALUE int_value | NOMAXVALUE ]
    |[ INCREMENT BY int_value ]
    |[ CACHE int_value | NOCACHE ]
    |[ ORDER | NOORDER ]
    |[ CYCLE | NOCYCLE]
    }
    ;
    

    Parameters

    Parameter
    Description
    schema. The schema where the sequence resides. If this parameter is not specified, the database modifies the sequence in the schema of the current user.
    sequence_name The name of the sequence to be modified.
    RESTART Restarts the generation of sequence values. When the sequence ascends, new values start from MINVALUE. When the sequence descends, new values start from MAXVALUE. Alternatively, START WITH int_value is used to generate values starting from int_value.
    MINVALUE int_value The minimum value of the sequence. Value range: [-(1027-1), (1027-1)].
    NOMINVALUE If NOMINVALUE is specified, the minimum value is 1 for an ascending sequence and -(1027-1) for a descending sequence.
    MAXVALUE int_value The maximum value of the sequence. Value range: [(-1027+1), (1028-1)]. The specified MAXVALUE value cannot be smaller than the current sequence value.
    Notice: When MINVALUE and MAXVALUE are both specified, MINVALUE must be smaller than MAXVALUE. The difference between MAXVALUE and MINVALUE must be greater than or equal to INCREMENT BY int_value.
    NOMAXVALUE If NOMAXVALUE is specified, the maximum value is (1028-1) for an ascending sequence and -1 for a descending sequence.
    INCREMENT BY int_value Modifies the increment of the sequence. int_value cannot be 0. If the value is positive, the sequence ascends. If the value is negative, the sequence descends. If this parameter is not specified, the default value is 1.
    CACHE int_value Modifies the number of sequence values pre-allocated in the memory. By default, int_value is 20. The value of CACHE int_value must be greater than 1. If the value of CACHE int_value is 1, it is equivalent to NOCACHE.
    NOCACHE Specifies that no sequence values are pre-allocated. If neither CACHE nor NOCACHE is specified, the database caches 20 sequence values by default.
    ORDER Specifies that sequence values are generated in order.
    NOORDER If NOORDER is specified, it is not assured that sequence values are generated in order.
    CYCLE Specifies that sequence values are generated cyclically. That is, when the sequence reaches its maximum or minimum value, it continues to generate values. If the sequence ascends and reaches its maximum value, the minimum sequence value will be generated. If the sequence descends and reaches its minimum value, the maximum sequence value will be generated.
    Notice
    • If CYCLE is specified and the value of INCREMENT BY int_value is smaller than 0, MINVALUE must be specified.
    • If CYCLE is specified, the number of values in the cache cannot be greater than the number of values in the cycle.
    NOCYCLE NOCYCLE is the default value. If NOCYCLE is specified, no more values are generated when the sequence reaches its maximum or minimum value.

    Examples

    • Modify the maximum value of the seq1 sequence and enable cyclic generation of sequence values.

      obclient> ALTER SEQUENCE seq1 MAXVALUE 1024 CYCLE;
      Query OK, 0 rows affected
      
    • Modify the maximum value and increment of the seq3 sequence, enable CYCLE and ORDER, and specify NOCACHE to indicate that the sequence values are not pre-allocated.

      obclient> ALTER SEQUENCE seq3 MAXVALUE 1500 INCREMENT BY 5 CYCLE NOCACHE ORDER;
      Query OK, 0 rows affected
      
    • Restart the sequence from 3.

      obclient> ALTER SEQUENCE seq3 RESTART;
      Query OK, 0 rows affected
      
      obclient> ALTER SEQUENCE seq3 RESTART START WITH 3;
      Query OK, 0 rows affected
      
    • The sequence can restart from any position. In the following example, the two SQL statements for restarting a sequence are equivalent.

      obclient> ALTER SEQUENCE seq3 START WITH 3 RESTART MINVALUE  -100 CYCLE;
      Query OK, 0 rows affected
      
      obclient> ALTER SEQUENCE seq3 RESTAR START WITH 3 T MINVALUE  -100 CYCLE;
      Query OK, 0 rows affected
      

    Previous topic

    ALTER OUTLINE
    Last

    Next topic

    MAJOR and MINOR
    Next
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples