This example starts by creating a database protected by a software wallet. If you already have a database protected by a software wallet, you can skip this section.
-
Create a wallet directory in the C:\oracle\admin\ORCLDB\WALLET directory, e.g., wallet.
-
Log in to the database instance as a user granted the SYSDBA administrative privilege.
SQL> connect / as sysdba
-
Set the WALLET_ROOT parameter.
SQL> alter system set wallet_root='<path to the oracle wallet directory>' scope=spfile
-
Shut down and start up the database.
SQL> shutdown immediate;
SQL> startup;
-
Set the TDE_CONFIGURATION parameter.
SQL> alter system set TDE_CONFIGURATION="KEYSTORE_CONFIGURATION=FILE" SCOPE=both ;
-
Grant the ADMINISTER KEY MANAGEMENT or SYSKM privilege to SYSTEM and any user you want.
SQL> grant ADMINISTER KEY MANAGEMENT to system;
SQL> commit;
-
Connect to the database as a system user.
SQL> connect system/<password>
-
Run the ADMINISTER KEY MANAGEMENT SQL statement to create the keystore.
SQL> ADMINISTER KEY MANAGEMENT CREATE KEYSTORE IDENTIFIED BY <software_keystore_password>;
-
Run the ADMINISTER KEY MANAGEMENT SQL statement to open the software-based keystore.
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY <software_keystore_password >;
-
Set the Master Encryption Key in the software keystore.
SQL> ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY <software_keystore_password > WITH BACKUP USING 'backupdb';
-
Create a SCIENTISTS table in the DB.
SQL> create table SCIENTISTS (SCID NUMBER(4), FirstName VARCHAR2(128), LastName VARCHAR2(128), Salary NUMBER(6));
-
Add data to the SCIENTISTS table.
SQL> insert into SCIENTISTS values (0001, 'Albert', 'Einstein', 850000);
SQL> insert into SCIENTISTS values (0002, 'Isaac', 'Newton', 750000);
SQL> insert into SCIENTISTS values (0003, 'Charles', 'Darwin', 650000);
SQL> insert INTO SCIENTISTS values (0004, 'Curie', 'Einstein', 550000);
SQL> commit;
-
Verify the added data in the SCIENTISTS table.
SQL> select * from SCIENTISTS;
-
Encrypt the 'Salary' column from SCIENTISTS.
SQL> alter table SCIENTISTS modify (Salary ENCRYPT);
-
The Transparent Data Encryption decrypts the encrypted column automatically and returns the data in clear format.
SQL> select salary from SCIENTISTS;
-
Verify the column is encrypted in your DB.
SQL> select * from DBA_ENCRYPTED_COLUMNS;
-
View the information of the software keystore.
SQL> select * from V$ENCRYPTION_WALLET;
-
Create an encrypted tablespace.
SQL> create tablespace SECURETS DATAFILE 'C:/Oraclenew/oradata/ORCLNEW/SECURETDB_01.DBF' SIZE 10M ENCRYPTION USING 'AES256' ENCRYPT;
-
Create the EMP table inside the SECURETS tablespace.
SQL> create table EMP (EMPID NUMBER(4),NAME VARCHAR(100),SALARY NUMBER(6)) tablespace SECURETS;
-
Add data to the EMP table.
SQL> insert into EMP values (0001, 'Michael Jackson', 999999);
SQL> insert into EMP values (0002, 'Lady Gaga', 888888);
SQL> insert into EMP values (0003, 'Freddie Mercury', 777777);
SQL> insert into EMP values (0004, 'Steven Tyler', 666666);
SQL> commit;
-
View the data from the EMP table.
SQL> select * from EMP;
-
Close the software keystore.
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE CLOSE IDENTIFIED BY <software_keystore_password>;
-
Now, try to view the contents of the EMP table.
SQL> select * from EMP;
As the keystore is closed, you will get an error message “ORA-28365: wallet is not open” and hence you cannot view the data from the EMP table.
-
Open the Keystore.
SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY < software_keystore_password >;
-
Now, view the data from the EMP table.
SQL> select * from EMP;
-
List all Key IDs.
SQL> select KEY_ID from V$ENCRYPTION_KEYS;