Вы находитесь на странице: 1из 141

Oracle Database 10g New Features

Utah Oracle Users Group Robert G. Freeman

About Me...
Robert G. Freeman Principle Engineer, LDS Church dbaoracle@aol.com or robertgfreeman@yahoo.com Books: Oracle Database 10g RMAN Backup and Recovery OP Oracle Database 10g New Features OP Portable DBA: Oracle OP Oracle9i New Features - OP Oracle9i RMAN Backup and Recovery - Oracle Press (OP) Mastering Oracle8i Database Administration - Sybex Oracle 8 to 8i Upgrade Exam Cram - Coriolis Oracle 7.3 to 8 Upgrade Exam Cram - Coriolis

Oracle Database10g New Features


y ASM y Statistics Related Changes y Flushing the buffer cache y Database resource manager changes y New Scheduler y Tablespace Groups y Rename tablespaces y Drop Database y Larger LOBs y Shrink and compact segments online y ADDM, AWR and the Advisors y SYSAUX Tablespace y New MERGE functionality y New Partitioning Features y Self tuning SGA y Self tuning checkpoinging y Sorted hash clusters y Recovery through resetlogs y Automated ARCH process startup y alter database backup commands y Flash recovery area y RMAN improvements y Flashback y Data pump y Bigfile tablespaces y Cross platform transportable tablespaces y External tables new features

Oracle Database 10g ASM


ASM = Automatic Storage Management Provides an integrated, clustered file system for you at no additional cost. No need to buy additional clusterware (e.g. Veritas) Performs nearly as well as raw (faster than OCFS) Requires creation of an ASM Oracle instance. An alternative to RAW or Cooked file systems for RAC and Non-RAC databases. Designed to make database management easier.

Oracle Database 10g ASM


Features of ASM
Compatible with JBOD, SAN, etc Automated management of file names (optional) Automated load balancing of datafiles across all disks. Automated re-balancing of datafiles when disks are added or removed. Dynamic rebalancing of disks as load patterns change. Support for vendor supplied storage offerings and features. Lot's of good (and bad) Internet coverage of ASM. You can use the new DBMS_FILE_TRANSFER package to move files in and out of ASM 10gR2 licensing of ASM does not require a RAC license. 10gR2 now allows a single ASM instance to manage both RAC and single node databases. ASM in 10gR2 supports 10.1 (> 10.0.1.3) and later databases.

Oracle Database 10g ASM


ASM in 10gR2 allows for a seamless creation of an independent ASM ORACLE_HOME via the Universal Installer/DBCA interfaces. Migration of raw or cooked file systems to ASM supported in 10gR2 via Oracle Grid Control. Support for migration of all database files. Support for fallback to non-ASM environment. Automated database migration process. If you use XMLDB you can access the ASM disk group via virtual folders. This also allows direct FTP operations to the ASM disk group.

Oracle Database 10g ASM


10gR2 offers a new stand-alone command line interface into ASM. (asmcmd). Example:
SQL> select file_name from dba_data_files; FILE_NAME ------------------------------------------------------------------------C:\ORACLE\PRODUCT\10.2.0\ORADATA\ROB10R2\SYSAUX01.DBF C:\ORACLE\PRODUCT\10.2.0\ORADATA\ROB10R2\SYSTEM01.DBF +ASMV01/ast_test01.dbf

Oracle Database 10g ASM


C:\Documents and Settings\Robert>asmcmd ASMCMD> pwd + ASMCMD> ls ASMV01/ ASMCMD> cd asmv01 ASMCMD> ls ROB10R2/ ast_test01.dbf ASMCMD> ls -al Type Redund Striped Time

Sys Y N +ASMV01/ROB10R2/DATAFILE/ASM_TEST.275.606649369 ASMCMD>

Name ROB10R2/ ast_test01.dbf =>

Oracle Database 10g ASM


ASM in 10gR2 allows for a seamless creation of an independent ASM ORACLE_HOME via the Universal Installer/DBCA interfaces. Migration of raw or cooked file systems to ASM supported in 10gR2 via Oracle Grid Control. Support for migration of all database files. Support for fallback to non-ASM environment. Automated database migration process. Personal feelings Don't use for stand-alone instances unless you can demonstrate a real benefit. An additional point of failure Unneeded complexity Consumes additional OS resources Worthwhile to use with RAC installs.

Oracle Database 10g Statistics Related Changes


The Rule Based Optimizer is now desupported (but still available) The CBO in 10g (and to a lesser extend in 9i) now takes system performance into account when generating an execution plan) You should now collect system statistics using the dbms_stats.gather_system_statistics package (how many are doing this now?) Removes many assumptions the optimizer previously made such as CPU and IO costing. Collect system statistics during a typical load period. See "Understanding System Statistics" by Jonathan Lewis.
http://www.oracle.com/technology/pub/articles/lewis_cbo.html

Oracle Database 10g Statistics Related Changes


Collecting system statistics is easy. Allow some delay between the start and stop (say, 20 minutes or more):
execute dbms_stats.gather_system_stats('Start'); execute dbms_stats.gather_system_stats('Stop');

Oracle Database 10g Statistics Related Changes


sys.aux_stats$ contains the results of the statistics collection.
select pname, pval1 from sys.aux_stats$ where sname = 'SYSSTATS_MAIN'; PNAME PVAL1 ---------- ---------CPUSPEED 904 IOSEEKTIM 10 IOTFRSPEED 4096 MBRC 11 MREADTIM 15.833 SREADTIM 8.532

Avg # blocks in MB IO Read. Avg read time for a MB IO Req. Avg read time for a SB IO Req.

Oracle uses these statistics to determine if a FTS or an index lookup will be more efficient (effectively calculating the db_file_multiblock_read_count parameter)

Oracle Database 10g Statistics Related Changes


Oracle database 10g now will automatically collect your database statistics. The job is run from the new Oracle job scheduler facility. Runs Monday through Friday at 10pm. Saturday at midnight. The tables with the most stale statistics will be analyzed first. Oracle Database 10g allows you to lock object statistics with the dbms_stats.lock_schema_stats and lock_table_stats procedures.

Oracle Database 10g Statistics Related Changes


The new dba_optstat_operations view provides a list of the start/stop times of statistics collection jobs.
SQL> select * from dba_optstat_operat OPERATION TARGET -------------------- ---------------START_TIME ------------------------------------END_TIME ------------------------------------gather_system_stats 23-NOV-06 01.17.41.495000 PM -07:00 23-NOV-06 01.17.41.515000 PM -07:00 gather_database_stats(auto) 24-NOV-06 09.00.04.094000 PM -06:00 24-NOV-06 09.01.41.625000 PM -06:00

Oracle Database 10g Statistics Related Changes


Don't like automated statistics collection?
BEGIN DBMS_SCHEDULER.DISABLE('GATHER_STATS_JOB'); END;

To restart automated statistics collection


BEGIN DBMS_SCHEDULER.ENABLE('GATHER_STATS_JOB'); END;

Be careful of this if you are upgrading to 10g and you didn't analyze your objects for a reason!

