该系列专题为2018年4月OCP-052考题变革后的最新题库。题库为小麦苗解答,若解答有不对之处,可留言,也可联系小麦苗进行修改。
注:OCP-052最新题库完整详细解答版请联系小麦苗私聊。解题不易,请大家尊重原创。
QQ:646634621
QQ群:547200174、618766405
微信号:lhrbestxh
Q
题目
A. A database can contain multiple undo tablespaces.
B. A database instance stores undo data in the SYSTEM tablespace if no undo tablespace exists.
C. A database instance hangs if the SYSAUX tablespace becomes unavailable.
D. A database can contain only a single temporary tablespace.
E. A database with a locally managed SYSTEM tablespace can have dictionary-managed user tablespaces.
A
答案
Answer:AB
对于C选项,不会hang住。
对于D选项,一个数据库可以包含多个临时表空间。
对于E选项,如果系统表空间是基于本地管理的,那么无法创建基于数据字典管理的表空间。
表空间的管理方式:
字典管理:oracle 8i(不包括i),只存在一种表空间的管理模式,即字典管理表空间(DMT)。DMT是指oracle的空间分配或回收是通过数据库中的数据字典表来记录和管理的。用于管理的两个数据字典表分别是:UET$(used extents)和FET$(freeextents)。DMT的工作方式是:当建立一个新的段或者段在表空间时,oracle通过一系列的SQL语句来完成这个工作且和前面的两个字典表有关,在繁忙的系统中会造成竞争和等待(另一个DMT会带来的问题是空间碎片)。
本地管理(Locally Managed Tablespace,LMT):在创建表空间时,在9i的R2版本后成了默认的选项。LMT在表空间的数据文件头部加入了一个位图区域,在其中记录每个extent的使用状况。当extent被使用或者被释放,oracle会更新头部的记录来反映这个变化,不产生回滚信息。因为仅仅操作数据文件头部的几个数据块,不用操作数据字典,LMT比DMT要快,尤其是在繁忙的时候更明显。
需要注意的是,如果使用“CREATE DATABASE”命令创建数据库,且不显式的加“EXTENT MANAGEMENT LOCAL”子句时,那么在创建完数据库后,其SYSTEM表空间默认为字典管理的表空间。只有SYSTEM表空间为字典管理的表空间时,才可以创建基于字典管理的其它表空间。如果SYSTEM表空间是基于本地管理的,那么无法创建基于字典管理的表空间。
--查看表空间使用的管理方式:
SQL> select TABLESPACE_NAME,EXTENT_MANAGEMENT,BLOCK_SIZE,STATUS,CONTENTS,FORCE_LOGGING,BIGFILE from dba_tablespaces;
TABLESPACE_NAME EXTENT_MAN BLOCK_SIZE STATUS CONTENTS FOR BIG
------------------------------ ---------- ---------- --------- --------- --- ---
SYSTEM LOCAL 8192 ONLINE PERMANENT NO NO
UNDOTBS1 LOCAL 8192 ONLINE UNDO NO NO
SYSAUX LOCAL 8192 ONLINE PERMANENT NO NO
TEMP LOCAL 8192 ONLINE TEMPORARY NO NO
USERS LOCAL 8192 ONLINE PERMANENT NO NO
EXAMPLE LOCAL 8192 ONLINE PERMANENT NO NO
TBS1 LOCAL 8192 ONLINE PERMANENT NO NO
--DMT 和LMT 的相互转换
--将字典管理的表空间转换为本地管理
exec dbms_space_admin.tablespace_migrate_to_local('表空间名')--表空间名用大写
--将本地管理的表空间转换为字典管理
exec dbms_space_admin.tablespace_migrate_from_local('表空间名')
SYS@ora11g > create tablespace test_dic datafile '/u01/app/oracle/oradata/ora11g/test_dic01.dbf' size 10m extent management directory;
create tablespace test_dic datafile '/u01/app/oracle/oradata/ora11g/test_dic01.dbf' size 10m extent management directory
*
ERROR at line 1:
ORA-25141: invalid EXTENT MANAGEMENT clause
SYS@ora11g > create tablespace test_dic datafile '/u01/app/oracle/oradata/ora11g/test_dic01.dbf' size 10m extent management dictionary;
create tablespace test_dic datafile '/u01/app/oracle/oradata/ora11g/test_dic01.dbf' size 10m extent management dictionary
*
ERROR at line 1:
ORA-12913: Cannot create dictionary managed tablespace
SYS@ora11g > select extent_management from dba_tablespaces where tablespace_name='SYSTEM';
EXTENT_MAN
----------
LOCAL
SYS@ora11g > ! oerr ora 12913
12913, 00000, "Cannot create dictionary managed tablespace"
// *Cause: Attemp to create dictionary managed tablespace in database
// which has system tablespace as locally managed
// *Action: Create a locally managed tablespace.
SYS@ora11g >
只有SYSTEM为字典管理的表空间时才能创建字典管理的普通表空间:
[oracle@rhel6lhr ~]$ cat a.txt
db_name=PROD3
db_block_size=8192
db_create_file_dest='/u01/app/oracle/oradata'
control_files='/u01/app/oracle/oradata/PROD3/control01.ctl'
sga_target=300m
[oracle@rhel6lhr ~]$
[oracle@rhel6lhr ~]$
[oracle@rhel6lhr ~]$ mkdir /u01/app/oracle/oradata/PROD3
[oracle@rhel6lhr ~]$
[oracle@rhel6lhr ~]$ sas
SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 24 22:41:03 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SYS@orclasm > exit
Disconnected
[oracle@rhel6lhr ~]$ ORACLE_SID=PROD3
[oracle@rhel6lhr ~]$ sas
SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 24 22:41:17 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SYS@PROD3 > startup nomount pfile='/home/oracle/a.txt';
ORACLE instance started.
Total System Global Area 313159680 bytes
Fixed Size 2227944 bytes
Variable Size 113246488 bytes
Database Buffers 192937984 bytes
Redo Buffers 4747264 bytes
SYS@PROD3 > create database PROD3 character set al32utf8;
Database created.
/*
Specify the EXTENT MANAGEMENT LOCAL clause in the CREATE DATABASE statement to create a locally managed SYSTEM tablespace. The COMPATIBLE initialization parameter must be set to 10.0.0 or higher for this statement to be successful. If you do not specify the EXTENT MANAGEMENT LOCAL clause, then by default the database creates a dictionary-managed SYSTEM tablespace. Dictionary-managed tablespaces are deprecated.*/
SYS@PROD3 > select open_mode from v$database;
OPEN_MODE
----------------------------------------
READ WRITE
SYS@PROD3 > create tablespace test_dic datafile '/u01/app/oracle/oradata/ora11g/test_dic01.dbf' size 10m extent management dictionary;
Tablespace created.
SYS@PROD3 >
SYS@PROD3 > SET LINE 120
SYS@PROD3 > SELECT TS.NAME,decode(ts.bitmapped, 0, 'DICTIONARY', 'LOCAL') extent_management FROM SYS.TS$ TS;
NAME EXTENT_MANAGEMENT
------------------------------------------------------------ --------------------
SYSTEM DICTIONARY
SYSAUX LOCAL
SYS_UNDOTS LOCAL
TEST_DIC DICTIONARY
SYS@PROD3 >