实验:创建加密表空间,并插入测试数据
一:查看现有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",共同学习,共同成长!!!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。