Oracle Database 10g Statistics Related Changes


New Parameter statistics_level (basic, typical, all). Default is typical - Enables Advisor framework. Timed Statistics Detection of stale statistics Setting to All will enable Timed OS statistics Row source execution stats (e.g. v$sqlplan_statistics) Recommend set to typical in most cases. (ALL seems to add between zero and 300+% overhead depending on the SQL being executed). See Dave Ensor article on this at:
http://www.dbazine.com/oracle/or-articles/ensor8

Oracle Database 10g Statistics Related Changes


Oracle automatically computes index statistics when an index is built or rebuilt. Table monitoring is on for all tables by default if statistics_level parameter is set to TYPICAL. alter table nomonitoring will have no effect. Monitoring is enabled by default in 10g, you can't disable it. Dynamic sampling is controlled by the OPTIMIZER_DYNAMIC_SAMPLING parameter or the dynamic_sampling hint (actually a 9.2 feature).

Oracle Database 10g Statistics Related Changes


v$sql_plan_statistics_all New view provides row source information. Example SQL to use:
select p.id, p.parent_id, p.depth, p.operation, p.object_owner,p.object_name, p.object_type, p.cr_buffer_gets, p.disk_reads, p.elapsed_time, p.total_executions from v$sql_plan_statistics_all p, ( select * from (select * from v$sql where sql_text like 'select * from emp%' and PARSING_USER_ID = SYS_CONTEXT ('USERENV', 'CURRENT_USERID') order by last_load_time desc) where rownum <2) s where s.address=p.address and s.hash_value=p.hash_value and s.child_number = p.child_number order by id, position;

Oracle Database 10g Statistics Related Changes


Example:
ID P_ID DEPTH OPERATION --- ---- ----- ------------1 0 1 NESTED LOOPS 2 1 2 TABLE ACCESS 3 1 2 TABLE ACCESS 4 3 3 INDEX OWNER O_NAME ----- -----OBJECT_TYPE CRBUGETS DSKRDS ELP_TIME ------------ -------- ------ -------24 0 1183 SCOTT EMP TABLE 8 0 200 SCOTT DEPT TABLE 16 0 745 SCOTT PK_DEPT INDEX (UNIQU 2 0 283

Columns in red are only recorded if statistics_level=ALL.

Oracle Database 10g Flushing the buffer cache


You can now flush the buffer cache without having to shutdown the database.
Alter system flush buffer_cache;

The question is.. Why?? Any takers?

Oracle Database 10g Flushing the buffer cache


A summary of Tom's opinion from AskTom:
there are two times when it comes into play a) you are using raw or unbuffered IO and you want to time your disk speed. This is very rare. b) you mistakenly believe that you need to benchmark with an empty buffer cache to get "real world" numbers. This "thought" occurs because your benchmark contains a single query with a single set of inputs and you cannot be bothered to simulate a real world workload. Problem is -- in real world buffer cache is neither 100% empty, not 100% full so problem is with benchmark, not with what is cached or not. This flushing command is mostly (IMO) to make people "feel better". Source: http://asktom.oracle.com/pls/ask/f?p=4950:8:16219223249178392116:: NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:12257624552691

Oracle Database 10g


Database Resource Manager Changes
New features associated with the database resource manager include: Now, you can revert back to the original consumer group after a SQL call that has caused your session to be switched into another consumer group, has completed. This means that consumer group switches as a result of the switch_time directive will only have effect for a given SQL statement, rather than the remaining session. The Max_idle_time parameter allows you to limit the maximum time that a session is allowed to remain idle. Very useful for applications that have a tendency to disconnect ungracefully from the database. Reduce blocking locks from zombie sessions.

Oracle Database 10g New Scheduler


DON'T PANIC! The old job scheduler is still available. The basic functionality of the old job scheduler is still intact in the new job scheduler, plus a bunch of new options are available. The new job scheduler is much more flexible (and, unfortunately, can be much more complex).

Oracle Database 10g New Scheduler


Basic components associated with the job scheduler Programs Defines what the scheduler will execute. A program has several attributes including a name, the type of program (PL/SQL, external program, etc..), arguments and so on. Schedule Defines when the scheduler is supposed to execute the tasks assigned to it. Jobs Assigned to a specific schedule. A job can be one time tasks, or assigned to program which may run once, many times or on demand.

Oracle Database 10g New Scheduler


How programs, jobs and schedules relate.

Source: Oracle Database 10g Documentation

Oracle Database 10g New Scheduler


Some more advanced features Job classes Grouping jobs together that have similar resource demands. Used to insure all jobs within a class utilize the same job class attributes (e.g. as a class execute at a higher or lower priority than other jobs in other job classes). Job classes can ensure that only jobs in the job class will start if there are sufficient resources available.

Oracle Database 10g New Scheduler


Some more advanced features Windows Allows the assignment of job classes and associated priorities to specific time based windows. Scheduled OLTP jobs might get a higher priority during the day. Reporting related jobs (or backup related jobs such as archived redo log backups) might get a lower priority during the day. Windows can be grouped together into window groups.

Oracle Database 10g New Scheduler


The automatic statistics collection feature of Oracle Database 10g is a good example of the use of the scheduler. We can look at scheduler objects with the dba_objects view as seen here:
SELECT owner, object_type, object_name, created, status FROM dba_objects WHERE object_type IN ('PROGRAM', 'JOB', 'JOB CLASS', 'SCHEDULE', 'WINDOW') ORDER BY object_type, OBJECT_name;

Oracle Database 10g New Scheduler


Here are some partial results:
Owner Type Name -------- ------------ -------------------SYS JOB AUTO_SPACE_ADVISOR_J OB SYS JOB GATHER_STATS_JOB SYS PROGRAM AUTO_SPACE_ADVISOR_P ROG SYS PROGRAM GATHER_STATS_PROG SYS WINDOW WEEKEND_WINDOW SYS WINDOW WEEKNIGHT_WINDOW Created On Status -------------------- ------30-AUG-05 VALID 30-AUG-05 30-AUG-05 30-AUG-05 30-AUG-05 30-AUG-05 VALID VALID VALID VALID VALID

Oracle Database 10g New Scheduler


We can look at more detail on the programs:
SELECT owner, program_name, program_type, program_action FROM dba_scheduler_programs where program_name='GATHER_STATS_PROG'; Owner Program Type -------- ---------------- -------------------------Action -------------------------SYS GATHER_STATS_PROG STORED_PROCEDURE dbms_stats.gather_database_stats_job_proc

Oracle Database 10g New Scheduler


If this procedure has arguments, we can see them too:
SELECT owner, program_name, argument_name, argument_position,argument_type, default_value, out_argument FROM dba_scheduler_program_args where program_name='GATHER_STATS_PROG';

In this case, the GATHER_STATS_PROG program has no arguments

Oracle Database 10g New Scheduler


