oracle 11g1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 SQL> alter pluggable database all open; Pluggable database altered. Elapsed: 00:00:19.03 SQL> SQL> select PDB_ID,PDB_NAME from dba_pdbs; PDB_ID PDB_NAME ---------- ---------------------------------------------------------------------------- 3 PDBORCL 2 PDB$SEED 4 KILLDB Elapsed: 00:00:00.01 SQL> select file_name ,bytes/1024/1024 from cdb_data_files where con_id=3; FILE_NAME BYTES/1024/1024 ---------------------------------------------------------------------- --------------- /oracle/oradata/orcl/pdborcl/system01.dbf 260 /oracle/oradata/orcl/pdborcl/sysaux01.dbf 620 /oracle/oradata/orcl/pdborcl/SAMPLE_SCHEMA_users01.dbf 5 /oracle/oradata/orcl/pdborcl/example01.dbf 323.125 Elapsed: 00:00:00.02 SQL> select file_name ,bytes/1024/1024 from cdb_data_files where con_id=4; FILE_NAME BYTES/1024/1024 ---------------------------------------------------------------------- --------------- /oracle/oradata/orcl/killdb/system01.dbf 250 /oracle/oradata/orcl/killdb/sysaux01.dbf 590 Elapsed: 00:00:00.04 SQL> select member from v$Logfile; MEMBER ------------------------------------------------------------ /oracle/oradata/orcl/redo03.log /oracle/oradata/orcl/redo02.log /oracle/oradata/orcl/redo01.log SQL> select name from v$controlfile; NAME ---------------------------------------------------------------------------------------- /oracle/oradata/orcl/control01.ctl /oracle/fast_recovery_area/orcl/control02.ctl
oracle 11g大家可以发现,我这里的orcl这个CDB中,有2个我自己创建的pdb。同时大家也可以发现,这2个pdb都有属于自己的system datafile,这说明了什么
?说明一个CDB中的每个pdb都属于自己的数据字典信息,换句话讲,一个CDB中的每个pdb的数据字典信息都是独立的,每个pdb就可以理解为一个单独的数据库,只不过这些pdb是共享的一个实例和redo,以及controlfile,undotbs. 如下,查询你会发现每个pdb的数据字典信息都不一致:
<%E5%AD%A6%E4%B9%A0%E7%B3%BB%E5%88%971-12c%E5%88%9D%E4%BD%93%E9%AA%8C.html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 SQL> alter pluggable database all open; Pluggable database altered. SQL> alter session set container=PDBORCL; Session altered. SQL> select count(1) from dba_objects; COUNT(1) ---------- 91517 SQL> alter session set container=killdb; Session altered. SQL> select count(1) from dba_objects; COUNT(1) ---------- 90761 oracle 11g这样设计有什么好处?显然好处之一就是便于进行迁移。同时我们也知道12c可以在线进行datafile 的move移动,先测试一把:
<%E5%AD%A6%E4%B9%A0%E7%B3%BB%E5%88%971-12c%E5%88%9D%E4%BD%93%E9%AA%8C.html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25SQL> alter database move datafile 12 to '/oracle/oradata/orcl/roger01.dbf'; Database altered. SQL> l 1* alter database move datafile 12 to '/oracle/oradata/orcl/roger01.dbf' SQL> select file#,name from v$datafile; FILE# NAME ---------- -------------------------------------------------------------------------------- 1 /oracle/oradata/orcl/system01.dbf 3 /oracle/oradata/orcl/sysaux01.dbf 4 /oracle/oradata/orcl/undotbs01.dbf 5 /oracle/oradata/orcl/pdbseed/system01.dbf 6 /oracle/oradata/orcl/users01.dbf 7 /oracle/oradata/orcl/pdbseed/sysaux01.dbf 8 /oracle/oradata/orcl/pdborcl/system01.dbf 9 /oracle/oradata/orcl/pdborcl/sysaux01.dbf 10 /oracle/oradata/orcl/pdborcl/SAMPLE_SCHEMA_users01.dbf 11 /oracle/oradata/orcl/pdborcl/example01.dbf 12 /oracle/oradata/orcl/roger01.dbf 13 /oracle/oradata/orcl/killdb/system01.dbf 14 /oracle/oradata/orcl/killdb/sysaux01.dbf 13 rows selected.
oracle 11g通过监控发可以发现move datafile的时候会出现type为MV的锁,mode是4,6. 换句话讲,在move的过程的中,该datafile的对象是可以进行访问的. 经测试发现在move datafile期间,该datafile上的对象是可以进行dml和select操作的,如下:
<%E5%AD%A6%E4%B9%A0%E7%B3%BB%E5%88%971-12c%E5%88%9D%E4%BD%93%E9%AA%8C.html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32---Session1 SQL> l 1* select segment_name,tablespace_name from dba_segments where segment_name='T' SQL> / SEGMENT_NAME TABLESPACE_NAME ------------------------------ ------------------------------ T USERS SQL> alter database move datafile 6 to '/oracle/oradata/orcl/killdb/users01.dbf'; Database altered. ----Session 2 SQL> delete from t where object_id < 1000; 996 rows deleted. SQL> delete from t where rownum < 10; 9 rows deleted. SQL> / 9 rows deleted. SQL> / 9 rows deleted. SQL> commit; Commit complete.
oracle 11g这里只列出delete的操作,其他操作就不列了.
阅读(2853) | 评论(0) | 转发(0) |