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
    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 TABLESPACE

    Last Updated:2026-04-15 08:24:15  Updated
    share
    What is on this page
    Purpose
    Required privileges
    Syntax
    Parameters
    tablespace_encryption_option
    Examples

    folded

    share

    Purpose

    You can use this statement to modify the encryption method of a tablespace.

    Required privileges

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

    Syntax

    • Modify an encrypted tablespace.

      ALTER TABLESPACE tablespace_name ENCRYPTION [=] 'tablespace_encryption_option';
      
      tablespace_encryption_option:
          N
          | Y
          | AES-256
          | AES-256-GCM
          | AES-128
          | AES-128-GCM
          | AES-192
          | AES-192-GCM
          | SM4-CBC
          | SM4-GCM
      
    • Modify a tablespace.

      ALTER TABLESPACE tablespace_name
        {ADD | DROP} DATAFILE 'file_name'
        [INITIAL_SIZE [=] size]
        [WAIT]
        ENGINE [=] engine_name
      

      Notice

      Only the keyword syntax is supported. The functionality does not actually take effect. You cannot use this keyword in combination with ENCRYPTION. Otherwise, a syntax error will be returned.

    Parameters

    Parameter
    Description
    tablespace_name The name of the tablespace to be modified.
    tablespace_encryption_option The encryption algorithm used by the tablespace to be modified. For a detailed introduction to the encryption algorithms, see tablespace_encryption_option.

    tablespace_encryption_option

    • N: specifies not to enable encryption for the tablespace.
    • Y: specifies to enable encryption for the tablespace. By default, the AES-256 encryption algorithm is used.
    • AES-256: uses a 256-bit key for encryption and decryption.
    • AES-256-GCM: uses Galois/Counter Mode (GCM) with a 256-bit key.
    • AES-128: uses a 128-bit key for encryption and decryption.
    • AES-128-GCM: uses GCM with a 128-bit key.
    • AES-192: uses a 192-bit key for encryption and decryption.
    • AES-192-GCM: uses GCM with a 192-bit key.
    • SM4-CBC: uses the SM4 algorithm in Cipher Block Chaining (CBC) mode, where before each block of data is encrypted, it undergoes an XOR operation with the encrypted output of the previous block.
    • SM4-GCM: uses the SM4 algorithm in GCM mode, which provides both encryption and authentication functionalities.

    Note

    • Advanced Encryption Standard (AES) is a symmetric encryption algorithm, meaning the same key is used for both data encryption and decryption. The AES algorithm is block-based, typically encrypting data in 128-bit blocks.
    • AES-GCM is an operational mode employed for block encryption algorithms, such as AES, providing both encryption and data authentication (also known as message authentication code).
    • The block size of the SM4 algorithm is 128 bits, and the key length is also 128 bits.

    Examples

    Enable the unencrypted tablespace named tablespace001 to use the SM4-GCM encryption algorithm.

    ALTER TABLESPACE tablespace001 ENCRYPTION = 'SM4-GCM';
    

    Previous topic

    ALTER TABLEGROUP
    Last

    Next topic

    ALTER USER
    Next
    What is on this page
    Purpose
    Required privileges
    Syntax
    Parameters
    tablespace_encryption_option
    Examples