So we have the GATHER_STATS_PROG program. Is it assigned to a job?
select owner, job_name, program_owner, program_name from dba_scheduler_jobs where program_name='GATHER_STATS_PROG'; Owner JOB_NAME PROG_OWNER Program ------ ----------------- ---------- ------------SYS GATHER_STATS_JOB SYS GATHER_STATS_PROG

Oracle Database 10g New Scheduler


Is this job assigned to a schedule?
select owner, job_name, schedule_name, enabled from dba_scheduler_jobs where program_name='GATHER_STATS_PROG'; Owner JOB_NAME SCHEDULE_NAME -------- ----------------- -----------------------SYS GATHER_STATS_JOB MAINTENANCE_WINDOW_GROUP ENAB ---TRUE

Oracle Database 10g New Scheduler


Does this job have arguments? (the answer is no in this case)
SELECT job_name, argument_name, argument_position, value FROM dba_scheduler_job_args;

Tell me about the schedule.. (it's called maintenance_window_group)


select owner, schedule_name, start_date, repeat_interval from dba_scheduler_schedules;

Our job won't show up here because it's part of a window group.

Oracle Database 10g New Scheduler


Tell me about the schedule window group then:
select * from dba_scheduler_wingroup_members Where window_group_name='MAINTENANCE_WINDOW_GROUP'; WINDOW_GROUP_NAME -----------------------------MAINTENANCE_WINDOW_GROUP MAINTENANCE_WINDOW_GROUP WINDOW_NAME --------------------WEEKNIGHT_WINDOW WEEKEND_WINDOW

Oracle Database 10g New Scheduler


Give me details on the windows
select window_name, repeat_interval from dba_scheduler_windows where window_name in ('WEEKNIGHT_WINDOW','WEEKEND_WINDOW')
WINDOW_NAME ---------------REPEAT_INTERVAL -----------------------------------------------------WEEKNIGHT_WINDOW freq=daily;byday=MON,TUE,WED,THU,FRI;byhour=22;byminute=0; bysecond=0 WEEKEND_WINDOW freq=daily;byday=SAT;byhour=0;byminute=0;bysecond=0

Oracle Database 10g New Scheduler


Give me a job run history
SELECT log_date, owner, job_name, status FROM dba_scheduler_job_log where job_name='GATHER_STATS_JOB';
Log Date Owner Job Status ---------------------------------- ------ -------------------- ---------23-NOV-06 09.02.09.007000 PM -07:00 SYS GATHER_STATS_JOB SUCCEEDED

Failed job run history


SELECT log_date, owner, job_name, status, actual_start_date, error# FROM dba_scheduler_job_run_details WHERE status <> 'SUCCEEDED' ORDER BY actual_start_date;

Oracle Database 10g New Scheduler


Using dbms_scheduler to drop and re-create a job:
BEGIN DBMS_SCHEDULER.DROP_JOB (job_name => 'MY_JOB', force => TRUE); DBMS_SCHEDULER.CREATE_JOB (job_name => 'MY_JOB', job_type => 'PLSQL_BLOCK' job_action => 'BEGIN MY_JOB.ME(''OWNER'');END;', start_date => '09/01/2006 09:00:00.000000', repeat_interval => 'FREQ=DAILY' enabled => FALSE comments => 'This is my PL/SQL job...'); END; /

Oracle Database 10g New Scheduler


Schedule jobs other than just PL/SQL jobs. Schedule shell scripts with the job scheduler Scheduler executable programs with the job scheduler You can also map jobs to resource manager plans.

Oracle Database 10g BigFile Tablespaces


Bigfile tablespaces are tablespaces that consist of only one datafile. Bigfile tablespaces can be quite large, depending on the database block size a bigfile tablespace can be up to 128 terabytes in size. With BFT's, a given Oracle DB can be up to 8.5 exabytes in size now. Bigfile tablespaces are always locally managed. An UNDO tablespace or temporary tablespace can be a bigfile tablespace. An Oracle database with BFTs can be upwards of 8 Exabytes in size. Larger datafiles can complicate backup strategies.

Oracle Database 10g BigFile Tablespaces


Databases can be set to use bigfile tablespaces as the default when created, or with the alter database command:
Alter database set default bigfile tablespace;

Use the create bigfile tablespace command to create a bigfile tablespace:


CREATE BIGFILE TABLESPACE big_tbs DATAFILE /u01/oracle/data/bigone.dbf SIZE 100g;

Use the alter tablespace and drop tablespace commands to manage bigfile tablespaces, just as you would normal tablespaces.

Oracle Database 10g BigFile Tablespaces


Can be used to create temporary tablespaces with tempfiles too. Probably want to put them on ASM or some other FS that allows for the underlying datafile to be striped. DBA views for bigfile tablespaces database properties shows default tablespace type dba_tablespaces v$tablespace

Oracle Database 10g Tablespace Groups


Tablespace groups are logical grouping of tablespaces. Assign temporary tablespaces to tablespace groups. Then assign the tablespace group as the default temporary tablespace for the database. Allows you to combine temporary tablespaces in the database for use. To use: Create temporary tablespaces as normal. Use the tablespace group parameter to assign to a tablespace group:
Create temporary tablespace temp_one tempfile /u01/oradata/temp_01.dbf size 100m tablespace group tbs_group_01;

Oracle Database 10g Tablespace Groups


Use the alter database command to make the tablespace group the default tablespace group:
Alter database default temporary tablespace tbs_group_01;

Now all new users will be assigned to the tbs_group_01 tablespace group as the default temporary tablespace. If you are using bigfile temporary tablespaces, this allows you to stripe the IO across many different BF temp tablespaces.

Oracle Database 10g Rename Tablespaces


Wooo Hooo! Rename tablespaces in Oracle Database 10g with the alter tablespace command!
Alter tablespace my_tbs rename to your_tbs;

Always backup the control file after this operation!

Oracle Database 10g Drop Database


Oracle Database 10g offers a new command to make your day, drop database. Oracle drops all datafiles, the SPFILE and the control files. In the hands of a Jr. DBA, (or a curious developer) this can make for a baaaad day.

Oracle Database 10g LOBs


LOBS in Oracle Database 10g can now be larger. The size is dependent on the block size of the database, but a 8k block size database will allow a 32GB limit on LOBs. You can get up to 128TB lobs in 32k block size databases. Lob performance is improved. BFILES are still limited to 4GB. 10R2 offers limited support for remote LOBS. Support for CTAS, and insert/update as select commands. LOBS supported in partitioned IOT's. LogMiner supports CLOB and NCLOB data (and LONGs too!)

Oracle Database 10g


Shrink and Compact Segments Online
No more reorgs! No more alter table move! Shrink your tables HWM online! Defragment and compact your blocks, online! Shrink and reorginize dependent objects online! Row movement must be enabled. Must be using automatic segment space management.
ALTER TABLE shrink_table ENABLE ROW MOVEMENT; ALTER TABLE shrink_table SHRINK SPACE CASCADE;

Compact without moving the HWM with the compact parameter:


ALTER TABLE shrink_table SHRINK SPACE COMPACT;

How to find objects to shrink? Funny you should ask!!

Oracle Database 10g ADDM, AWR and the Advisors


Oracle comes with the Advanced Workload Repository (AWR). Statspack on steroids (Tom Kyte I think) Tracks a number of database statistics Automatic collection of statistics out of the box. Automatic Database Diagnostic Monitor Monitors the database Uses the ADDM and other database views. Can send notifications in the event of database problems. The Advisors Used to assist with database performance and tuning issues. Here is where we find out which objects to shrink!

Oracle Database 10g ADDM, AWR and the Advisors


AWR (Automated Workload Repository) AWR collects database statistics every 60 minutes out of the box (this is configurable), and this data is maintained for a week and then purged. The statistics collected by AWR are stored in the database. To properly collect database statistics, the parameter statistics_level should be set to TYPICAL (the default) or ALL. Configure collection interval (15 min and retention 20160 seconds)
Exec dbms_workload_repository.modify_snapshot_settings (retention=>20160, interval=> 15);

Oracle Database 10g ADDM, AWR and the Advisors


AWR is used for Problem detection and analysis Self-tuning. AWR collects Wait events and time model statistics Active session history statistics Various system and session-level statistics Object usage statistics Information on the most resource-intensive SQL statements. Other Oracle Database 10g features use the AWR, including ADDM and a series of "advisors" which are designed to help you manage the database.

Oracle Database 10g ADDM, AWR and the Advisors


You can see the current run setting for the job:
SELECT * FROM dba_hist_wr_control; DBID SNAP_INTERVAL RETENTION ---------- -------------------- -------------------2139184330 +00000 01:00:00.0 +00007 00:00 More on AWR at http://www.dbazine.com/olc/olc-articles/freeman2

AWR offers reporting much like statspack. awrrpt.sql

Oracle Database 10g ADDM, AWR and the Advisors


ADDM Provides for automated analysis of collected database statistics (via AWR for example). Once the AWR snapshot is taken, the ADDM analysis occurs automatically as long as the STATISTICS_LEVEL parameter is set to TYPICAL or ALL. The new Oracle Database 10g background process MMON performs the ADDM analysis. The results of the ADDM run is stored in the AWR, and can be accessed through various means such as OEM, manual query, or an Oracle supplied API.

Oracle Database 10g ADDM, AWR and the Advisors


ADDM's principle goal is to reduce database response time. ADDM Database response time is a value that Oracle calculates to indicate the cumulative time that is spent processing user requests. ADDMs goal is to reduce the overall db time value You can see the current value of db time by querying the V$SYS_TIME_MODEL You can see it for a given session by using the V$SESS_TIME_MODEL view.
select sum(value) "DB time" from v$sys_time_model where stat_name='DB time'; DB time ---------109797 `

Oracle Database 10g ADDM, AWR and the Advisors


In an effort to reduce DB Time, ADDM analyses a number of different database-related problems, including: Memory-related issues such as shared pool latch contention, log buffer issues, or database buffer cache related problems CPU bottlenecks Disk I/O performance issues Database configuration problems Space-related issues, such as tablespaces running out of space Application and SQL tuning issues such as excessive parsing and excessive locking

Oracle Database 10g ADDM, AWR and the Advisors


The results of the ADDM analysis are stored in the AWR in the form of findings. There are three different kinds of findings: Problem A problem indicates a root cause problem that is causing a database performance problem. Symptom A symptom indicates a performance issue that normally points to one or more specific problem findings. Information This is just basic database-related information that is not related to a specific problem.

Oracle Database 10g ADDM, AWR and the Advisors


You can review the findings a number of different ways: Via the Oracle data dictionary DBA_ADVISOR_TASKS - The execution of an ADDM analysis is a single task. DBA_ADVISOR_RECOMMENDATIONS Recommendations associated with a specific ADDM task execution. DBA_ADVISOR_FINDINGS Findings associated with a specific ADDM task execution. DBA_ADVISOR_RATIONALE Rationale associated with the specific ADDM recommendations.

Oracle Database 10g ADDM, AWR and the Advisors


Oracle provides a script (addmrpt.sql) to analyze a snapshot range. OEM also provides an interface into the ADDM findings. More information on AWR and it's findings see:
http://www.dbazine.com/olc/olc-articles/freeman3

Oracle Database 10g ADDM, AWR and the Advisors


The advisors are user run interfaces that use AWR and other sources of Oracle information (e.g. the rest of the data dictionary) to provide guidance on specific DBA activities. Advisors introduced in 10g include: Segment Usage Advisor UNDO Advisor Redo Logfile Size Advisor SQL Tuning Advisor SQL Access Advisor

Oracle Database 10g The SYSAUX Tablespace


The SYSAUX tablespace is a required tablespace in Oracle Database 10g. You will need to add the tablespace to your database as you migrate to Oracle Database 10g. It is created as a part of the create database command on new databases. SYSAUX is the storage location for many ancillary Oracle database files (like the Job scheduler, Ultra Search, Data mining, the Enterprise Manager repository and so on)

Oracle Database 10g New Merge Functionality


You can now optionally omit the update or insert clause of the MERGE statement.
Merge into emp_history eh using emp_history_adds eha on (eh.empno = eha.empno) when matched then update set eh.total_pay=eh.total_pay+eha.net_pay, eh.update_date=sysdate;

Oracle Database 10g New Merge Functionality


You can add a WHERE clause to each UPDATE and INSERT statement in the MERGE statement to allow for conditional execution of these statements.
Merge into emp_history eh using emp_history_adds eha on (eh.empno = eha.empno) when matched then update set eh.total_pay=eh.total_pay+eha.net_pay, eh.update_date=sysdate where eh.pay_code <> Retired;

Oracle Database 10g New Merge Functionality


You can use the optional delete clause to remove old data that is no longer needed:
Merge into emp_history eh using emp_history_adds eha on (eh.empno = eha.empno) when matched then update set eh.total_pay=eh.total_pay+eha.net_pay, eh.update_date=sysdate where eh.pay_code <> Retired delete where (eha.pay_code = DELETE) when not matched then insert (eh.empno, eh.total_pay, eh.update_date) values (eha.empno, eha.net_pay, sysdate) where eha.pay_code <> Retired;

Oracle Database 10g DML Logging Clause


All Oracle DML statements have a new error logging clause available. This lets you capture DML related errors and log them to a table. Use the dbms_errlog package to create the logging table.

Oracle Database 10g DML Logging Clause


SQL>Create table emp_data (eid number, sal number constraint sal_check check(sal > 5000)); begin dbms_errlog.create_error_log ('emp_data','errlog'); End; / SQL> Insert into emp_data values (1, 1000) log errors into errlog('Oops') reject limit 10; 0 rows created.

Oracle Database 10g DML Logging Clause


SQL> Select ora_err_mesg$, ora_err_tag$, eid, sal from errlog; ORA_ERR_MESG$ -----------------------------------------------------ORA_ERR_TAG$ -----------------------------------------------------EID -----------------------------------------------------SAL -----------------------------------------------------ORA-02290: check constraint (SCOTT.SAL_CHECK) violated Oops 1 1000

Oracle Database 10g New Partitioning Features


IOT Partitioning improvements List partitioning is now available for IOTs. Global maintenance operations (such as drop or exchange partition operations) of an IOT will not cause indexes to be marked as unusable. Indexes are now maintained as a part of the operation. All Partitioned IOT table types can now contain LOBs. IOT Mapping tables are partitioned if the IOT is partitioned. Partitions will share the same name.

Oracle Database 10g Hash Partitioned Global Indexes


Now global indexes can be range partitioned or hash partitioned. Each partition will contain a hashed value based on the partition key of the index, and the number of partitions in the index. You can add, coalesce, rebuild partitions of hash partitioned global indexes.

Oracle Database 10g Dealing with Unusable Indexes


A new parameter skip_unusable_indexes is available for use. Helps avoid ORA-01502s.

Oracle Database 10g Column Encryption


Available in 10gR2 when using Advanced Security. You must have enabled Advanced Security and a wallet must be opened. Columns in tables owned by sys can not be encrypted. A FK column can not be encrypted.

Oracle Database 10g Self Tuning SGA


Things that make the DBA and/or developer unhappy.
ORA-04031: unable to allocate 2216 bytes of shared memory ("shared pool"... ...

Or
ORA-04031: unable to allocate XXXX bytes of shared memory ("large pool","unknown object","session heap","frame")

or perhaps this one:


ORA-04031: unable to allocate bytes of shared memory ("shared pool", "unknown object","joxlod: init h", "JOX: ioc_allocate_pal")

All hail the arrival of the self tuning SGA!

Oracle Database 10g Self Tuning SGA


Oracle has introduce a new parameter sga_target. Disabled by default. Set this parameter the the total amount of memory you want Oracle to allocated to the following: Buffer cache Shared pool Large Pool Java Pool Streams pool (10gR2) Setting any of these to non-zero values will define minimum settings for these pools.

Oracle Database 10g Self Tuning SGA


Once set, Oracle will manage memory allocations as needed for you. Statistics_level must be set to at least TYPICAL. This parameter does not impact settings of: The redo log buffer The keep or recycle buffer pool Nondefault block-sized buffer cache pools. The SGA_TARGET Parameter is dynamic. It can be altered up to SGA_MAX_SIZE or down to the minimum setting.

Oracle Database 10g Self Tuning SGA


The Oracle configured parameters will appear in your SPFILE with double underscores in them ('__'). Example: __shared_pool_size __large_pool_size __java_pool_size If you want to see how often your memory is dynamically being adjusted v$sga_resize_ops Historical resize information V$sga_current_resize_ops Current resize operaitons How is my SGA configured currently? v$sgainfo

Oracle Database 10g Self Tuning SGA


Look like a brilliant Oracle consultant!! Help your clients tune their SGA! v$sga_target_advice
SQL> select * from v$sga_target_advice order by sga_size;

SGA_SIZE SGA_SIZE_FACTOR ESTD_DB_TIME ESTD_DB_TIME_FACTOR ESTD_PHYSICAL_READS ---------- --------------- ------------ ------------------- ------------------105 .75 267 1.1883 13077 140 1 225 1 11429 175 1.25 204 .9058 10707 210 1.5 201 .8924 10707 245 1.75 201 .8924 10707 280 2 201 .8924 10707

Oracle Database 10g


Time to stretch your legs and Win a book! Answer these questions and win a book!

1. Using a database view, how can you tell definitively that you are or are not using a SPFILE? 2. Which of these accounts does not have a default password that is the same as the account name? a. MDDATA b. MDSYS c. DMSYS d. OLAPSYS e. ORDSYS

Oracle Database 10g


Time to stretch your legs and Win a book! Answer these questions and win a book!

1. Using a database view, how can you tell definitively that you are or are not using a SPFILE? Use the v$spparameter view column isspecified. If it is set to FALSE for all columns then a SPFILE is not being used by the instance. If one column is set to TRUE, then an SPFILE is being used.

Oracle Database 10g


Time to stretch your legs and Win a book! Answer these questions and win a book!

2. Which of these accounts does not have a default password that is the same as the account name? a. MDDATA b. MDSYS c. DMSYS d. OLAPSYS Default is manager e. ORDSYS

Oracle Database 10g


Time to stretch your legs and Win a book! Anyone left standing?? Tie breaker questions Name the co-author of my book Oracle9i RMAN Backups and Recovery. Name the first book that I ever wrote. Finally. Answer this riddle.. It's dark. There are two men on a boat, each with a candle but no matches or other flaming devices. How to they manage to light a candle?

Oracle Database 10g Log_Buffer Changes


Starting in 10gR2 it does you no good to adjust the size of the log buffer down. (See Metalink note 373018.1). A minimum default is now established. As a result memory allocated to the redo log buffer will likley go up when upgrading to 10gR2. Oracle now combines the fixed SGA areas and the log buffer space into one area. As a result the redo buffer will have more space than expected or configured for in many cases. The log buffer is rounded up to the next granule size.

Oracle Database 10g Log_Buffer Changes


The hidden parameter _ksmg_granule_size establishes the granule size. To find the setting of your database granule size:
SELECT a.ksppinm "Parameter",b.ksppstvl "Session Value", c.ksppstvl "Instance Value" FROM x$ksppi a, x$ksppcv b, x$ksppsv c WHERE a.indx = b.indx AND a.indx = c.indx AND a.ksppinm = '_ksmg_granule_size'

Oracle Database 10g Fast-Start Fault Recovery


Oracle constantly is writing to the datafiles via fast-start checkpointing. This is to reduce the overall time it takes to perform crash recovery. This "evens" the write load of the Oracle database, reducing the need for bulk writes which leads to IO spikes. Oracle is careful not to interfere with database performance during fast-start checkpoints. Setting the parameter FAST_START_MTTR_TARGET to a zero value will disable fast-start checkpointing. Setting the parameter FAST_START_MTTR_TARGET to a non-zero value (represented in seconds) will enable faststart checkpointing.

Oracle Database 10g Fast-Start Fault Recovery


You should remove these parameters if you are going to use fast-start checkpointing (which I recommend) log_checkpoint_interval log_checkpoint_timeout fast_start_io_target You can view the MTTR advisor to determine the estimated impact of your MTTR target setting:
SELECT TARGET_MTTR, ESTIMATED_MTTR, CKPT_BLOCK_WRITES FROM V$INSTANCE_RECOVERY TARGET_MTTR ESTIMATED_MTTR CKPT_BLOCK_WRITES ----------- -------------- ----------------214 12 269880

Oracle Database 10g Optimal Log File Sizing


Another advisor that Oracle provides us with is the log file advisor. Provides a recommendation of the optimal size of your online redo logs. Query the column optimal_logfile_size (in MB) column in the v$instance_recovery view. (note that the FAST_START_MTTR_TARGET parameter must be set).
SQL> select optimal_logfile_size from v$instance_recovery; OPTIMAL_LOGFILE_SIZE -------------------49

Oracle Database 10g Recovery Through RESETLOGS


Oracle Database 10g supports easy recovery through the RESETLOGS command. A new format parameter for the archivelog file format facilititates this: %r, which identifies the logical incarnation of the database. This makes the archived redo log name unique through RESETLOGS, which makes recovery easy. The default log_archive_format in 10g on all platforms now includes the %r parameter.

Oracle Database 10g


Automated ARCH process Startup
In Oracle Database 10g, if the database is in ARCHIVELOG mode, then the ARCH process will be started automatically, regardless of the setting of the log_archive_start parameter.

Oracle Database 10g Alter database backup commands


If you manually backup your database, you can now put all tablespaces in hot backup mode with the alter database begin backup command. The alter database end backup command can now be used when the database is open.

Oracle Database 10g The Flash Recovery Area


The flash recovery area allows you to define a central area of disk space for recovery related file such as RMAN backups and archived redo logs. Configure the flash recovery area with these parameters: db_recovery_file_dest Location of the flash recovery area db_recovery_file_dest_size Amount of space that can be used by Oracle in the flash recovery area.

Oracle Database 10g The Flash Recovery Area


Benefits of the flash recovery area Oracle monitors its use, and can send out notifications if it is becoming full. Once centralized location for all backup files. Can be used by ASM, raw or cooked disks. The V$RECOVERY_FILE_DEST view is available to help with flash recovery area management. If the flash recovery area fills, what happens: Archiving stops Database stops You must find a way to release space, or modify the db_recovery_file_dest_size parameter.

Oracle Database 10g RMAN Improvements


RMAN automatically backs up to the flash recovery area if its defined. The backup as copy command allows you to create file image copies of database datafiles. This, along with the new switch database to copy command can reduce MTTR significantly. Catalog and uncatalog commands allow you to manage catalog entries of backup sets. RMAN supports the DROP DATABASE command. You can unregister a database from the recovery catalog in RMAN. RMAN will, if the redo is available, recover datafiles that are not backed up.

Oracle Database 10g RMAN Improvements


RMAN offers true compression (Like PKZIP or GZIP) of backup sets. Guess who creates tempfiles automatically now?? 10gR2 RMAN does, thats who!!

Oracle Database 10g RMAN Improvements


Incremental backups are improved in RMAN Block change tracking file allows for true block level incremental backups. Use the alter database enable block change tracking command to enable block change tracking. Use the alter database disable block change tracking command to enable block change tracking. If db_create_file_dest is configured the file will be stored there. Otherwise use the using file clause to define the location of the block change tracking file. V$BLOCK_CHANGE_TRACKING view provides information on the block change tracking file.

Oracle Database 10g RMAN Improvements


Did anyone say Security?? How long until you loose a backup off the back of a truck or to a rouge employee? How sensitive is your data anyway? RMAN backups can not be encrypted. Password encryption Set when the backup is executed using the set encryption on command. Transparent encryption Implimented using the Oracle Wallet. Dual mode encryption Choice of either password and transparent encryption in use.

Oracle Database 10g Connect Role Changes


The connect role. Do you ever grant it? Used to be considered a potential security issue. Has change in 10gR2. Oracle has reduced the privileges, removing: create table.. gone create view gone create sequence, create cluster, create synonym, create database link, create sequence, alter session. all gone Now only create session remains.

Oracle Database 10g Flashback *


Many new flashback features Flashback database Flashback the database to a point in time without recovery. flashback drop Allows you to recover tables that may have been accidentally dropped. New recycle bin (show recyclebin or dba_recyclebin). Restore from multiple copies in the recycle bin. Flashback versions query See all changes to rows in a table over a period of time.

Oracle Database 10g Flashback *


Many new flashback features Flashback Transaction Query Like log miner in a way, you can reconstruct SQL statements that have been previously executed in the database. Flashback Table You can flashback a table to a point in time different than the rest of the database.

Oracle Database 10g Flashback Database


Allows you to "flashback" the entire database to a specific point in time. Flashback to a timestamp, SCN or a restore point. Can be much quicker than recovering the database and performing point-in-time based recovery. Not a means of recovering a database in the event of physical loss or corruption of the database datafiles. New flashback database logs are used to facilitate flashback of the database. New RVWR process writes to flashback database logs. Flashback stand-by databases too!

Oracle Database 10g Flashback Database


New flashback database logs are used to facilitate flashback of the database. New RVWR process writes to flashback database logs.

Source: http://www.oracle.com/technology/deploy/availability/htdocs/Flashback_Overview.htm

Oracle Database 10g Flashback Database


Flashback database is very dependent on undo retention. The DB_FLASHBACK_RETENTION_TARGET parameter must be set high enough (default to 1440). You may wish to enable guaranteed undo retention for the database or specific tablespaces. You must have a flash recovery area defined in the database before you enable flashback.

Oracle Database 10g Flashback Database


Enable flashback database via the alter database command (database must be mounted).
alter database flashback on;

Oracle will create flashback logs in the flash recovery area. You can then use the flashback database command to flashback the database. To perform a flashback, the database must be mounted, not open. Examples:
SQL> Flashback database to timestamp (sysdate-2); SQL> flashback database to scn 2034455;

Oracle Database 10g Flashback Database


You can now open the database In read only mode to check if the you flashedback the database to the point in time you really wanted. You can continue to change the time or SCN to flashback too as needed. To restore back to the point where you started the database use the recover database command. For read-write using resetlogs to set flashback in stone. Flashback to before a resetlogs command!

Oracle Database 10g


Flashback Database Restore Points (10gR2)
Oracle 10gR2 adds restore points Normal restore point Depends on the setting of DB_FLASHBACK_RETENTION_TARGET parameter setting. Normal restore points can be aged out or dropped. You can have up to 2048 restore points. Restore points are maintained in the control file for a number of days specified in the parameter CONTROL_FILE_RECORD_KEEP_TIME.

Oracle Database 10g


Flashback Database Restore Points (10gR2)
Oracle 10gR2 adds restore points Guaranteed restore point Assures a restore regardless of the setting of the DB_FLASHBACK_RETENTION_TARGET parameter. Dependent on flashback logs only. Guaranteed restore points can only be dropped explicitly. Can use significant amounts of disk space in the flash recovery area.

Oracle Database 10g


Flashback Database Restore Points (10gR2)
Create restore points Create restore point rest_point; Create restore point guar_rp guarantee flashback database; Remove a restore point drop restore point guar_rp;

Oracle Database 10g


Flashback Database Restore Points (10gR2)
Manage restore points v$restore_point
SELECT NAME, SCN, TIME, DATABASE_INCARNATION#, GUARANTEE_FLASHBACK_DATABASE FROM V$RESTORE_POINT WHERE GUARANTEE_FLASHBACK_DATABASE='YES';
NAME SCN TIME DATABASE_INCARNATION# GUA

----------- ---------- -------------------- --------------------- --GUAR_RP 7956618 26-NOV-06 09.50.44.0 00000000 PM 8 YES

RMAN Also supports flashback database.

Oracle Database 10g


Flashback Database Restore Points (10gR2)
Other views v$database Indicates if flashback is enabled. v$flashback_database_log Information on flashback logs and estimates on space requirements in the FRA based on the undo retention target. v$flashback_database_stat Used to estimate the total amount of space that will be required for flashback database operations.

Oracle Database 10g Guaranteed Undo Retention


Undo availability is key to flashback operations. Oracle Database 10g offers guaranteed undo retention. Set at the database or undo tablespace level. Statements will fail if UNDO can not be guaranteed. RETENTION column in dba_tablespaces will tell you the current setting. Example:
SQL> select tablespace_name, retention from dba_tablespaces where tablespace='UNDOTBS1'; TABLESPACE_NAME RETENTION ------------------------------ ----------UNDOTBS1 GUARANTEE

Oracle Database 10g Flashback Table (drop)


Flashback table (drop) allows you to restore a table that you dropped. Takes advantage of the new recycle bin feature of Oracle.
Create table dropped_by_accident(id number); Drop table dropped_by_accident; Show recyclebin SQL> Show recyclebin
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME ---------------- ------------------------------ ------------ ------------------DROPPED_BY_ACCID BIN$veQKt/OtT8+4wry2mA1VwA==$0 TABLE 2006-11-26:22:12:34

Oracle Database 10g Flashback Table (drop)


Recyclebin Enabled by default Can view the contents show recyclebin dba_recyclebin (user, all versions too). Purge of the recyclebin Oracle purges as needed (to reclaim space). You can purge manually Purge recyclebin Drop object without sending it to the recyclebin Drop object_name purge;

Oracle Database 10g Flashback Table (drop)


10gR2 Turn off recyclebin with the recyclebin parameter. recyclebin=off What is preserved? Table Dependent objects (indexes, constraints, triggers) NOT FK's!! You will need to re-create FK's.

Oracle Database 10g Flashback Table (drop)


Give me back my table!! Flashback table table_name to before drop;
SQL> Drop table dropped_by_accident; SQL> flashback table dropped_by_accident to before drop; Flashback complete. SQL> desc dropped_by_accident Name Null? Type --------------------------------- -------- -----ID NUMBER

Oracle Database 10g Flashback Table (drop)


Supports multiple versions of the same table being dropped and re-created.
SQL> show recyclebin ORIGINAL NAME ---------------DROPPED_BY_ACCID ENT DROPPED_BY_ACCID ENT RECYCLEBIN NAME OBJECT TYPE DROP TIME ------------------------------ ------------ ------------------BIN$XBXwZvTbRqSKh6Tu1w+18g==$0 TABLE 2006-11-26:22:21:55 BIN$SvBTQxTzQuCZSAD1teq45g==$0 TABLE 2006-11-26:22:21:37

Flashback based on the recyclebin name:


Flashback table "BIN$SvBTQxTzQuCZSAD1teq45g==$0" to before drop;

Look at a table in the recyclebin:


Select * from "BIN$SvBTQxTzQuCZSAD1teq45g==$0";

Oracle Database 10g Flashback Table (drop)


Rename to something else
Flashback table boots to before drop rename to 'boots_temp';

Oracle Database 10g Flashback Table


Flashback a table to a different point in time Must enable row movement (alter table enable row movement) Gotta have the undo!
Flashback table boots to scn 100000; Flashback table to timestamp sysdate 1; flashback table emp to TIMESTAMP to_timestamp(2003-09-30 09:00:00, YYYY-MM-DD HH:MI:SS);

Oracle Database 10g Other Flashback Functions


Flashback Versions Query Allows you to see all versions of a given set of rows between two separate timestamps. For example, you could see how an employees salary has changed over time.
SELECT ename, sal, versions_starttime FROM emp VERSIONS BETWEEN TIMESTAMP SYSTIMESTAMP - INTERVAL '15' MINUTE AND SYSTIMESTAMP WHERE empno=22; ENAME SAL VERSIONS_STARTTIME ---------- ---------- --------------------FREEMAN 25000 26-NOV-06 10.45.24 PM FREEMAN 10000 26-NOV-06 10.39.02 PM

Oracle Database 10g Other Flashback Functions


Oracle supports lots of pseudo columns for use with flashback version query Versions_startscn Effective time of row creation Versions_starttime Versions_endscn Effective time of row expire. Versions_endtime Versions_xid Transaction that created the row version. Versions_operation Type of operation (insert, delete, etc)
ENAME SAL VERSIONS_STARTTIME VERSIONS_ENDTIME -------- ------- --------------------- --------------------FREEMAN 25000 26-NOV-06 10.45.24 PM FREEMAN 10000 26-NOV-06 10.39.02 PM 26-NOV-06 10.45.24 PM

Oracle Database 10g Other Flashback Functions


Only committed changes can be seen. UNDO_RETENTION parameter is critical, UNDO must be available to reconstruct the change.
ORA-30052: invalid lower limit snapshot expression

Oracle Database 10g Other Flashback Functions


Flashback Transaction Query allows you to reconstruct SQL statements to undo a given transaction. Uses the view flashback_transaction_query. Example query
SELECT xid, logon_user FROM flashback_transaction_query WHERE xid IN (SELECT versions_xid FROM emp VERSIONS BETWEEN TIMESTAMP SYSDATE - INTERVAL '15' MINUTE AND SYSDATE WHERE empno=22); XID ---------------04000E00ED120000 04000E00ED120000 LOGON_USER ---------SCOTT SCOTT

Oracle Database 10g Other Flashback Functions


Combine flashback version query and flashback transaction query
SELECT xid, start_scn START, commit_scn COMMIT, operation OP, logon_user USER, undo_sql FROM flashback_transaction_query WHERE xid = HEXTORAW('04000E00ED120000'); XID START_SCN COMMIT_SCN OPERATION ---------------- ---------- ---------- ------------------------LOGON_USER -----------------------------UNDO_SQL ---------------------------------------------------------------04000E00ED120000 7959083 7959085 UPDATE SCOTT update "SCOTT"."EMP" set "SAL" = '10000' where ROWID = 'AAAMfPAAEAAAAAdAAA'; 04000E00ED120000 SCOTT 7959083 7959085 BEGIN

Oracle Database 10g ORA_ROWSCN Pseudo Column


New pseudo column is available ORA_ROWSCN Contains the SCN associated with each row. Tracks at a block level by default. Can enable at a row level on a by table basis. Great for web applications that want to take advantages of optimistic locking.

Oracle Database 10g Data Pump


Oracle Data Pump replaces import/export Client/server type of operation Data pump export estimates the size of export files. Suspend and resume jobs at will. Restart failed jobs from the point of failure. Fine-grained exports of objects. Parallel export and import operations. Direct mode exports and imports! Extracts via direct path or using external tables. Support to load from one database into another at the same time. Support from different kinds of extractions and imports: Object metadata, just data and metadata and data.

Oracle Database 10g


Cross Platform Transportable Tablespaces
You can now transport tablespaces across platforms. You may need to convert the tablespace with RMAN first, if the byte ordering (big or little endian) is different on the two platforms. You can convert a tablespace or datafiles. You can determine your database format by looking at the ENDIAN_FORMAT column of v$transportable_platform. If you dont need to convert, simply transport the tablespace over.

Oracle Database 10g


Cross Platform Transportable Tablespaces

Source: http://www.oracle.com/technology/deploy/availability/htdocs/xtts.htm

Oracle Database 10g


Cross Platform Transportable Tablespaces

See v$transportable_platform to determine what your OS Byte format is


Source: http://www.oracle.com/technology/deploy/availability/htdocs/xtts.htm

Oracle Database 10g


Cross Platform Transportable Tablespaces
Example of using RMAN to convert a tablespace (Linux is Little Endian byte format, so this might be an example of converting from Solaris (Big Endian) to Linux)
RMAN> CONVERT TABLESPACE 'USERS' TO PLATFORM = 'Linux IA (32-bit)' DB_FILE_NAME_CONVERT = '/u01/oradata/rob/users01.dbf', '/dba/recovery_area/transport_linux'

Oracle Database 10g


Cross Platform Transportable Tablespaces
Some restrictions still exist Source and target databases must be same character set and National Character Set. You cannot transport a tablespace to a target database in which a tablespace with the same name already exists. Instead rename either the tablespace to be transported or the destination tablespace before the transport operation. The new Oracle data types Binary_float and binary_double are supported (only be data pump). System, undo, sysaux, and temp tables cannot be transported

Oracle Database 10g New External Table Features


You can now write to external tables The write operation is a one time bulk write operation using the create table as select command. This allows you to move data easily outside of the database. Must use the new data pump access driver, available in Oracle Database 10g. Parallel load processes are supported by declaring multiple output files in the create table statement.

Oracle Database 10g New External Table Features


Example:
Create table emp_history_ext (ename, retire_date, last_retirement_pay_date, pay_amount) organization external ( type oracle_datapump default directory external_directory location (emp_history_01.exp, emp_history_02.exp) ) parallel as select a.ename, b.retire_date, b.last_retirement_pay_date, b.pay_amount from emp a, retire_pay b where a.empno=b.empno;

Oracle Database 10g Materialized Views?


What is the easiest way to turn this SQL query into a refresh fast on commit materialized view? How big will it be? These are all questions we might find ourselves asking.
SELECT s.prod_id, s.cust_id, SUM(s.amount_sold) sum_amount FROM sales s, customers cs WHERE s.cust_id = cs.cust_id GROUP BY s.prod_id, s.cust_id;

Oracle Database 10g Materialized Views?


The DBMS_ADVISOR.TUNE_MVIEW procedure will give us what we want to know.
Declare V_sql varchar2(2000); V_task_id varchar2(30):='MY_TASK'; Begin V_sql:='create materialized view my_view Refresh fast on commit as Select s.prod_id, s.cust_id, sum(s.amount_sold) Sum_amount from sales s, customers cs Where s.cust_id=cs.cust_id Group by s.prod_id, s.cust_id'; Dbms_advisor.tune_mview(v_task_id, v_sql); End; /

Oracle Database 10g Materialized Views?


We now look at the user_tune_mview table for the results
select action_id, script_type, statement from user_tune_mview where task_name='MY_TASK';

Oracle Database 10g Materialized Views?


We now look at the user_tune_mview view for the results
ACTION_ID SCRIPT_TYPE ---------- -------------STATEMENT --------------------------------------------------------3 IMPLEMENTATION CREATE MATERIALIZED VIEW LOG ON "SH"."SALES" WITH ROWID, SEQUENCE ("PROD_ID","CU 4 IMPLEMENTATION ALTER MATERIALIZED VIEW LOG FORCE ON "SH"."SALES" ADD ROWID, SEQUENCE ("PROD_ID" 5 IMPLEMENTATION CREATE MATERIALIZED VIEW LOG ON "SH"."CUSTOMERS" WITH ROWID, SEQUENCE ("CUST_ID"

Oracle Database 10g Materialized Views?


ACTION_ID SCRIPT_TYPE ---------- -------------STATEMENT --------------------------------------------------------6 IMPLEMENTATION ALTER MATERIALIZED VIEW LOG FORCE ON "SH"."CUSTOMERS" ADD ROWID, SEQUENCE ("CUST 7 IMPLEMENTATION CREATE MATERIALIZED VIEW SH.MY_VIEW ROWID DISABLE QUERY REWR 8 UNDO DROP MATERIALIZED VIEW SH.MY_VIEW

REFRESH FAST WITH

Oracle Database 10g Materialized Views?


How big will my MVIEW be? Use the dbms_mview.estimate_mview_size package.

Oracle Database 10g Materialized Views?


Set serveroutput on size 99999 Declare v_num_rows number; v_num_bytes number; V_sql varchar2(2000); Begin

V_sql:='Select s.prod_id, s.cust_id, sum(s.amount_sold) Sum_amount from sales s, customers cs Where s.cust_id=cs.cust_id Group by s.prod_id, s.cust_id'; Dbms_mview.estimate_mview_size ( stmt_id => 'MVIEW_ESTIMATE', select_clause=>v_sql, num_rows=>v_num_rows, num_bytes=>v_num_bytes); Dbms_output.put_line('Rows= '||v_num_rows); Dbms_output.put_line('Bytes= '||v_num_bytes); End; / Rows= 359386

Oracle Database 10g Materialized Views?


Rows= 359386 Bytes= 23719476 (23MB)

Oracle Database 10g Commitment No Waiting


Your sitting there. Waiting for some big SQL job to finish running.. It commits, a lot. Nukes, did someone say nukes are coming this way You say I can't leave until the job is completed? We need to speed up this job!! How about a lazy commit!! Or You say we DBA's need yet another thing to worry about developers doing??

Oracle Database 10g Commitment No Waiting


10gR2 offers many different commit options:
Immediate Forces the transfer of the commit related data from the log buffer to disk. Batch Indicates to Oracle that it should batch up commit related redo in the redo buffer and write is in a batch. Each of these commit options comes with two additional options: Wait Causes Oracle to wait until the physical IO writes have completed. Nowait Allows the commit to return before the redo is written.

Oracle Database 10g Commitment No Waiting


The default is immediate wait. This can be controled by the parameter COMMIT_WRITE. Note that use of any asynchronous option (using the nowait option) can cause loss of data, but can also improve performance. Example
begin for tt in 1..100000 loop insert into test_table values (id_seq.nextval, 'this is a test. commit write batch nowait ; end loop; end; /

Oracle Database 10g Finally Empty Datafiles


Ready Aim Drop You can now drop empty datafiles with the alter tablespace command.
ALTER TABLESPACE testtbs1 DROP DATAFILE 55;

You can not drop the last datafile in a tablespace. Can't drop a datafile with data.

Summary
Well that was about 140 slides of Oracle10g New Features for you! 11g is coming next year! Thanks for coming!!

Вам также может понравиться