Purpose
This statement is used to modify sensitive data protection rules.
Privilege requirements
To execute the ALTER SENSITIVE RULE statement, the current user must have the CREATE SENSITIVE RULE privilege. For more information about OceanBase AI Database privileges, see Permission classification.
Syntax
ALTER SENSITIVE RULE rule_name ADD COLUMN sensitive_field_list
ALTER SENSITIVE RULE rule_name DROP COLUMN sensitive_field_list
ALTER SENSITIVE RULE rule_name ENABLE
ALTER SENSITIVE RULE rule_name DISABLE
ALTER SENSITIVE RULE rule_name USING ENCRYPTION [ = { DEFAULT | encryption_method } ]
Parameters
The specific parameters are described as follows:
Parameter |
Data type |
Default Value |
Description |
|---|---|---|---|
| rule_name | Character | The name of the sensitive rule, which must be unique within the tenant. | |
| sensitive_field_list | Character | Column to be encrypted, in the format of db.table(col1, col2), db2.table2(col3, col4), ... Each sensitive item specifies one or more columns in the table, separated by commas. Multiple sensitive items are separated by commas. db Can be empty. The default is the current connected database. |
|
| encryption_method | Character | Encryption method. Default value: aes-256, which actually refers to the AES-256-ECB encryption algorithm. For the valid values, see the description below. |
The encryption_method parameter can take the following values:
Values (used in SQL syntax) |
Actual Encryption Algorithm Used |
Key Length |
schema |
Description |
|---|---|---|---|---|
| aes-256 | AES-256-ECB | 256-bit | ECB | Default Algorithm |
| aes-128 | AES-128-ECB | 128-bit | ECB | |
| aes-192 | AES-192-ECB | 192-bit | ECB | |
| aes-128-gcm | AES-128-GCM | 128-bit | GCM | High security level, supports Authenticated Encryption with Additional Data (AEAD) |
| aes-192-gcm | AES-192-GCM | 192-bit | GCM | High security level, supports Authenticated Encryption with Additional Data (AEAD) |
| aes-256-gcm | AES-256-GCM | 256-bit | GCM | High security level, supports Authenticated Encryption with Additional Data (AEAD) |
| sm4-cbc | SM4-CBC | CBC | High security level | |
| sm4-GCM | SM4-GCM | GCM | High security level, supports Authenticated Encryption with Additional Data (AEAD) |
The limitations are as follows:
- The
sensitive_field_listparameter forADD/DROP COLUMNis consistent with this field in theCREATE SENSITIVE RULEsyntax. - The column added by
ADD COLUMNcannot be protected by any existing rule. - The column dropped by the
DROP COLUMNstatement must be a column protected by the specified rule. DISABLE: Temporarily disables the current sensitive rule without deleting it. Rules are enabled by default after creation.
Examples
Here is an example:
-- Add tbl2(c), db2.tbl3(x); to sensitive rule r1;
ALTER SENSITIVE RULE r1 ADD COLUMN tbl2(c), db2.tbl3(x);
-- Remove tbl2(c) from sensitive rule r1
ALTER SENSITIVE RULE r1 DROP COLUMN tbl2(c);
-- Enable sensitive rule r1
ALTER SENSITIVE RULE r1 ENABLE;
-- Disable sensitive rule r1
ALTER SENSITIVE RULE r1 DISABLE;
-- Modify the encryption algorithm of sensitive rule r1 to the default algorithm.
ALTER SENSITIVE RULE r1 USING ENCRYPTION;
-- Modify the encryption algorithm of sensitive rule r1 to sm4-cbc.
ALTER SENSITIVE RULE r1 USING ENCRYPTION = 'sm4-cbc';