OCM考试系列的文章写的快结束了,基本的内容都已经涉及到,在这片文章中,将对之前的OCM考试系列文章进行汇总,对一些之前没提到的知识点进行补充。
OCM考试分成8个section,时间安排为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
OCM考试一共有9个section,具体的安排如下: 第一天上午: section 0:创建一个数据库 45分钟 section 1:数据库和网络配置 120分钟 第一天下午: section 2:Grid control安装配置 120分钟 section 3:数据库备份恢复 60分钟 section 4:数据仓库管理 90分钟 第二天上午: section 5:数据库管理 120分钟 section 6:数据库性能管理 120分钟 第二天下午: section 7:部署Oracle RAC数据库 105分钟 sectoin 8:部署dataguard数据库 60分钟 |
section 0的手工建库,相关文章见:《OCM考试-create the database》,注意牢记在线文档中create database的例句在administrator guide-Part I Basic Database Administration-2 creating an oracle database – Step 7: Issue the CREATE DATABASE Statement。
section 1:侦听部分见文章《OCM考试-listener》,另外还会涉及到表空间管理,需要注意以下知识点,
1、big tablespace 的建立,相关文档Administrator’s Guide-8 Managing Tablespaces-Creating Tablespaces和SQL Reference-16 SQL Statements: CREATE SYNONYM to CREATE TRIGGER-CREATE TABLESPACE 。
例子:
1 2 3 4 5 6 7 |
SQL> create bigfile tablespace big_tbs 2 datafile 'D:\oracle\product\10.2.0\oradata\oralocal\big_tbs1.dbf' size 200m 3 default storage(initial 1m next 1m); 表空间已创建。 SQL> |
2、tablespace group的建立,相关文档也可以在Administrator’s Guide和SQL Reference里面找。
例子 :
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
SQL> create temporary tablespace temp1 tempfile 'D:\oracle\product\10.2.0\oradata\oralocal\temp1.dbf' size 5m; 表空间已创建。 SQL> create temporary tablespace temp2 tempfile 'D:\oracle\product\10.2.0\oradata\oralocal\temp2.dbf' size 5m; 表空间已创建。 SQL> alter tablespace temp1 tablespace group tmp_grp; 表空间已更改。 SQL> alter tablespace temp2 tablespace group tmp_grp; 表空间已更改。 SQL> select * from dba_tablespace_groups; GROUP_NAME TABLESPACE_NAME ------------------------------ ------------------------------ TMP_GRP TEMP1 TMP_GRP TEMP2 SQL> SQL> alter database default temporary tablespace tmp_grp; 数据库已更改。 SQL> SQL> SQL> select name,value$ from props$ where name like '%TEMP%'; NAME ------------------------------ VALUE$ -------------------------------------------------------------------------------- DEFAULT_TEMP_TABLESPACE TMP_GRP SQL> alter tablespace temp1 tablespace group ''; 表空间已更改。 SQL> select * from dba_tablespace_groups; GROUP_NAME TABLESPACE_NAME ------------------------------ ------------------------------ TMP_GRP TEMP2 SQL> |
3、冗余logifle,相关文档见SQL Reference-10 SQL Statements: ALTER CLUSTER to ALTER JAVA-ALTER DATABASE -logfile_clauses 。
例子:
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- ------------------------------------------------------------ --- 1 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO01.LOG NO 2 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO02.LOG NO 3 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO03.LOG NO SQL> SQL> SQL> SQL> SQL> SQL> SQL> alter database add logfile member 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO11.LOG' to group 1 2 / 数据库已更改。 SQL> alter database add logfile member 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO12.LOG' to group 2; 数据库已更改。 SQL> alter database add logfile member 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO13.LOG' to group 3; 数据库已更改。 SQL> SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- ------------------------------------------------------------ --- 1 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO01.LOG NO 2 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO02.LOG NO 3 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO03.LOG NO 1 INVALID ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO11.LOG NO 2 INVALID ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO12.LOG NO 3 INVALID ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO13.LOG NO 已选择6行。 SQL> SQL> SQL> SQL> alter database add logfile GROUP 4('D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO04.LOG', 2 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO14.LOG') SIZE 50M; 数据库已更改。 SQL> SQL> ALTER DATABASE ADD LOGFILE GROUP 5 ('D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO05.LOG', 2 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO15.LOG') SIZE 50M; 数据库已更改。 SQL> SQL> ALTER SYSTEM SWITCH LOGFILE; 系统已更改。 SQL> / 系统已更改。 SQL> / 系统已更改。 SQL> / 系统已更改。 SQL> / 系统已更改。 SQL> SELECT * FROM V$LOGFILE; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- ------------------------------------------------------------ --- 1 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO01.LOG NO 2 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO02.LOG NO 3 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO03.LOG NO 1 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO11.LOG NO 2 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO12.LOG NO 3 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO13.LOG NO 4 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO04.LOG NO 4 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO14.LOG NO 5 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO05.LOG NO 5 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO15.LOG NO 已选择10行。 SQL> SELECT * FROM V$LOGFILE ORDER BY 1,4; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- ------------------------------------------------------------ --- 1 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO01.LOG NO 1 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO11.LOG NO 2 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO02.LOG NO 2 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO12.LOG NO 3 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO03.LOG NO 3 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO13.LOG NO 4 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO04.LOG NO 4 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO14.LOG NO 5 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO05.LOG NO 5 ONLINE D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORALOCAL\REDO15.LOG NO 已选择10行。 SQL> |
4、resource manager的配置:
4.1、配置一个用户,拥有resource manager的administration权限:
或者直接用语句:
1 2 3 4 |
CREATE USER "SH" PROFILE "DEFAULT" IDENTIFIED BY "SH" DEFAULT TABLESPACE "TBS_TEST" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK BEGIN dbms_resource_manager_privs.grant_system_privilege(privilege_name=>'ADMINISTER_RESOURCE_MANAGER', grantee_name=>'SH', admin_option=>FALSE); END; |
注意这里的ADMINISTER_RESOURCE_MANAGER system privilege。
4.2、创建2个consumer groups,分别为OLTP和DSS:
4.3、创建一个名为WEEKDAYS的resource plan:
4.4、将OLTP_USER的默认资源组分配成OLTP,注意转到user界面
4.6、将instance的默认资源计划定位WEEKDAYS:
点Activate this plan
section2的gc安装配置见《OCM考试-安装grid control》
section 3:备份和恢复会用到之前的文件存储路径的冗余,还有之前的rman备份。
section 4:数据仓库管理,主要是物化视图和sqlldr以及external table。
1、建立一个能快速刷新的物化视图,且能去除表中的重复行:
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
SQL> create table t1 as select username,user_id from dba_users; 表已创建。 SQL> insert into t1 select * from t1; 已创建18行。 SQL> / 已创建36行。 SQL> / 已创建72行。 SQL> commit; 提交完成。 SQL> SQL> create materialized view log on t1 2 with rowid,sequence(username,user_id) 3 including new values; 实体化视图日志已创建。 SQL> create materialized view mv_t1 refresh fast on commit 2 as 3 select username,user_id,count(*) from t1 4 group by username,user_id; 实体化视图已创建。 SQL> SQL> SQL> SQL> select count(*) from t1; COUNT(*) ---------- 144 SQL> SQL> select count(*) from mv_1; COUNT(*) ---------- 18 SQL> SQL> SQL> SQL> SQL> create user test1 identified by test1; 用户已创建。 SQL> insert into t1 select username,user_id from dba_users; 已创建19行。 SQL> SQL> SQL> SQL> SQL> SQL> commit; 提交完成。 SQL> select count(*) from t1; COUNT(*) ---------- 163 SQL> select count(*) from mv_1; COUNT(*) ---------- 19 SQL> |
2、建立一个外部表,类型是datapump
(相关知识:Utilities-Part III External Tables)
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
2.1、已经存在了dmp文件:test1.t2.dmp SQL> create directory mydir as 'D:\oracle\product\10.2.0\dumpdir'; 目录已创建。 SQL> SQL> grant read,write on directory mydir to test1; 授权成功。 SQL> create table x_2 ( 2 USERNAME VARCHAR2(30) , 3 USER_ID NUMBER , 4 PASSWORD VARCHAR2(30) , 5 ACCOUNT_STATUS VARCHAR2(32) , 6 LOCK_DATE DATE , 7 EXPIRY_DATE DATE , 8 DEFAULT_TABLESPACE VARCHAR2(30) , 9 TEMPORARY_TABLESPACE VARCHAR2(30) , 10 CREATED DATE , 11 PROFILE VARCHAR2(30) , 12 INITIAL_RSRC_CONSUMER_GROUP VARCHAR2(30) , 13 EXTERNAL_NAME VARCHAR2(4000) 14 ) 15 organization external 16 ( type oracle_datapump 17 default directory mydir 18 location ('test1.t2.dmp') 19 ); 表已创建。 SQL> 2.2、将select出来的内容转储到test1.t1.dmp中: SQL> create table x_1 2 organization external 3 ( type oracle_datapump 4 default directory mydir 5 location ('test1.t1.dmp') 6 ) 7 as 8 select * from test1.t1; 表已创建。 SQL> |
3、sqlldr的使用(相关知识:Utilities-Part II SQL*Loader):
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 33 34 35 36 37 38 39 40 41 42 |
sqlldr_file.dat的内容: P,James,31, P,Thomas,22, E,Pat,38,93645,1122,Engineering, P,Bill,19, P,Scott,55, S,Judy,45,27316,English, S,Karen,34,80356,History, E,Karen,61,90056,1323,Manufacturing, S,Pat,29,98625,Spanish, S,Cody,22,99743,Math, P,Ted,43, E,Judy,44,87616,1544,Accounting, E,Bob,50,63421,1314,Shipping, S,Bob,32,67420,Psychology, E,Cody,33,25143,1002,Human Resources, 建立一个控制文件sqlldr.ctl load data infile 'sqlldr_file' append into table sqlldr_test TRAILING NULLCOLS (col1 CHAR TERMINATED BY ",", col2 CHAR TERMINATED BY ",", col3 INTEGER EXTERNAL TERMINATED BY ",", col4 INTEGER EXTERNAL TERMINATED BY ",", col5 INTEGER EXTERNAL TERMINATED BY ",", col6 CHAR TERMINATED BY "," ) 注意因为有几行的数据只有3列columns,有些有6列;对于不到6列的行,后面的几列必须制定tailing nullcols,用null来补齐 D:\oracle\product\10.2.0\dumpdir>sqlldr test/test control=sqlldr.ctl SQL*Loader: Release 10.2.0.1.0 - Production on 星期四 8月 12 23:52:00 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. 达到提交点 - 逻辑记录计数 14 达到提交点 - 逻辑记录计数 15 D:\oracle\product\10.2.0\dumpdir> |
section 5:数据库管理
1、表空间传输(相关知识:Administrator’s Guide-8 Managing Tablespaces-Transporting Tablespaces Between Databases-Example)
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
SQL> create tablespace t4trans datafile '/oracle/app/oracle/oradata/ocmdb/dfile/t4trans.dbf' size 5m SQL> / Tablespace created. SQL> create table test.ttt tablespace t4trans as select * from dba_users; Table created. SQL> SQL> SQL> alter tablespace t4trans read only; Tablespace altered. SQL> SQL> exec dbms_tts.TRANSPORT_SET_CHECK('T4TRANS',true,true); PL/SQL procedure successfully completed. [oracle@ocmdb1 ~]$ cp /oracle/app/oracle/oradata/ocmdb/dfile/t4trans.dbf /oracle/app/oracle/oradata/ocmgc/dfile/t4trans.dbf [oracle@ocmdb1 ~]$ [oracle@ocmdb1 ~]$ imp userid=\"/ as sysdba\" file=tbs_t4trans.dmp TTS_OWNERS=test TRANSPORT_TABLESPACE=y TABLESPACES=t4trans DATAFILES=/oracle/app/oracle/oradata/ocmgc/dfile/t4trans.dbf fromuser=test touser=test1; Import: Release 10.2.0.2.0 - Production on Thu Aug 12 20:59:34 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options Export file created by EXPORT:V10.02.01 via conventional path About to import transportable tablespace(s) metadata... import done in ZHS16GBK character set and AL16UTF16 NCHAR character set import server uses US7ASCII character set (possible charset conversion) . importing TEST's objects into TEST1 . . importing table "TTT" Import terminated successfully without warnings. [oracle@ocmdb1 ~]$ SQL> SQL> SQL> SQL> SQL> select * from transport_set_violations; no rows selected SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options [oracle@ocmdb1 ~]$ [oracle@ocmdb1 ~]$ [oracle@ocmdb1 ~]$ exp userid=\"/ as sysdba\" TRANSPORT_TABLESPACE=y TABLESPACES=(t4trans) file=tbs_t4trans.dmp Export: Release 10.2.0.2.0 - Production on Thu Aug 12 20:12:45 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set server uses US7ASCII character set (possible charset conversion) Note: table data (rows) will not be exported About to export transportable tablespace metadata... For tablespace T4TRANS ... . exporting cluster definitions . exporting table definitions . . exporting table TTT . exporting referential integrity constraints . exporting triggers . end transportable tablespace metadata export Export terminated successfully without warnings. [oracle@ocmdb1 ~]$ |
2、打开一个表上所有的索引监控(相关知识:Administrator’s Guide-16 Managing Indexes-Monitoring Index Usage):
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 33 34 35 |
SQL> create or replace procedure pro_monitor_index 2 as 3 idx_name varchar2(20); 4 cursor c1 is select index_name from user_indexes where table_name='TEST_1'; 5 begin 6 open c1; 7 loop fetch c1 into idx_name; 8 if c1%found then 9 execute immediate 'alter index '||idx_name||' monitoring usage'; 10 else 11 exit; 12 end if; 13 end loop; 14 close c1; 15 end; 16 / Procedure created. SQL> exec pro_monitor_index; PL/SQL procedure successfully completed. SQL> SQL> l 1* select * from V$OBJECT_USAGE SQL> / INDEX_NAME TABLE_NAME MONITO USED START_MONITORING END_MONITORING -------------------- -------------------- ------ ------ ------------------------------ -------------------------------------- IDX_ID TEST_1 YES YES 08/12/2010 23:02:09 IDX_LAST_DDL_TIME TEST_1 YES NO 08/12/2010 23:02:11 SQL> |
3、建立分区表(相关知识: SQL Reference-CREATE INDEX):
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
SQL> alter system set db_16k_cache_size=200m scope=spfile; System altered. SQL> startup force ORACLE instance started. Total System Global Area 314572800 bytes Fixed Size 1260612 bytes Variable Size 62915516 bytes Database Buffers 247463936 bytes Redo Buffers 2932736 bytes Database mounted. Database opened. SQL> create tablespace data01 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data01.dbf' 2 size 32m blocksize 16k 3 uniform size 4m; Tablespace created. SQL> SQL> SQL> SQL> create tablespace data02 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data02.dbf' 2 size 32m blocksize 16k 3 uniform size 4m; Tablespace created. SQL> l1 1* create tablespace data02 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data02.dbf' SQL> c/02/03 1* create tablespace data03 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data02.dbf' SQL> c/02/03 1* create tablespace data03 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data03.dbf' SQL> l 1 create tablespace data03 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data03.dbf' 2 size 32m blocksize 16k 3* uniform size 4m SQL> / Tablespace created. SQL> SQL> SQL> l1 1* create tablespace data03 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data03.dbf' SQL> c/03/04 1* create tablespace data04 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data03.dbf' SQL> c/03/04 1* create tablespace data04 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data04.dbf' SQL> l 1 create tablespace data04 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data04.dbf' 2 size 32m blocksize 16k 3* uniform size 4m SQL> / Tablespace created. SQL> SQL> SQL> l1 1* create tablespace data04 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data04.dbf' SQL> c/04/05 1* create tablespace data05 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data04.dbf' SQL> c/04/05 1* create tablespace data05 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data05.dbf' SQL> l 1 create tablespace data05 datafile '/oracle/app/oracle/oradata/ocmdb/dfile/data05.dbf' 2 size 32m blocksize 16k 3* uniform size 4m SQL> / Tablespace created. SQL> SQL> SQL> SQL> SQL> conn sh/sh Connected. SQL> create table sales_history 2 (id number(5), 3 salesman_name varchar2(20), 4 sales_date date) 5 partition by range(sales_date) 6 (partition p1 values less than (to_date('1999-01-01','yyyy-mm-dd')) tablespace data01, 7 partition p2 values less than (to_date('2000-01-01', 'yyyy-mm-dd')) tablespace data02, 8 partition p3 values less than (to_date('2001-01-01', 'yyyy-mm-dd')) tablespace data03, 9 partition p4 values less than (to_date('2002-01-01', 'yyyy-mm-dd')) tablespace data04, 10* partition p5 values less than (to_date('2003-01-01','yyyy-mm-dd')) tablespace data05) SQL> / Table created. SQL> SQL> create index pk_id on sales_history(id) global 2 partition by hash(id) parallel 4; Index created. SQL> SQL> create index id_name on sales_history(SALESMAN_NAME) 2 local; Index created. SQL> SQL> create index idx_date on sales_history(SALES_DATE) 2 global partition by hash(SALES_DATE) 3 (partition p1, 4 partition p2, 5 partition p3); Index created. SQL> |
4、建立带LOB字段表(相关知识: SQL Reference-CREATE TABLE-LOB_storage_clause::=和LOB Column Example):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SQL> create table MAGAZINE_ARTICLES 2 ( 3 AUTHOR VARCHAR2(30), 4 ARTICLE_NAME VARCHAR2(50), 5 ARTICLE_DATE DATE, 6 ARTICLE_DATA CLOB) tablespace TBS_1 7 LOB(ARTICLE_DATA) 8 store as(tablespace TBS_2 9 disable storage in row 10 chunk 16k 11 nocache 12 ); Table created. SQL> |
5、FGA审计(相关知识 PL/SQL Packages and Types Reference-40 DBMS_FGA-ADD_POLICY Procedure):
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
SQL> DESC TEST.T2 名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- USERNAME NOT NULL VARCHAR2(30) USER_ID NOT NULL NUMBER SQL> SQL> exec dbms_fga.ADD_POLICY('TEST','T2','AUD_T2','USER_ID>=3','USER_ID,USERNAME',NULL,NULL,TRUE,'INSERT, UPDATE, DELET E',DBMS_FGA.XML+DBMS_FGA.EXTENDED); PL/SQL 过程已成功完成。 SQL> SQL> SQL> SQL> CONN TEST/TEST 已连接。 SQL> SELECT COUNT(*) FROM T2; COUNT(*) ---------- 220 SQL> UPDATE T2 SET USERNAME='ASASAS' WHERE USER_ID>6; 已更新196行。 SQL> UPDATE T2 SET USERNAME='QQWW' WHERE USER_ID<2; 已更新12行。 SQL> COMMIT; 提交完成。 SQL> SQL> L 1* SELECT SESSION_ID,AUDIT_TYPE,EXTENDED_TIMESTAMP,SQL_TEXT FROM V$XML_AUDIT_TRAIL SQL> / SESSION_ID AUDIT_TYPE EXTENDED_TIMESTAMP SQL_TEXT ---------- ---------- ---------------------------------------- -------------------------------------------------- 189 2 18-8月 -10 11.32.09.879000 下午 +08:00 UPDATE T2 SET USERNAME='ASASAS' WHERE USER_ID>6 SQL> 或者: SQL> exec dbms_fga.ADD_POLICY('TEST','T2','AUD_T2','USER_ID>=3','USER_ID,USERNAME',NULL,NULL,TRUE,'INSERT, UPDATE, DELET E',DBMS_FGA.DB+DBMS_FGA.EXTENDED); PL/SQL 过程已成功完成。 SQL> conn test/test 已连接。 SQL> UPDATE T2 SET USERNAME='test3' WHERE USER_ID=5; 已更新12行。 SQL> COMMIT; 提交完成。 SQL> conn / as sysdba 已连接。 SQL> select sql_text from dba_fga_audit_trail; SQL_TEXT -------------------------------------------------- UPDATE T2 SET USERNAME='test3' WHERE USER_ID=5 SQL> |
section 6:数据库性能管理
1、创建IOT表(相关知识:Administrator’s Guide-Managing tables-Creating an Index-Organized Table 或者 SQL Reference-CREATE TABLE-Index-Organized Table Example ):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SQL> l 1 create table test_iot 2 (a number, 3 b varchar2(20), 4 c date, 5 constraint pk_a primary key(a,b)) 6 organization index 7 tablespace users 8 pctthreshold 20 9 including c 10* overflow tablespace big_tbs SQL> / 表已创建。 SQL> |
2、keep 在cache中:
1 2 3 4 5 6 7 8 9 |
SQL> alter system set db_keep_cache_size=20m; 系统已更改。 SQL> alter table test_iot storage(buffer_pool keep); 表已更改。 SQL> |
3、创建bitmap index:
1 2 3 4 5 6 7 8 9 |
SQL> create table t1 as select * from dba_tables; 表已创建。 SQL> create bitmap index idx_bitmap on t1(OWNER); 索引已创建。 SQL> |
4、创建reverse index:
1 2 3 4 5 |
SQL> create index idx_rev on t1(PCT_FREE) reverse; 索引已创建。 SQL> |
5、创建function base index:
1 2 3 4 5 |
SQL> create index idx_fun on t1(to_char(LAST_ANALYZED,'yyyy-mm-dd hh24:mi:ss')); 索引已创建。 SQL> |
6、收集统计信息:
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
SQL> desc dbms_stats …… PROCEDURE GATHER_SCHEMA_STATS 参数名称 类型 输入/输出默认值? ------------------------------ ----------------------- ------ -------- OWNNAME VARCHAR2 IN ESTIMATE_PERCENT NUMBER IN DEFAULT BLOCK_SAMPLE BOOLEAN IN DEFAULT METHOD_OPT VARCHAR2 IN DEFAULT DEGREE NUMBER IN DEFAULT GRANULARITY VARCHAR2 IN DEFAULT CASCADE BOOLEAN IN DEFAULT STATTAB VARCHAR2 IN DEFAULT STATID VARCHAR2 IN DEFAULT OPTIONS VARCHAR2 IN DEFAULT OBJLIST DBMS_STATS OUT STATOWN VARCHAR2 IN DEFAULT NO_INVALIDATE BOOLEAN IN DEFAULT GATHER_TEMP BOOLEAN IN DEFAULT GATHER_FIXED BOOLEAN IN DEFAULT STATTYPE VARCHAR2 IN DEFAULT FORCE BOOLEAN IN DEFAULT PROCEDURE GATHER_SCHEMA_STATS 参数名称 类型 输入/输出默认值? ------------------------------ ----------------------- ------ -------- OWNNAME VARCHAR2 IN ESTIMATE_PERCENT NUMBER IN DEFAULT BLOCK_SAMPLE BOOLEAN IN DEFAULT METHOD_OPT VARCHAR2 IN DEFAULT DEGREE NUMBER IN DEFAULT GRANULARITY VARCHAR2 IN DEFAULT CASCADE BOOLEAN IN DEFAULT STATTAB VARCHAR2 IN DEFAULT STATID VARCHAR2 IN DEFAULT OPTIONS VARCHAR2 IN DEFAULT STATOWN VARCHAR2 IN DEFAULT NO_INVALIDATE BOOLEAN IN DEFAULT GATHER_TEMP BOOLEAN IN DEFAULT GATHER_FIXED BOOLEAN IN DEFAULT STATTYPE VARCHAR2 IN DEFAULT FORCE BOOLEAN IN DEFAULT PROCEDURE GATHER_SYSTEM_STATS 参数名称 类型 输入/输出默认值? ------------------------------ ----------------------- ------ -------- GATHERING_MODE VARCHAR2 IN DEFAULT INTERVAL NUMBER(38) IN DEFAULT STATTAB VARCHAR2 IN DEFAULT STATID VARCHAR2 IN DEFAULT STATOWN VARCHAR2 IN DEFAULT PROCEDURE GATHER_TABLE_STATS 参数名称 类型 输入/输出默认值? ------------------------------ ----------------------- ------ -------- OWNNAME VARCHAR2 IN TABNAME VARCHAR2 IN PARTNAME VARCHAR2 IN DEFAULT ESTIMATE_PERCENT NUMBER IN DEFAULT BLOCK_SAMPLE BOOLEAN IN DEFAULT METHOD_OPT VARCHAR2 IN DEFAULT DEGREE NUMBER IN DEFAULT GRANULARITY VARCHAR2 IN DEFAULT CASCADE BOOLEAN IN DEFAULT STATTAB VARCHAR2 IN DEFAULT STATID VARCHAR2 IN DEFAULT STATOWN VARCHAR2 IN DEFAULT NO_INVALIDATE BOOLEAN IN DEFAULT STATTYPE VARCHAR2 IN DEFAULT FORCE BOOLEAN IN DEFAULT …… SQL> SQL> SQL> SQL> desc dbms_workload_repository …… PROCEDURE CREATE_SNAPSHOT 参数名称 类型 输入/输出默认值? ------------------------------ ----------------------- ------ -------- FLUSH_LEVEL VARCHAR2 IN DEFAULT …… SQL> exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT; PL/SQL 过程已成功完成。 SQL> |
section 7:部署Oracle RAC数据库,相关文章见:《ocm考试-rac安装》
sectoin 8:部署dataguard数据库 ,相关文章见:《OCM考试-DG安装》
7条评论
请教一下,有关数据仓库管理要看什么 文档,
或是在官方文档的哪篇可以学习, 是不是《Data Warehousing Guide》这个文档
感谢!
最近在考 谢谢提空的资料!
请看“建立一个能快速刷新的物化视图,且能去除表中的重复行“ 这一块。
按照你这样的创建方法,是不支持update和delete的,是个只支持insert的insert-only materialized view. 物化试图创建中少了count(*)列。Oracle文档中有明确说明:
If the materialized view has one of the following, then fast refresh is supported only on conventional DML inserts and direct loads.
* Materialized views with MIN or MAX aggregates
* Materialized views which have SUM(expr) but no COUNT(expr)
* Materialized views without COUNT(*)
你没测试UPDATE和DELTE,所以没看到错。。嘿嘿
谢谢kevin的指出,确实忽略了这点。
关于物化视图,老杨 写了很多文章,写的真好,不过太多了,需要慢慢看了~~~嘿嘿
ocm的考题这么固定吗
?
物化视图完全按照你的代码写的,为啥不刷新啊?