To decrypt a table, you need only to remove the table from the encrypted tablespace.
Background
Assume that table t1 is in the following encryption status and is stored in an encrypted tablespace sectest_ts1.
obclient> SELECT * FROM oceanbase.V$OB_ENCRYPTED_TABLES;
+----------+------------+---------------+---------------+-----------+----------------------------------+-------------+------------------+------------------+--------+--------+
| TABLE_ID | TABLE_NAME | TABLESPACE_ID | ENCRYPTIONALG | ENCRYPTED | ENCRYPTEDKEY | MASTERKEYID | BLOCKS_ENCRYPTED | BLOCKS_DECRYPTED | STATUS | CON_ID |
+----------+------------+---------------+---------------+-----------+----------------------------------+-------------+------------------+------------------+--------+--------+
| 500010 | t1 | 500009 | aes-256 | YES | xxxxxxxxxxxxxxxxxxxxxxxxxxxx7882 | xxxx08 | 0 | 0 | NORMAL | 0 |
+----------+------------+---------------+---------------+-----------+----------------------------------+-------------+------------------+------------------+--------+--------+
1 row in set
obclient> SHOW CREATE TABLE t1;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
`id1` int(11) DEFAULT NULL,
`id2` int(11) DEFAULT NULL
) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 TABLESPACE `sectest_ts1` |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set
Remove the table from the encrypted tablespace
Log on to a MySQL tenant as an administrator.
Perform a progressive compaction on the table.
Set the
progressive_merge_numparameter to a value greater than1, and run theOPTIMIZEcommand.Here is an example:
obclient> ALTER TABLE t1 SET progressive_merge_num = 3; obclient> OPTIMIZE TABLE t1;Manually initiate multiple progressive compactions.
Execute the following statement to initiate a progressive compaction:
obclient> ALTER SYSTEM MAJOR FREEZE;Note
Decryption is an asynchronous process. Progressive compactions must be performed on the table to ensure that all data is decrypted.
Create an unencrypted tablespace
ts2.obclient> CREATE TABLESPACE ts2;Enter the database where the table is located.
Move the
t1table from the encrypted tablespacesectest_ts1to the unencrypted tablespacets2.obclient> ALTER TABLE t1 TABLESPACE ts2;Then, execute the
SHOW CREATE TABLEstatement to check whether thet1table is moved to the tablespacets2:obclient> SHOW CREATE TABLE t1; +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | t2 | CREATE TABLE `t1` ( `id1` int(11) DEFAULT NULL, `id2` int(11) DEFAULT NULL ) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 TABLESPACE `ts2` | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in setQuery the
oceanbase.V$OB_ENCRYPTED_TABLESview to check the encryption status of the table.obclient> SELECT * FROM oceanbase.V$OB_ENCRYPTED_TABLES; +------------------+------------+------------------+---------------+-----------+--------------+-------------+------------------+------------------+------------+--------+ | TABLE_ID | TABLE_NAME | TABLESPACE_ID | ENCRYPTIONALG | ENCRYPTED | ENCRYPTEDKEY | MASTERKEYID | BLOCKS_ENCRYPTED | BLOCKS_DECRYPTED | STATUS | CON_ID | +------------------+------------+------------------+---------------+-----------+--------------+-------------+------------------+------------------+------------+--------+ | 500010 | t1 | 500015 | | NO | | 0 | 2 | 0 | NORMAL | 0 | +------------------+------------+------------------+---------------+-----------+--------------+-------------+------------------+------------------+------------+--------+ 1 row in setIt is clear that the
ENCRYPTEDcolumn of tablet1isNO. This indicates that tablet1is decrypted.