Description
This statement is used to create a TableSpace logical object. The TableSpace attribute supports encryption.
Syntax
Create an encrypted tablespace.
CREATE 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-GCMCreate tablespaces.
CREATE TABLESPACE tablespace_name [ADD DATAFILE 'file_name'] [FILE_BLOCK_SIZE = value] USE LOGFILE GROUP logfile_group [EXTENT_SIZE [=] extent_size] [INITIAL_SIZE [=] initial_size] [AUTOEXTEND_SIZE [=] autoextend_size] [MAX_SIZE [=] max_size] [NODEGROUP [=] nodegroup_id] [WAIT] [COMMENT [=] 'string'] [ENGINE [=] engine_name]Notice
Only this keyword syntax is supported; the feature does not take effect. This syntax keyword cannot be executed together with
ENCRYPTION; otherwise, the syntax will report an error.
Parameters
Parameter |
Description |
|---|---|
| tablespace_name | Specifies the name of the TableSpace object to be created. |
| ENCRYPTION | Optional. Specifies the encryption key, which defines the encryption algorithm used by the tablespaces. If no encryption algorithm is specified by using the ENCRYPTION keyword, a non-encrypted tablespace is created by default. For more information about the encryption algorithms, see tablespace_encryption_option. |
tablespace_encryption_option
N: Indicates that no encryption is performed.Y: If you useY, the defaultAES-256algorithm is used.AES-256: Uses a 256-bit key for encryption and decryption.AES-256-GCM: GCM mode using a 256-bit key.AES-128: Uses a 128-bit key for encryption and decryption.AES-128-GCM: GCM mode using a 128-bit key.AES-192: Uses a 192-bit key for encryption and decryption.AES-192-GCM: GCM mode using a 192-bit key.SM4-CBC: The SM4 algorithm is used in CBC mode. In this mode, each data block is encrypted by performing an XOR operation with the encrypted output of the previous block.SM4-GCM: The SM4 algorithm operates in GCM mode, which provides both data encryption and authentication.
Note
- AES (Advanced Encryption Standard) is a symmetric encryption algorithm, which means the same key is used for both encrypting and decrypting data. The AES algorithm itself is based on block encryption and typically encrypts data in 128-bit blocks.
- AES-GCM (Galois/Counter Mode) is an operation mode used to process block encryption algorithms such as AES, providing both encryption and data authentication (also known as a message authentication code).
- The SM4 algorithm uses 128-bit blocks and a 128-bit key.
Examples
Create an unencrypted tablespaces object.
CREATE TABLESPACE tablespace001;Create a TableSpace object using transparent data encryption (TDE).
Set the encryption method to built-in transparent encryption.
ALTER SYSTEM SET tde_method = 'internal';Displays the configuration of the current encryption method.
SHOW PARAMETERS LIKE 'tde_method';Generate a new primary encryption key.
ALTER INSTANCE ROTATE INNODB MASTER KEY;Notice
Although this command is executable, generating a new primary encryption key will fail if disk space is full.
Create an encrypted tablespace named
tablespace2using theSM4-GCMencryption algorithm.CREATE TABLESPACE tablespace002 ENCRYPTION = 'SM4-GCM';