############################################################
表空间自包含通过测试场景理解
在基于xtts或者TSPITR进行操作时需要检查数据库表空间自包含情况,现通过2个测试场景理解自包含的定义。
自包含场景测试
1、查看当前用户以及默认表空间
SQL> show user
USER is "ADMIN"
SQL> select username,default_tablespace from dba_users where username='ADMIN';
USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
ADMIN ADMIN
1234567
2、在默认表空间下创建表admin,无索引
SQL> creat table admin tablespace admin as select * from dba_users;
1
3、查看自包含
SQL> execute DBMS_TTS.TRANSPORT_SET_CHECK('ADMIN',TRUE);
SQL> SELECT * from sys.transport_set_violations;
no rows selected
无返回值,表空间admin为完全自包含
123456789
非自包含场景测试
1、创建表tbs以及索引,使用2个独立的表空间
表tbs---->表空间tbs
SQL> create table tbs tablespace tbs as select * from dba_users;
表tbs索引---->表空间tbs_index
SQL> create index idx_name on tbs(username) tablespace tbs_index;
1234567
2、TBS表空间自包含情况
SQL> execute DBMS_TTS.TRANSPORT_SET_CHECK('TBS',TRUE);
PL/SQL procedure successfully completed.
SQL> SELECT * from sys.transport_set_violations;
no rows selected
结果:自包含
123456789
3、TBS_INDEX表空间自包含情况
SQL> execute DBMS_TTS.TRANSPORT_SET_CHECK('TBS_INDEX',TRUE);
SQL> SELECT * from sys.transport_set_violations;
VIOLATIONS
-----------------------------------------------------------------------
ORA-39907: Index ADMIN.IDX_NAME in tablespace TBS_INDEX points to table ADMIN.TBS in tablespace TBS.
结果:非自包含
123456789
结论:
自包含:当前表空间集中的对象可以脱离其他表空间对象,如上表对象可以独立存在
非自包含:当前表空间中的对象不能完全独立于其他表空间,如上索引不能脱离表对象
---------------------
作者:iverycd 来源:CSDN 原文:https://blog.csdn.net/kiral07/article/details/88236565