Oracle Encrypted Tablespaces

chenoracle發表於2017-07-12
Oracle Encrypted Tablespaces


實驗:建立加密表空間,並插入測試資料

一:檢視現有wallet
SQL>  select * from v$encryption_wallet;
WRL_TYPE             WRL_PARAMETER                       STATUS
-------------------- ----------------------------------- ------------------
file                 /u01/app/oracle/admin/orcl/wallet   CLOSED

二:建立目錄
SQL> ho mkdir /u01/app/oracle/admin/orcl/wallet

三:建立加密KEY
SQL> alter system set encryption key identified by oracle;

四:檢視現有wallet狀態
SQL> select * from v$encryption_wallet;
WRL_TYPE             WRL_PARAMETER                       STATUS
-------------------- ----------------------------------- ------------------
file                 /u01/app/oracle/admin/orcl/wallet   OPEN

五:建立加密表空間
SQL> create tablespace test_encrypt datafile '/u01/app/oracle/oradata/orcl/test_encrypt01.dbf' size 10M encryption default storage(encrypt);
Tablespace created.

SQL> SELECT TABLESPACE_NAME, ENCRYPTED FROM DBA_TABLESPACES;

TABLESPACE_NAME                ENC
------------------------------ ---
SYSTEM                         NO
SYSAUX                         NO
UNDOTBS1                       NO
TEMP                           NO
USERS                          NO
TEST_ENCRYPT                   YES

6 rows selected.

SQL> SELECT NAME, ENCRYPTIONALG ENCRYPTEDTS
FROM V$ENCRYPTED_TABLESPACES, V$TABLESPACE
WHERE V$ENCRYPTED_TABLESPACES.TS# = V$TABLESPACE.TS#;  

NAME                           ENCRYPT
------------------------------ -------
TEST_ENCRYPT                   AES128

六:建立測試資料
SQL> create table t1(id number,name varchar2(20)) tablespace test_encrypt;
SQL> create table t2(id number,name varchar2(20)) tablespace users;

SQL> insert into t1 values(1,'a');
SQL> commit;
SQL> insert into t2 values(2,'b');
SQL> commit;

七:重啟資料庫後,錢包自動關閉,並且無法查詢加密表空間裡的資料
SQL> shutdown immediate
SQL> startup

SQL> select * from t1;
select * from t1
              *
ERROR at line 1:
ORA-28365: wallet is not open

---資料庫重啟後,錢包會自動關閉
SQL> select * from v$encryption_wallet;
WRL_TYPE             WRL_PARAMETER                       STATUS
-------------------- ----------------------------------- ------------------
file                 /u01/app/oracle/admin/orcl/wallet   CLOSED

八:開啟錢包
SQL> alter system set wallet open identified by oracle;
System altered.
---SQL> alter system set wallet close identified by oracle;(關閉錢包)

SQL> select * from t1;
        ID NAME
---------- --------------------
         1 a

九:將t2表移動到加密表空間中
SQL> alter table t2 move tablespace test_encrypt;
System altered.

歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!!

Oracle Encrypted Tablespaces

Oracle Encrypted Tablespaces



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2141957/,如需轉載,請註明出處,否則將追究法律責任。

相關文章