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-GCMModify a tablespace.
ALTER TABLESPACE tablespace_name {ADD | DROP} DATAFILE 'file_name' [INITIAL_SIZE [=] size] [WAIT] ENGINE [=] engine_nameNotice
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: IfYis specified, the AES-256 encryption algorithm is used by default.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';