What is TDE?
Transparent Data Encryption encrypts data on disk. If someone steals the datafiles or a backup, they only see unreadable bytes. Applications do not change at all, which is why it is called transparent.
| Piece | Role |
| Keystore (wallet) | A protected file that holds the master key |
| Master encryption key | Protects the keys that encrypt the data |
| Tablespace encryption key | Encrypts the datafiles of one tablespace |
Licence note: TDE is part of Oracle's Advanced Security option on Enterprise Edition. Check the licence rules for your edition before using it in production. Practice on a test system is fine.
Step 1: Tell Oracle Where the Wallet Lives
sql
-- connect to the root as SYSDBA
ALTER SYSTEM SET WALLET_ROOT = '/opt/oracle/admin/FREE/wallet' SCOPE = SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP;
ALTER SYSTEM SET TDE_CONFIGURATION = 'KEYSTORE_CONFIGURATION=FILE' SCOPE = BOTH;
Create the folder first and make sure the Oracle OS user owns it. The tde sub-folder is created inside WALLET_ROOT.
Step 2: Create and Open the Keystore
sql
ADMINISTER KEY MANAGEMENT CREATE KEYSTORE IDENTIFIED BY "WalletPwd#1";
ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN
IDENTIFIED BY "WalletPwd#1" CONTAINER = ALL;
Step 3: Create the Master Key
sql
ADMINISTER KEY MANAGEMENT SET KEY
IDENTIFIED BY "WalletPwd#1" WITH BACKUP CONTAINER = ALL;
Step 4: Auto-Login (So the Database Opens After Restart)
sql
ADMINISTER KEY MANAGEMENT CREATE AUTO_LOGIN KEYSTORE
FROM KEYSTORE '/opt/oracle/admin/FREE/wallet/tde'
IDENTIFIED BY "WalletPwd#1";
Why auto-login? Without it, an administrator must open the keystore by hand after every restart, otherwise encrypted data cannot be read.
Check the Keystore
sql
SELECT wrl_type, status, wallet_type FROM v$encryption_wallet;
Result
STATUS should be OPEN. WALLET_TYPE shows PASSWORD or AUTOLOGIN.
Create an Encrypted Tablespace
sql
ALTER SESSION SET CONTAINER = FREEPDB1;
CREATE TABLESPACE secure_data
DATAFILE '/opt/oracle/oradata/FREE/FREEPDB1/secure01.dbf' SIZE 100M
ENCRYPTION USING 'AES256'
DEFAULT STORAGE (ENCRYPT);
SELECT tablespace_name, encrypted FROM dba_tablespaces;
Every table you create in secure_data is encrypted automatically. Applications and queries work as before.
Protect the Wallet
Critical: If you lose the keystore, you lose all encrypted data, including data in backups. Back up the wallet separately from the database backups, and store the wallet password safely.
- Keep wallet backups in a different location from the database backups.
- Limit who has access to the wallet folder.
- Rotate the master key on a schedule that your policy requires.
Conclusion
TDE encrypts data files and backups with no application changes. The keystore is the single most important file, so back it up separately.
Quick Summary: Keystore + master key + encrypted tablespace. Lose the wallet = lose the data.