Welcome to AI DBA Hub – Your One-Stop Hub for Database Mastery!
AI DBA Hub is your go-to channel for Oracle Database (23ai, 26ai) and PostgreSQL tutorials. Learn AI DBA skills, performance tuning, architecture, migrations, and real-world DBA scenarios.
Oracle AI Database • PostgreSQL • AI DBA Roadmap • Performance Tuning • Exadata • Cloud & Autonomous DB • DBA Interview Preparation.
Lost Your Oracle TDE Wallet Password? There IS a Recovery Path | AI DBA Hub
AI DBA HubOracle SecurityTDE RecoveryWallet Management
🚨 DBA Emergency Guide
Lost Your TDE Wallet Password? There IS a Recovery Path!
You cannot recover the original TDE wallet password — but if an Auto-Login wallet (cwallet.sso) exists and the keystore is open, you can create a new wallet with a new password and continue accessing your encrypted data — with zero data loss.
👤 AI DBA Hub🏷 Oracle TDE · Security · Recovery⏱ ~12 min read🎯 Intermediate–Advanced DBAs
The Scenario — What Happens When You Lose the TDE Password?
It happens more often than DBAs admit: the TDE wallet password was set by a colleague who left the team, stored in a password manager no one can access, or simply forgotten after a long period without keystore operations. The database is running, encrypted data is accessible — but the moment you need to do a keystore operation (key rotation, adding a new tablespace, manual wallet open after restart), you hit a wall.
🚫
Important: The Password Cannot Be Recovered
Oracle uses one-way hashing for the TDE wallet password. There is no backdoor, no Oracle Support override, no way to extract or reverse-engineer the original password from ewallet.p12. The only path forward is creating a new wallet with a new password.
⭐
The Good News — The Recovery Path Exists
If an Auto-Login wallet (cwallet.sso) exists and the keystore is currently OPEN, Oracle allows you to create a new password-protected wallet from the open keystore state. Your Master Encryption Keys remain intact. Your encrypted tablespaces remain accessible. No data loss.
The One Critical Prerequisite — cwallet.sso
The entire recovery path hinges on a single file: cwallet.sso — the Auto-Login wallet. This file is created when you run ADMINISTER KEY MANAGEMENT CREATE AUTO_LOGIN KEYSTORE. Unlike ewallet.p12 (which requires a password), cwallet.sso opens automatically via OS-level authentication.
❌ Recovery NOT Possible
Only ewallet.p12 exists
Keystore is CLOSED
cwallet.sso was never created
cwallet.sso was deleted
Database was restarted without auto-login
✅ Recovery IS Possible
cwallet.sso exists in WALLET_ROOT
Keystore STATUS = OPEN (auto-login active)
Database is running (not restarted since last open)
SYSDBA or SYSKM privilege available
Master Encryption Keys are intact
Step 0: Check Your Current State
Before anything else, verify whether recovery is possible in your environment.
SQL — Verify Keystore & Wallet State
-- 1. Check keystore status — STATUS must be OPEN or OPEN_NO_MASTER_KEYSELECTwrl_type,wrl_parameter,status,wallet_type,con_idFROMv$encryption_wallet;-- STATUS should be: OPEN or OPEN_NO_MASTER_KEY
-- WALLET_TYPE should be: AUTOLOGIN or PASSWORD
-- If STATUS = CLOSED → Recovery path is NOT available without the password-- 2. Check physical wallet files in your WALLET_ROOTSELECTvalueFROMv$parameterWHEREname='wallet_root';-- Then from OS shell — verify both files exist:-- $ ls -la $WALLET_ROOT/tde/
-- cwallet.sso ← Auto-Login wallet (the recovery enabler)
-- ewallet.p12 ← Password-protected wallet-- 3. Check existing encryption keysSELECTkey_id,creation_time,activation_time,keystoretypeFROMv$encryption_keysORDER BYcreation_timeDESC;
Decision Tree — Which Path Are You On?
🔍 TDE Password Lost — Recovery Decision Flow
Is the keystore OPEN?
Check V$ENCRYPTION_WALLET
↙ YESNO ↘
Does cwallet.sso exist?
Check WALLET_ROOT/tde/
❌ Cannot Recover
Keystore CLOSED + no password = data unrecoverable
↙ YESNO ↘
✅ Recovery Path Available
Proceed with CREATE KEYSTORE FROM KEYSTORE
❌ Limited Options
DB running? Try MERGE KEYSTORE. Else: restore from backup
The Recovery Procedure — Step by Step
⚠️
Back Up First — Always
Before executing any keystore operation, copy your entire WALLET_ROOT directory to a safe location. This preserves both ewallet.p12 and cwallet.sso as-is before any changes.
1
Back Up Your Existing Wallet Files
Copy the entire wallet directory before any changes. This is your rollback point.
OS Shell — Backup Wallet
# Step 1: Backup WALLET_ROOT directory (DO THIS FIRST)WALLET_ROOT="/etc/oracle/wallets/${ORACLE_SID}/tde"BACKUP_DIR="/backup/tde_wallet_$(date +%Y%m%d_%H%M%S)"mkdir-p$BACKUP_DIRcp-p$WALLET_ROOT/*$BACKUP_DIR/ls-la$BACKUP_DIR# Verify both files backed up:
# ewallet.p12 (password-protected — old, inaccessible password)
# cwallet.sso (auto-login — this is the recovery key)
2
Confirm Keystore is Open via Auto-Login
The keystore must currently be OPEN. If the database was restarted and no auto-login wallet exists, this path is unavailable.
SQL — Confirm Open State
-- Verify keystore is OPEN — this is the go/no-go checkSELECTwrl_type,status,wallet_type,fully_backed_upFROMv$encryption_wallet;-- Expected output (recovery possible):
-- WRL_TYPE STATUS WALLET_TYPE FULLY_BACKED_UP
-- FILE OPEN AUTOLOGIN NO ← GOOD: auto-login open
-- FILE OPEN PASSWORD NO ← GOOD: password-opened (use known pwd)
--
-- Recovery NOT possible if:
-- FILE CLOSED UNKNOWN NO ← CLOSED = need password to open-- For CDB: check all PDB keystores tooSELECTcon_id,status,wallet_typeFROMv$encryption_walletORDER BYcon_id;
3
Create a New Password-Protected Wallet FROM the Open Keystore
This is the core recovery command. Oracle copies all existing Master Encryption Keys from the currently-open keystore into a brand new ewallet.p12 protected by your chosen new password.
SQL — Core Recovery Command
-- THE KEY RECOVERY COMMAND
-- Creates a new ewallet.p12 with NewPassword from the currently-open keystore
-- All existing Master Encryption Keys are preservedADMINISTER KEY MANAGEMENTCREATE KEYSTORE'/etc/oracle/wallets/${ORACLE_SID}/tde'IDENTIFIED BY"YourNewStrongPassword@2024"FROMKEYSTOREIDENTIFIED EXTERNALLY;-- NOTE: "IDENTIFIED EXTERNALLY" means Oracle reads from the
-- currently-open auto-login (cwallet.sso) keystore.
-- This does NOT require the old password.
-- The command REPLACES ewallet.p12 with a new file using the new password.-- For CDB environments — run in the CDB root (not a PDB)ALTER SESSION SETcontainer=CDB$ROOT;ADMINISTER KEY MANAGEMENTCREATE KEYSTORE'/etc/oracle/wallets/${ORACLE_SID}/tde'IDENTIFIED BY"YourNewStrongPassword@2024"FROMKEYSTOREIDENTIFIED EXTERNALLYCONTAINER=ALL;
4
Verify the New Password Works
Test the new password immediately by closing and re-opening the keystore with the new credentials.
SQL — Test New Password
-- Close the keystore (now uses new ewallet.p12)ADMINISTER KEY MANAGEMENTSET KEYSTORE CLOSEIDENTIFIED BY"YourNewStrongPassword@2024"CONTAINER=ALL;-- Re-open with new password — if this succeeds, recovery is completeADMINISTER KEY MANAGEMENTSET KEYSTORE OPENIDENTIFIED BY"YourNewStrongPassword@2024"CONTAINER=ALL;-- Verify keystore is open and keys are accessibleSELECTstatus,wallet_type,fully_backed_upFROMv$encryption_wallet;-- Confirm all MEKs are intactSELECTkey_id,creation_time,activation_timeFROMv$encryption_keysORDER BYcreation_time;-- Verify encrypted tablespaces are still accessibleSELECTtablespace_name,encrypted,encryption_algorithmFROMv$encrypted_tablespaces;
5
Regenerate the Auto-Login Wallet with the New Password
After creating the new ewallet.p12, regenerate cwallet.sso so it stays in sync with the new wallet. This also ensures future database restarts work without manual intervention.
SQL — Regenerate Auto-Login Wallet
-- Regenerate cwallet.sso from the newly-created ewallet.p12ADMINISTER KEY MANAGEMENTCREATE AUTO_LOGIN KEYSTOREFROMKEYSTORE'/etc/oracle/wallets/${ORACLE_SID}/tde'IDENTIFIED BY"YourNewStrongPassword@2024";-- Verify cwallet.sso was created/updated on OS:-- $ ls -la $WALLET_ROOT/tde/
-- -rw-r----- cwallet.sso ← Updated auto-login (synced with new ewallet.p12)
-- -rw-r----- ewallet.p12 ← New password-protected wallet-- Final verification: keystore opens automatically (simulates restart)ADMINISTER KEY MANAGEMENTSET KEYSTORE CLOSEIDENTIFIED BY"YourNewStrongPassword@2024"CONTAINER=ALL;-- Open via auto-login (no password needed = simulates post-restart auto-open)ADMINISTER KEY MANAGEMENTSET KEYSTORE OPENIDENTIFIED EXTERNALLYCONTAINER=ALL;SELECTstatus,wallet_typeFROMv$encryption_wallet;-- Expected: STATUS=OPEN, WALLET_TYPE=AUTOLOGIN ← SUCCESS
Data Guard Environments — Extra Steps
If you're running a Data Guard configuration, the new wallet must be propagated to all Standby databases after recovery.
SQL + Shell — Data Guard Wallet Sync
-- After recovery on PRIMARY, sync to Standby:-- Step 1: Copy both wallet files to Standby's WALLET_ROOT-- $ scp $WALLET_ROOT/tde/ewallet.p12 oracle@standby:$WALLET_ROOT/tde/-- $ scp $WALLET_ROOT/tde/cwallet.sso oracle@standby:$WALLET_ROOT/tde/-- Step 2: Open keystore on Standby with new passwordADMINISTER KEY MANAGEMENTSET KEYSTORE OPENIDENTIFIED BY"YourNewStrongPassword@2024"CONTAINER=ALL;-- Step 3: Verify standby TDE sync statusSELECTdest_id,db_unique_name,tde_keystore_status,statusFROMv$archive_dest_statusWHEREstatus='VALID';-- Using Oracle Key Vault (OKV)?
-- Key sync is automatic — just ensure OKV is reachable from Standby
-- Verify: ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED EXTERNALLY;
Troubleshooting Common Errors
Error
Cause
Fix
ORA-46656
cwallet.sso missing or corrupted
Restore from RMAN backup; contact Oracle Support
ORA-28365
Keystore is CLOSED — cannot create from closed keystore
Recovery path unavailable without password; restore wallet from backup
ORA-46655
Keystore path does not exist or insufficient permissions
Verify WALLET_ROOT path; check OS permissions for oracle user
New password not accepted
Weak password — Oracle enforces complexity rules
Use mixed case, numbers, special chars: Wallet@2024#Secure
CDB: some PDBs still show CLOSED
CONTAINER=ALL not used
Re-run with CONTAINER=ALL or connect to each PDB and open individually
Keys missing after recovery
MEK was in a different keystore location (HSM vs FILE)
Run SELECT * FROM v$encryption_keys on both; use MERGE KEYSTORE
Prevention — Best Practices to Avoid This Again
1
Always Create an Auto-Login Wallet
Create cwallet.sso immediately after setting up your keystore. This is both your operational convenience tool AND your recovery insurance. Run: ADMINISTER KEY MANAGEMENT CREATE AUTO_LOGIN KEYSTORE FROM KEYSTORE '/path' IDENTIFIED BY "pwd";
2
Store the Password in a Vault or PAM Tool
Use CyberArk, HashiCorp Vault, Oracle Key Vault, or your organisation's PAM solution. Never store TDE passwords only in a personal password manager or undocumented.
3
Include Wallet Files in RMAN Backup
RMAN does not back up wallet files by default. Script an OS-level backup of WALLET_ROOT after every keystore change (key rotation, new password). Keep 3+ generations.
4
Test Password Rotation Quarterly
Add a quarterly calendar event to verify the wallet password on all databases. Open and close the keystore manually: SET KEYSTORE OPEN → SET KEYSTORE CLOSE. Catch issues before they become emergencies.
5
Use Oracle Key Vault for Enterprise Deployments
OKV eliminates the lost-password problem entirely for most scenarios. Keys are centrally managed, access-controlled, and audited. Especially critical for Data Guard and RAC environments.
Quick Reference — All Commands
SQL — Complete Recovery Command Reference
-- ═══════════════════════════════════════════════════════════
-- ORACLE TDE WALLET PASSWORD RECOVERY — FULL COMMAND REFERENCE
-- Prerequisite: cwallet.sso exists + keystore STATUS = OPEN
-- ═══════════════════════════════════════════════════════════-- DIAGNOSE: Check current stateSELECTwrl_type,status,wallet_typeFROMv$encryption_wallet;-- BACKUP: OS-level wallet backup (run from shell)-- cp -rp $WALLET_ROOT/tde /backup/tde_$(date +%Y%m%d)-- RECOVER: Create new wallet from open auto-login keystoreADMINISTER KEY MANAGEMENTCREATE KEYSTORE'/path/to/wallet'IDENTIFIED BY"NewPassword@2024"FROMKEYSTOREIDENTIFIED EXTERNALLYCONTAINER=ALL;-- TEST: Close and reopen with new passwordADMINISTER KEY MANAGEMENTSET KEYSTORE CLOSEIDENTIFIED BY"NewPassword@2024"CONTAINER=ALL;ADMINISTER KEY MANAGEMENTSET KEYSTORE OPENIDENTIFIED BY"NewPassword@2024"CONTAINER=ALL;-- REGEN: Rebuild auto-login wallet from new ewallet.p12ADMINISTER KEY MANAGEMENTCREATE AUTO_LOGIN KEYSTOREFROMKEYSTORE'/path/to/wallet'IDENTIFIED BY"NewPassword@2024";-- VERIFY: All keys intactSELECTstatus,wallet_typeFROMv$encryption_wallet;SELECTtablespace_name,encryptedFROMv$encrypted_tablespaces;
🔐 Oracle TDE🔑 cwallet.sso💊 Recovery🛡 Data Guard🔒 ewallet.p12⚡ Zero Data Loss🏥 DBA Emergency
Master TDE Master Encryption Key rotation, automate compliance schedules for PCI-DSS, SOX, GDPR and HIPAA, and build audit-ready key management pipelines — with every command covered.
👤 AI DBA Hub🏷 Oracle TDE · Compliance · Automation⏱ ~16 min read🎯 Intermediate–Advanced DBAs
Why Key Rotation Matters — The Compliance Imperative
Transparent Data Encryption protects your data at rest, but encryption is only as strong as your key management discipline. Regulatory frameworks don't just require you to encrypt — they require you to rotate encryption keys regularly, maintain an audit trail of every rotation event, and prove that compromised keys were replaced.
PCI-DSS
Req 3.6.x: Cryptographic key rotation annually or when compromised. Full key lifecycle documentation required.
SOX
Section 404: Key management controls must be documented and tested. Rotation events require audit records.
GDPR
Art. 32: Appropriate technical measures including key rotation. Data breach scope reduced with recent key rotation.
HIPAA
§164.312(a)(2)(iv): Encryption key management. PHI must be encrypted with regularly rotated keys.
AES-256 required for new rotations. Key lifecycle including creation, distribution, storage and destruction.
⭐
Oracle TDE Key Rotation — What Changed in 26ai
Oracle 26ai introduced online key rotation for both individual tablespaces and CDB-wide operations. Rotation now happens without taking tablespaces offline, and the redo stream propagates key changes automatically to Data Guard standbys — turning a multi-hour maintenance window into a background operation.
Understanding TDE Key Hierarchy
Before rotating keys, you must understand the two-level key hierarchy Oracle TDE uses. Confusing the two types leads to incorrect rotation procedures and compliance gaps.
Key Type
Abbreviation
Purpose
Rotation Command
Scope
Master Encryption Key
MEK
Encrypts all Tablespace Encryption Keys. Stored in wallet/OKV.
ADMINISTER KEY MANAGEMENT SET KEY
CDB / PDB
Tablespace Encryption Key
TEK
Encrypts actual data blocks. Wrapped by the MEK.
ALTER TABLESPACE … REKEY
Per tablespace
💡
MEK vs TEK Rotation — Know the DifferenceMEK rotation (most common) replaces the top-level master key without touching data blocks. Fast, non-disruptive. TEK rotation (REKEY) re-encrypts every data block in the tablespace with a new key — resource-intensive but required for highest-security compliance postures or post-breach scenarios. Most rotation schedules require MEK rotation; TEK rotation is the nuclear option.
Types of Key Rotation Operations
🔑 Scheduled MEK Rotation
Routine compliance-driven rotation of the Master Encryption Key. Required by PCI-DSS annually. Fast, runs online, no tablespace downtime. Most common operation.
⚡ Emergency MEK Rotation
Triggered when a key is suspected compromised. Must be executed immediately regardless of maintenance windows. Requires immediate Standby sync and audit documentation.
🔄 Tablespace REKEY (TEK)
Full re-encryption of all data blocks with a new Tablespace Encryption Key. Used post-breach or for algorithm upgrades (3DES → AES256). Resource-intensive — plan I/O carefully.
🗄️ CDB-Wide Rotation
Rotates MEK for the CDB root and all open PDBs in a single operation using CONTAINER=ALL. Ensures consistent rotation timestamps across all pluggable databases.
MEK Rotation — Step by Step
⚠️
Pre-Rotation Checklist
(1) Verify keystore is OPEN on Primary AND all Standbys. (2) Take OS backup of WALLET_ROOT. (3) Record current MEK ID from V$ENCRYPTION_KEYS for audit trail. (4) Confirm no other keystore operation is in progress.
Step 1: Pre-Rotation Audit Snapshot
SQL — Pre-Rotation State Capture
-- Capture current MEK details BEFORE rotation (for audit log)SELECTkey_id,creation_time,activation_time,retired_time,keystoretype,creator,con_idFROMv$encryption_keysORDER BYactivation_timeDESC;-- Verify keystore status on PrimarySELECTwrl_type,status,wallet_type,fully_backed_upFROMv$encryption_wallet;-- Backup wallet (OS command — run before proceeding)-- cp -rp $WALLET_ROOT/tde /backup/tde_pre_rotation_$(date +%Y%m%d_%H%M%S)
Step 2: Rotate the Master Encryption Key
SQL — MEK Rotation Commands
-- ═══════════════════════════════════════════════════════
-- OPTION A: Non-CDB / Single PDB Rotation
-- ═══════════════════════════════════════════════════════ADMINISTER KEY MANAGEMENTSET KEYUSING TAG'PCI_ROTATION_2024Q4'-- Audit tag for complianceIDENTIFIED BY"WalletPassword@2024"WITH BACKUP USING'pre_rotation_2024Q4'-- Keystore backupFORCE KEYSTORE;-- ═══════════════════════════════════════════════════════
-- OPTION B: CDB-Wide Rotation (Root + All Open PDBs)
-- ═══════════════════════════════════════════════════════ALTER SESSION SETcontainer=CDB$ROOT;ADMINISTER KEY MANAGEMENTSET KEYUSING TAG'SOX_ROTATION_2024Q4_CDB'IDENTIFIED BY"WalletPassword@2024"WITH BACKUP USING'cdb_rotation_2024Q4'FORCE KEYSTORECONTAINER=ALL;-- Rotates in CDB + all PDBs-- ═══════════════════════════════════════════════════════
-- OPTION C: OKV (Oracle Key Vault) — No Password Needed
-- ═══════════════════════════════════════════════════════ADMINISTER KEY MANAGEMENTSET KEYUSING TAG'GDPR_ROTATION_2024Q4'IDENTIFIED EXTERNALLYWITH BACKUPFORCE KEYSTORECONTAINER=ALL;
Step 3: Post-Rotation Verification
SQL — Post-Rotation Audit Verification
-- Verify new MEK is active (activation_time should be NOW)SELECTkey_id,creator,creation_time,activation_time,tag-- Shows your USING TAG value — key audit linkFROMv$encryption_keysWHEREactivation_time=(SELECT MAX(activation_time)FROMv$encryption_keys);-- Verify previous MEK is now RETIRED (not ACTIVE)SELECTkey_id,activation_time,retired_time,tagFROMv$encryption_keysORDER BYactivation_timeDESC;-- Confirm fully_backed_up = YES after rotationSELECTstatus,wallet_type,fully_backed_upFROMv$encryption_wallet;-- Check all tablespaces still encrypted (no regressions)SELECTtablespace_name,encrypted,encryption_algorithmFROMv$encrypted_tablespaces;
Tablespace REKEY (TEK Rotation)
TEK rotation re-encrypts every data block. Use for post-breach remediation, algorithm upgrades, or ultra-strict compliance postures. Oracle 26ai makes this online.
SQL — Online Tablespace REKEY (Oracle 26ai)
-- Online REKEY — tablespace stays accessible during operationALTER TABLESPACEUSERSENCRYPTION ONLINEUSING'AES256'REKEY;-- Monitor REKEY progressSELECTtablespace_name,encryption_algorithm,rekey_status,-- IN_PROGRESS / COMPLETED / FAILEDpct_rekeyed,-- Percentage completelast_rekey_timeFROMv$encrypted_tablespacesWHERErekey_statusIS NOT NULL;-- Using DBMS_SPACE_ADMIN for programmatic REKEY with DG propagationEXECDBMS_SPACE_ADMIN.TABLESPACE_REKEY(tablespace_name=>'USERS',encrypt_algo=>DBMS_SPACE_ADMIN.ENCRYPT_AES256,online_mode=>TRUE,dg_propagate=>TRUE-- Auto-propagate to Standbys);
Compliance Automation — Scripting Key Rotation
Manual key rotation is error-prone and audit-risky. The gold standard is an automated rotation pipeline triggered by a scheduler (DBMS_SCHEDULER, cron, or OEM) with built-in pre/post checks and audit logging.
🔄 Automated Key Rotation Pipeline
1. Trigger
DBMS_SCHEDULER / cron
Scheduled
→
2. Pre-Check
Keystore OPEN? DG sync OK?
→
3. Backup
OS wallet backup
→
4. Rotate MEK
SET KEY with TAG
8. Notify
Email / Slack / ITSM
Compliance
←
7. Audit Log
Write to audit table
←
6. DG Sync
Standby verification
←
5. Verify
New key active? Keys intact?
Automated Rotation Procedure — PL/SQL
PL/SQL — Complete Automated Rotation Procedure
-- ═══════════════════════════════════════════════════════════
-- CREATE AUDIT TABLE (run once)
-- ═══════════════════════════════════════════════════════════CREATE TABLEdba_tde_rotation_log(log_idNUMBERGENERATED ALWAYS AS IDENTITY,rotation_dateDATEDEFAULT SYSDATE,rotation_typeVARCHAR2(20),-- MEK / TEK / CDB_MEKcompliance_tagVARCHAR2(100),old_key_idVARCHAR2(100),new_key_idVARCHAR2(100),rotated_byVARCHAR2(50)DEFAULTSYS_CONTEXT('USERENV','OS_USER'),statusVARCHAR2(20),-- SUCCESS / FAILEDerror_msgVARCHAR2(4000),CONSTRAINTpk_tde_logPRIMARY KEY(log_id));-- ═══════════════════════════════════════════════════════════
-- AUTOMATED ROTATION PROCEDURE
-- ═══════════════════════════════════════════════════════════CREATE OR REPLACE PROCEDUREsp_tde_rotate_mek(p_wallet_pwdINVARCHAR2,p_compliance_tagINVARCHAR2DEFAULT'SCHEDULED_ROTATION',p_cdb_wideINBOOLEANDEFAULTFALSE)ASv_old_key_idVARCHAR2(100);v_new_key_idVARCHAR2(100);v_wallet_openVARCHAR2(10);v_sqlVARCHAR2(4000);BEGIN-- Pre-check: verify keystore is openSELECTstatusINTOv_wallet_openFROMv$encryption_walletWHEREROWNUM=1;IFv_wallet_openNOT IN('OPEN','OPEN_NO_MASTER_KEY')THENRAISE_APPLICATION_ERROR(-20001,'Keystore not open. Status: '||v_wallet_open);END IF;-- Capture current (old) key IDSELECTkey_idINTOv_old_key_idFROMv$encryption_keysWHEREactivation_time=(SELECT MAX(activation_time)FROMv$encryption_keys)ANDROWNUM=1;-- Build rotation SQL with compliance tagIFp_cdb_wideTHENv_sql:='ADMINISTER KEY MANAGEMENT SET KEY '||'USING TAG '''||p_compliance_tag||''' '||'IDENTIFIED BY "'||p_wallet_pwd||'" '||'WITH BACKUP FORCE KEYSTORE CONTAINER=ALL';ELSEv_sql:='ADMINISTER KEY MANAGEMENT SET KEY '||'USING TAG '''||p_compliance_tag||''' '||'IDENTIFIED BY "'||p_wallet_pwd||'" '||'WITH BACKUP FORCE KEYSTORE';END IF;-- Execute the rotationEXECUTE IMMEDIATEv_sql;-- Capture new key IDSELECTkey_idINTOv_new_key_idFROMv$encryption_keysWHEREactivation_time=(SELECT MAX(activation_time)FROMv$encryption_keys)ANDROWNUM=1;-- Write audit log entryINSERT INTOdba_tde_rotation_log(rotation_type,compliance_tag,old_key_id,new_key_id,status)VALUES(CASE WHENp_cdb_wideTHEN'CDB_MEK'ELSE'MEK'END,p_compliance_tag,v_old_key_id,v_new_key_id,'SUCCESS');COMMIT;EXCEPTIONWHEN OTHERS THENINSERT INTOdba_tde_rotation_log(rotation_type,compliance_tag,old_key_id,status,error_msg)VALUES('MEK',p_compliance_tag,v_old_key_id,'FAILED',SQLERRM);COMMIT;RAISE;ENDsp_tde_rotate_mek;/
DBMS_SCHEDULER — Scheduling Automated Rotation
SQL — Schedule Annual Rotation Job (PCI-DSS)
-- Schedule annual MEK rotation — PCI-DSS requirement (rotate at least yearly)BEGINDBMS_SCHEDULER.CREATE_JOB(job_name=>'TDE_MEK_ANNUAL_ROTATION',job_type=>'STORED_PROCEDURE',job_action=>'sp_tde_rotate_mek',number_of_arguments=>3,start_date=>SYSTIMESTAMP,repeat_interval=>'FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=15;BYHOUR=2;BYMINUTE=0',enabled=>FALSE,comments=>'Annual TDE MEK rotation — PCI-DSS Req 3.6.x compliance');DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(job_name=>'TDE_MEK_ANNUAL_ROTATION',argument_position=>1,argument_value=>'WalletPassword@2024'-- Use OKV to avoid plaintext!);DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(job_name=>'TDE_MEK_ANNUAL_ROTATION',argument_position=>2,argument_value=>'PCI_DSS_ANNUAL_ROTATION');DBMS_SCHEDULER.ENABLE('TDE_MEK_ANNUAL_ROTATION');END;/-- Verify job scheduled correctlySELECTjob_name,state,next_run_date,repeat_interval,commentsFROMdba_scheduler_jobsWHEREjob_nameLIKE'TDE%';
Data Guard — Key Rotation Propagation
SQL — Post-Rotation Standby Verification
-- After MEK rotation on Primary — verify Standby keystore sync-- Run on PRIMARY:SELECTdest_id,db_unique_name,tde_keystore_status,-- OPEN = Standby can decrypt new redostatus,gap_statusFROMv$archive_dest_statusWHEREstatus='VALID';-- Run on STANDBY — confirm same MEK is activeSELECTkey_id,activation_time,tagFROMv$encryption_keysWHEREactivation_time=(SELECT MAX(activation_time)FROMv$encryption_keys);-- For Software Keystore: copy updated wallet to Standby after rotation-- scp $WALLET_ROOT/tde/ewallet.p12 oracle@standby:$WALLET_ROOT/tde/
-- scp $WALLET_ROOT/tde/cwallet.sso oracle@standby:$WALLET_ROOT/tde/
-- Then on Standby: ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY "pwd";
Audit Queries — Compliance Reporting
SQL — Compliance Audit Report Queries
-- Complete key rotation history with age calculationSELECTkey_id,tagcompliance_tag,creation_time,activation_time,COALESCE(retired_time,SYSDATE)retired_or_now,ROUND(COALESCE(retired_time,SYSDATE)-activation_time)days_active,CASE WHENretired_timeIS NULLTHEN'ACTIVE'ELSE'RETIRED'ENDkey_state,-- Flag keys exceeding PCI 365-day limitCASE WHENretired_timeIS NULLANDSYSDATE-activation_time>365THEN'⚠ OVERDUE'ELSE'OK'ENDpci_complianceFROMv$encryption_keysORDER BYactivation_timeDESC;-- Rotation log for last 12 months (from audit table)SELECTrotation_date,rotation_type,compliance_tag,old_key_id,new_key_id,rotated_by,statusFROMdba_tde_rotation_logWHERErotation_date>=ADD_MONTHS(SYSDATE,-12)ORDER BYrotation_dateDESC;
Best Practices Summary
#
Best Practice
Compliance Driver
Priority
1
Tag every rotation with USING TAG for audit trail
PCI-DSS, SOX, GDPR
Critical
2
Use WITH BACKUP on every rotation — creates keystore snapshot
All frameworks
Critical
3
Automate via DBMS_SCHEDULER — eliminate manual rotation risk
SOX, ISO 27001
High
4
Use OKV for enterprise — no plaintext passwords in scheduler
All frameworks
High
5
Rotate MEK at least annually; consider quarterly for PCI
PCI-DSS Req 3.6
High
6
Sync wallet to ALL Standbys immediately after rotation
Availability SLA
Medium
7
Monitor V$ENCRYPTION_KEYS with alerting for overdue keys
All frameworks
Medium
8
Separate rotation privilege — use SYSKM, not SYSDBA
The Complete DBA Guide to Oracle Cursor Sharing, Hard Parsing & Library Cache
Introduction — The Hard Parsing Crisis Most
DBAs Don't See Coming
Hard parsing is one of Oracle's
most insidious performance problems. Unlike a slow query — which is visible in
AWR, in execution plans, in wait events — hard parsing hides in aggregate
statistics that look harmless individually but represent catastrophic waste at
scale. A Java application making 50,000 database calls per minute, each with a
slightly different literal in the WHERE clause, generates 50,000 hard parses
per minute. Each hard parse acquires multiple latches, consumes CPU, allocates
shared pool memory, and builds an execution plan from scratch. At 50,000 hard
parses per minute, the database can spend 40% of its CPU budget on work that
produces no business value.
CURSOR_SHARING is Oracle's
server-side workaround for this problem — a parameter that controls when and
how the database shares SQL cursors between statements that are logically
identical but textually different due to literal values. Understanding exactly
what EXACT, FORCE, and SIMILAR do — and the subtle but critical differences
between them — is essential knowledge for any Oracle DBA.
⚡THE HARD PARSE
PROBLEM IN NUMBERS:
Enterprise OLTP
database, Java application WITHOUT bind variables:
Hard parses per
second:2,847
CPU wasted on hard
parsing: ~38% of total database CPU
Shared pool
allocations:2,847 new child cursors
per second
Shared pool
fragmentation:Library cache fills in
~4 hours
This is the
environment where CURSOR_SHARING=FORCE is not optional — it is emergency
medicine.
Background — How Oracle Parses SQL: The Full
Pipeline
To understand CURSOR_SHARING, you
must first understand what Oracle does every time it receives a SQL statement.
The parsing pipeline has multiple stages, and CURSOR_SHARING intervenes at a
very specific point in that pipeline.
Parse Stage
Description
Cost
When Occurs
Syntax Check
Is the SQL
grammatically correct Oracle SQL?
Trivial —
microseconds
Every parse
Semantic Check
Do the
referenced objects and columns exist? Does the user have privileges?
Low — data
dictionary lookup
Every parse
(soft or hard)
Shared Pool
Lookup
Is there an
existing cursor in the library cache with identical SQL text?
Low — hash
lookup
Every parse —
this is where CURSOR_SHARING intervenes
Hard Parse (if
no match)
Build
execution plan from scratch: statistics lookup, optimizer analysis, plan
generation, compile
High —
milliseconds to seconds. Acquires latch
Only when
Shared Pool Lookup finds no match
Soft Parse (if
match)
Validate the
cached cursor is still usable (objects not changed)
Very low —
microseconds
When Shared
Pool Lookup succeeds
Execute
Actually run
the query using the parsed and compiled plan
Query-dependent
After any
parse
The key insight: CURSOR_SHARING
modifies the SQL text BEFORE the Shared Pool Lookup step. By replacing literal
values with bind variable placeholders in the SQL text, CURSOR_SHARING makes
textually different statements look identical to the shared pool — enabling
cursor reuse and eliminating the hard parse.
💡 Library Cache
vs Shared Pool:
Shared Pool = memory
area in the SGA containing the Library Cache and Data Dictionary Cache
Library Cache = the
section of Shared Pool that stores parsed SQL and PL/SQL code
Library Cache Latch =
the synchronisation mechanism that protects Library Cache access
Hard Parse = acquires
Library Cache Latch for an extended period (contention under high
concurrency)
Soft Parse = briefly
checks Library Cache — much shorter latch hold time
⚖ CURSOR_SHARING = EXACT [ THE
DEFAULT — PURE CORRECTNESS ]
CURSOR_SHARING = EXACT — The Default Setting
CURSOR_SHARING=EXACT is the Oracle
default. With EXACT, Oracle shares a cursor only when the SQL text being
submitted is byte-for-byte identical to an existing cursor in the library cache
— including identical whitespace, identical case, identical literal values, and
identical comment text. If even one character differs, Oracle treats it as a
completely new SQL statement and performs a full hard parse.
How EXACT Works — Step by Step
With CURSOR_SHARING=EXACT, the
parsing pipeline is unchanged. Oracle computes a hash of the exact SQL text and
looks it up in the library cache. Only an exact hash match results in a soft
parse and cursor reuse.
•Applications
that already use bind variables consistently — EXACT provides optimal
performance and plan stability.
•Databases
where data distribution is highly skewed — EXACT allows the optimizer to
generate column-value-specific plans for different literals.
•Systems
where SQL is generated programmatically and literals represent meaningful data
ranges — the optimizer should generate different plans for different values.
•New
application development — forces developers to write correct,
bind-variable-aware SQL from the start.
When EXACT Becomes a Problem
EXACT becomes catastrophically
harmful when used with applications that generate literal-embedded SQL — which
is the overwhelming majority of legacy Java, PHP, Ruby, and .NET applications
written before bind variable awareness was standard practice. Every variation
of the literal becomes a separate cursor, and the library cache fills with
thousands of nearly-identical SQL statements that differ only in the literal
value.
-- Detecting the hard parse problem (run this when DB is slow):
SELECT stat.name, stat.value
FROM v$sysstat stat
WHERE stat.name IN
('parse count (hard)',
'parse count (total)',
'parse count (failures)',
'execute count',
'session cursor cache hits')
ORDER BY stat.name;
-- KEY RATIO: hard_parses / total_parses
-- < 1% : healthy
-- 1-10% : moderate concern — investigate top literal SQL
-- > 10% : serious problem — CURSOR_SHARING=FORCE is needed
-- > 30% : crisis — immediate action required
-- Find the worst offending literal SQL (under EXACT)
If your hard parse
ratio is > 5%, investigate immediately.
The root cause is
almost always literal SQL from an application layer.
⚖ CURSOR_SHARING = FORCE [ THE
EMERGENCY LEVER — MAX SHARING ]
CURSOR_SHARING = FORCE — Maximum Cursor
Sharing
CURSOR_SHARING=FORCE is Oracle's
most aggressive cursor sharing mode. When set to FORCE, Oracle intercepts every
SQL statement before the shared pool lookup and replaces all literal values
(numbers, strings, dates) with system-generated bind variable placeholders
(:SYS_B_0, :SYS_B_1, etc.). The SQL text that reaches the shared pool is
therefore the same regardless of the literal values in the original statement —
enabling full cursor sharing across all variations.
How FORCE Works — The Literal Substitution Mechanism
The substitution happens
transparently, below the application layer. The application sends a SQL with
literals. Oracle intercepts it, replaces the literals with bind variable
placeholders, computes a hash of the modified SQL text, and performs the library
cache lookup. The application never knows this happened — it receives the
correct result regardless.
-- Application sends these three 'different' statements:
SELECT employee_id, salary FROM employees WHERE department_id =
10;
SELECT employee_id, salary FROM employees WHERE department_id =
20;
SELECT employee_id, salary FROM employees WHERE department_id =
30;
-- Oracle internally rewrites each to:
-- SELECT employee_id, salary FROM employees
-- WHERE department_id =
:SYS_B_0
-- (with :SYS_B_0 = 10, then 20, then 30)
-- Check library cache: ONE cursor for all three!
SELECT sql_text,
parse_calls,
executions,
loads,
version_count
FROM v$sql
WHERE sql_text LIKE
'%employees%SYS_B%'
AND sql_text NOT LIKE '%v$sql%';
-- Result: 1 cursor with loads=1 (hard parsed ONCE)
-- parse_calls=3,
executions=3, version_count=1
-- Monitor the impact on hard parses:
SELECT stat.name, stat.value
FROM v$sysstat stat
WHERE stat.name IN
('parse count (hard)', 'parse count (total)');
-- Check library cache hit ratio (should improve dramatically):
SELECT ROUND(
(SUM(pinhits) /
NULLIF(SUM(pins), 0)) * 100, 2
) AS library_cache_hit_pct
FROM v$librarycache
WHERE
namespace = 'SQL AREA';
The Version Count Problem Under FORCE
CURSOR_SHARING=FORCE introduces a
subtle but important phenomenon: child cursor versioning. When Oracle creates a
shared cursor with FORCE, it creates a PARENT cursor (the literal-substituted
SQL text) and potentially multiple CHILD cursors (different versions of the
execution plan). Child cursors are created when the same parent SQL needs
different plans — for example, when different sessions use different optimizer
settings, different NLS parameters, or when the bind variable values happen to
require genuinely different plans due to bind variable peeking.
-- Check version count on cursors (flag if > 20)
SELECT sql_id,
version_count,
parse_calls,
executions,
SUBSTR(sql_text, 1,
80) sql_preview
FROM v$sqlarea
WHERE version_count >
5
ORDER BY version_count
DESC
FETCH FIRST 10 ROWS ONLY;
-- Investigate why multiple children exist:
SELECT sql_id,
child_number,
reason -- shows WHY a new child was created
FROM v$sql_shared_cursor
WHERE sql_id =
'&problem_sql_id'
ORDER BY child_number;
-- Common reasons for new children:
-- BIND_MISMATCH:
Bind type/length changed
-- OPTIMIZER_MISMATCH:
Different optimizer settings in sessions
-- NLS_MISMATCH:
Different NLS character settings
--
ROLL_INVALID_MISMATCH: Statistics changed, plan invalidated
The Bind Variable Peeking Risk Under FORCE
This is the most important risk
with CURSOR_SHARING=FORCE. When the first execution of a literal-substituted
query runs, Oracle peeks at the bind variable value and generates an execution
plan optimised for that specific value. All subsequent executions reuse that
plan — even if they have completely different bind values that would benefit
from a different plan.
Example: first execution has
department_id=50 (1 employee). Oracle generates an index range scan plan.
Second execution has department_id=1 (50,000 employees). Oracle reuses the
index range scan plan — which is now suboptimal. A full table scan or parallel
query would be better. With EXACT and literals, Oracle could have generated the
correct plan for each value. With FORCE and bind peeking, one plan is frozen
for all.
🔴 CRITICAL:
Bind Variable Peeking + FORCE = Potential Plan Instability
The plan frozen on
first execution may be catastrophically wrong for subsequent values.
Mitigation options:
1. Adaptive Cursor
Sharing (ACS) — Oracle 11g+ detects when bind values cause plan issues
2. SQL Plan
Management (SPM) — lock known-good plans
3.
CURSOR_INVALIDATION=IMMEDIATE — invalidate cursors when statistics change
4. Ensure
STATISTICS_LEVEL = TYPICAL or ALL (enables ACS)
⚖ CURSOR_SHARING = SIMILAR [
DEPRECATED — AVOID IN PRODUCTION ]
CURSOR_SHARING = SIMILAR — The Deprecated
Middle Ground
CURSOR_SHARING=SIMILAR was
Oracle's attempt at a 'smart' version of FORCE — sharing cursors when the
optimizer determines the plan would be the same regardless of the literal
value, but generating separate plans (not sharing) when the optimizer detects that
different literal values would benefit from different plans (e.g., due to
histograms showing data skew).
The intent was elegant: get most
of FORCE's sharing benefits without the plan quality risk. The reality was far
less elegant: SIMILAR introduced complex, unpredictable behaviour, poor
performance in edge cases, and bugs that were difficult to diagnose. Oracle
deprecated SIMILAR in Oracle Database 12c and strongly recommends against its
use.
How SIMILAR Works — and Why It's Complicated
With SIMILAR, Oracle replaces
literals with bind variable placeholders (like FORCE) but then checks whether
the optimizer considers the literal 'safe to share'. Safety is determined by
examining whether column histograms exist and whether they show that different
values would produce different plans. If the optimizer decides sharing is safe,
the cursor is shared. If not, a separate child cursor is created for this
literal value combination.
-- Oracle evaluates whether each literal is 'unsafe to share'
-- based on the presence of histograms on the filtered column.
-- Scenario A: No histogram on department_id
-- → Oracle treats as FORCE → creates one shared cursor
SELECT * FROM employees WHERE department_id = 10;
SELECT * FROM employees WHERE department_id = 20;
-- Result: 1 cursor (same as FORCE behaviour)
-- Scenario B: Histogram EXISTS on department_id
-- (because data is skewed — most employees in dept 10)
-- → Oracle creates SEPARATE cursors for each literal
SELECT * FROM employees WHERE department_id = 10;
SELECT * FROM employees WHERE department_id = 99;
-- Result: 2 cursors (different plans for different skews)
-- The problem: you get SIMILAR's complexity WITH FORCE's risks
-- Unpredictable: you can't easily tell which mode it's using
-- for any given query without running it and checking v$sql
-- IMPORTANT: SIMILAR is DEPRECATED in 12c+
-- Oracle documentation states:
-- 'The SIMILAR setting has been deprecated.'
--
'Oracle recommends using FORCE instead.'
Why SIMILAR Was Retired
•Unpredictable
cursor proliferation: Under some workload patterns, SIMILAR generates MORE
child cursors than EXACT, defeating its own purpose.
•Poor
interaction with Adaptive Cursor Sharing: ACS (introduced in 11g) provides the
'smart sharing' behaviour that SIMILAR attempted, but does it correctly.
SIMILAR and ACS conflict.
•Complex
latch behaviour: The additional logic required to evaluate histogram safety
introduces more shared pool latch activity than FORCE.
•Diagnostic
complexity: When SIMILAR is set, diagnosing performance problems requires
understanding which mode each cursor used — adding a layer of complexity that
most DBAs find unmanageable.
•Oracle
support burden: SIMILAR generated a disproportionate number of Oracle Support
bugs and MOS (My Oracle Support) service requests.
🔴 VERDICT: DO
NOT USE CURSOR_SHARING = SIMILAR
It is deprecated in
Oracle 12c and later versions.
It provides no
benefits over FORCE that Adaptive Cursor Sharing (ACS) does not provide
better.
If you are currently
using SIMILAR: migrate to FORCE immediately.
If you are on 12c or
later: ACS handles the plan quality concern automatically.
Head-to-Head: EXACT vs FORCE vs SIMILAR —
Decision Matrix
Criterion
EXACT
FORCE
SIMILAR
Default value?
YES — Oracle
default
No — must be
set explicitly
No — must be
set explicitly
Hard parse
reduction
None (requires
bind vars in app)
Dramatic
(95–99% reduction possible)
High — but
unpredictable
Shared Pool
memory usage
High — one
cursor per literal variation
Low — one
cursor for all literal variations
Variable —
depends on histograms
Library cache
latch contention
High — if app
uses literals
Low — fewer
hard parses = fewer latch acquisitions
Complex — more
latch activity than FORCE
Execution plan
quality
Optimal —
different plans for different values
Risk — one
plan for all values (bind peeking)
Variable —
histogram-dependent
Interaction
with ACS (11g+)
Full ACS
support
Full ACS
support — ACS mitigates bind peeking risk
Conflicts with
ACS behaviour
Interaction
with histograms
Full histogram
benefit — literal-specific plans
Bind peeking
sees first execution value
Attempts to
use histograms — unpredictably
Dynamic SQL
support
Works
correctly
Works —
rewrites dynamic SQL literals too
Works — same
rewrite mechanism
Diagnostic
ease
Easy — each
literal is its own cursor
Moderate —
SYS_B_N visible in v$sql
Hard —
unpredictable sharing decisions
Oracle
recommendation
Preferred when
app uses bind variables
Use when app
cannot use bind variables
DEPRECATED —
do not use
Version
availability
All Oracle
versions
All Oracle
versions
Deprecated
from 12c — avoid all versions
SQL_ID
consistency
Consistent —
same SQL = same ID
Consistent —
rewritten SQL = consistent ID
Inconsistent —
ID depends on sharing decision
Practical Diagnostics — Detecting and
Resolving Hard Parse Problems
Legacy app,
immediate production crisis (hard parse >30%)
FORCE at
session/system level immediately
Emergency
medicine. Apply now, optimise later.
Reporting
database, one execution per SQL
EXACT
Reports run
once with specific parameters. No benefit from sharing. Avoid bind peeking.
Mixed OLTP +
analytics workload
FORCE + ACS
enabled
FORCE for
OLTP, ACS prevents plan degradation for analytics.
Currently
running SIMILAR
FORCE (migrate
immediately)
SIMILAR is
deprecated. FORCE + ACS provides superior and predictable behaviour.
Exadata /
In-Memory database
EXACT (prefer
bind vars in app)
Advanced
hardware reduces hard parse cost. Plan quality is paramount.
Oracle 12c+
with ACS enabled
FORCE (ACS
mitigates bind risk)
ACS in 12c+
makes FORCE significantly safer than in earlier releases.
Adaptive Cursor Sharing (ACS) — The Modern
Complement to FORCE
Adaptive Cursor Sharing (ACS),
introduced in Oracle 11g, is the mechanism that makes CURSOR_SHARING=FORCE safe
for production use in modern Oracle databases. ACS monitors the execution
statistics of shared cursors and detects when a bind variable value is
producing a suboptimal plan. When it detects this, it marks the cursor as 'bind
sensitive' and allows Oracle to generate an additional child cursor optimised
for that value range — all transparently and automatically.
-- Check if Adaptive Cursor Sharing is active
SELECT is_bind_sensitive, is_bind_aware,
is_shareable,
child_number,
SUBSTR(sql_text, 1,
60) sql_preview
FROM v$sql
WHERE sql_text LIKE
'%SYS_B_%'
AND sql_text NOT LIKE '%v$sql%'
ORDER BY child_number;
-- is_bind_sensitive = Y: Oracle is monitoring this cursor
-- is_bind_aware = Y:
Oracle has detected bind value variation
-- is_shareable = Y:
Cursor can still be reused
-- Check ACS execution history
SELECT bind_set_hash_value,
plan_hash_value,
executions,
rows_processed,
cpu_time,
elapsed_time
FROM v$sql_cs_statistics
WHERE sql_id =
'&problem_sql_id';
-- Enable ACS prerequisites
ALTER SYSTEM SET STATISTICS_LEVEL = TYPICAL SCOPE=BOTH;
--
(ACS requires TYPICAL or ALL statistics level)
Best Practices Summary — The CURSOR_SHARING
Decision Framework
CURSOR_SHARING is not a
performance silver bullet — it is a targeted solution for a specific problem
(literal SQL from applications that cannot use bind variables). Applied
correctly, it is one of the most impactful single-parameter changes a DBA can
make to a suffering system. Applied incorrectly, it trades one set of problems
for another.
1.Long-term
fix is always application-level bind variables. CURSOR_SHARING is a workaround,
not a solution. The only permanent fix for hard parsing is application code
that uses bind variables (PreparedStatement in Java, parameterized queries in
.NET, bind variables in PL/SQL).
2.On Oracle
11g+: Enable ACS (STATISTICS_LEVEL=TYPICAL) before setting FORCE. ACS makes
FORCE safe.
3.Monitor
version_count. If any cursor exceeds 100 child versions, investigate
v$sql_shared_cursor immediately. Excessive versioning indicates FORCE is
causing more overhead than it saves.
4.Test at
session level first. Before applying system-wide, test CURSOR_SHARING=FORCE in
a session and validate both the hard parse reduction and query plan quality.
5.Never use
SIMILAR in Oracle 12c+. Migrate any SIMILAR setting to FORCE immediately.
6.Use
CURSOR_SHARING_EXACT hint for critical queries. For queries where plan quality
is critical and bind peeking is a concern, use /*+ CURSOR_SHARING_EXACT */ to
exempt that query from FORCE substitution.
7.Set at
appropriate scope. SCOPE=BOTH applies immediately to running instance and
persists after restart. SCOPE=MEMORY applies immediately but reverts after
restart (useful for testing).