You can decrypt a table by simply removing the table from the encrypted tablespace.
Applicability
OceanBase Database Community Edition currently does not support transparent data encryption.
Background information
Assume that table t1 is in the following encryption status and is stored in the 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 the administrator.
Perform progressive compactions 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.
The statement to initiate a progressive compaction is as follows:
obclient> ALTER SYSTEM MAJOR FREEZE;Note
Decryption is an asynchronous process. The decryption process requires progressive compactions of the table to ensure that all data is decrypted.
Create an unencrypted tablespace named
ts2.obclient> CREATE TABLESPACE ts2;Access 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 has been 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 setThe query result shows that the
ENCRYPTEDfield of thet1table is set toNO, indicating that thet1table has been decrypted.