About The Presenter

• Robert Freeman

<Insert Picture Here>

Oracle Certified Professional Exam (OCP) – 1Z0-053
Robert G Freeman Master Principal Sales Consultant – Public Sector

• Oracle OCP • Over 20 years experience in IT. • Oracle DBA for over 20 years. • Master Principal Consultant for Oracle Corp. • Presents frequently. • Have worked at many large Oracle clients. • I have a number of Oracle Books published including OCP: Oracle Database 11g Oracle Certified Professional Exam Preparation Guide.

Agenda
 We will discuss the major objectives covered in the Oracle Database 11g OCP Exam (1Z0-053).  As a consequence of time and the number of topics covered in the exam we will only cover specific topics in this class.  The topics we will cover are those with the most coverage in the exam.

Schedule For Today

• 0900 – 1000 Class • 1030 – 1045 Break • 1045 – 1200 Class • 1200 – 1300 Lunch • 1300 – 1500 Class • 1500 – 1530 Break • 1530 – 1700 Class

Becoming an Oracle OCP
• Requires 3 tests • SQL Fundamentals • OCA • OCP • Requires 1 Oracle course • If you are already an OCP • Take the upgrade exams • 8i to 9i • 8i to 10g • 9i to 10g • 10g to 11g

Becoming an Oracle OCP
•The Oracle Database 11g OCP Exam • 11g – 1Z0-053 • Perhaps the loooongest beta exam period ever!! • Finally in production. • Passing score 66% • Cost - $195.00 • Find the details at:

http://education.oracle.com

• Anyone here for something other than this? • Questions before we get started?

1

Becoming an Oracle OCP
•To prepare for the exam • Education.oracle.com • Exam objectives • Other exam related information • Practice Exams • Self-Test Software • Transcender • Links to both companies can be found

Becoming an Oracle OCP
• Prepare for the fire hose! • Topics in the OCP Exam we will cover today
• ASM

on Oracle’s education/certification web site.

• User Managed Backup and Recovery • RMAN Backup and Recovery • Flashback Database Features • Diagnosing The Database And Performance • Managing Database Resources • The Oracle Scheduler

Becoming an Oracle OCP
• OCP Exam topics we do not cover in this session due to time constraints.
• Database Resource Manager • Create Windows and Job Classes • Use advanced Scheduler concepts to prioritize jobs • Globalization Support

ASM – OCP Objectives
•Describe Automatic Storage Management (ASM) •Set up initialization parameter files for ASM and database instances •Start up and shut down ASM instances •Administer ASM disk groups

ASM – What is ASM?
• Automated Storage Management (ASM) is designed to simplify Oracle database file administration. • ASM is somewhat like a logical volume manager. • ASM also provides • Redundancy configurations • Automated rebalancing operations • We use this feature to pre-create databases, and later provision additional disks! • When using RAC and Oracle Clusterware, ASM provides the ability to share database related files.

ASM – Other Features
• Automatic software data striping (RAID 0) • Load balancing across physical disks • Software RAID 1 data redundancy with double or triple mirrors • External Redundancy (No mirror) • Normal Redundancy (1 mirror) • High Redundancy (2 mirror) • Elimination of fragmentation • Elimination of file management • Ease of maintenance

2

ASM - Architecture
• ASM runs in the form of the ASM instance. • Each database server has one ASM instance. • Each ASM instance can be used by one or more databases on the server. • The ASM instance is called +ASM.

ASM - Architecture
• ASM stores files in disk groups. • Logical entities made up of one or more physical disk drives (LUNS, etc…) that are assigned to that disk group.

ASM - Architecture
• ASM is designed to store all sorts of database related files including • Oracle datafiles • Database tempfiles • Online redo logs • Archived redo logs • Control files • SPFILES • RMAN Backup Sets • The flash recovery area (FRA) • Datapump dump sets

ASM – Restrictions and Limits
• ASM limits you to 63 disk groups in a given storage system. • You can have up to a maximum of 10,000 ASM disks in a given storage system. • Each ASM disk (LVM, etc) can be up to a maximum of 4 petabytes in size. • Each ASM instance can manage up to 40 Exabytes of storage. • Each disk group can contain up to one million files

Creating the ASM Instance ASM – Restrictions and Limits
• Maximum ASM file sizes vary on the type of disk group: • External redundancy disk group – 140 PB Maximum file size • Normal redundancy disk group – 42 PB maximum file size • High redundancy disk group – 15 PB maximum file size • Created using DBCA or manually (Oracle recommends using DBCA). • Parameter file for ASM instance is not unlike a database parameter file • Can be PFILE or SPFILE. • Uses a combination of parameters • Only one required parameter - instance_type • Can contain a combination of • ASM specific parameters (start with ASM_) • Some database parameters (memory_target)

3

Alter system set ASM_DISKSTRING=’?/disks/d1/*. • ASM_DISKSTRING can identify multiple candidate disks. Creating ASM Disk Groups • Once disk discovery has found disks. • Parameter file for ASM instance is a basic parameter file. Describes each disk that was discovered by the ASM instance. • V$ASM_FILE Displays each ASM file contained in the ASM instance. ASM Views • V$ASM_DISKGROUP • V$ASM_DISK Describes a given disk group. • V$ASM_CLIENT Displays each database that is using at least one disk group managed by the ASM instance.6.0 remote_login_passwordfile=exclusive Starting the ASM Instance • You use SQL*Plus to start the ASM instance. • Use the create diskgroup command to create disk groups. • Example setting ASM_DISKSTRING. • Use the startup mount command to start the ASM instance. Creating the ASM Instance • Example: ############################################## # ASM Parameter File . ASM Disk Discovery • When the ASM instance is started disk discovery begins. 4 . This is done when databases are backed up. Note that discovery will occur each time query this view.UNIX # ASM_DISKGROUPs='DISK GROUP_ROB1' ############################################## # Diagnostics and Statistics ########################################### background_dump_dest=/u01/app/oracle/admin/+ASM/bdump core_dump_dest=/u01/app/oracle/admin/+ASM/cdump user_dump_dest=/u01/app/oracle/admin/+ASM/udump ########################################### # Miscellaneous # Of course – set compatible to your version of Oracle ########################################### instance_type=asm compatible=11. • The ASM_DISKSTRING parameter is used to identify candidate disks for the ASM instance.1. Discovery will occur each time query this view. • No need to backup the ASM instance. you can create disk groups.Creating the ASM Instance • Created using DBCA or manually (Oracle recommends using DBCA).0.?/disks/d21/*'. • Example CREATE DISKGROUP dgroup1 NORMAL REDUNDANCY failgroup diskcontrol1 DISK '/devices/diska1' failgroup diskcontrol2 DISK '/devices/diskb1'. • The process of finding candidate disks is known as discovery.

56. ASM Administration • Use the alter diskgroup command to: •Add disks to an ASM disk group •Remove disks from an ASM disk group •Adding and Dropping disks from an ASM disk group •Undrop disks from an ASM disk group •Resize disks in a disk group •Manually rebalance a disk group •Mount and unmount disk groups •Check the consistency of a disk group •Create ASM disk group directories •Manage ASM disk group directories • If the disk group has files in it then you need to use the including contents parameter as seen here: Drop diskgroup sp_dgroup2 including contents. • ASM Filename Alias with Templates • Incomplete ASM Filenames •+Sp_dgroup1 • Incomplete ASM Filenames With Templates • +Sp_dgroup1(special_template) 5 . ASM Files • You can set ASM disk groups as default locations.Dropping ASM Disk Groups •Use the drop diskgroup command to drop an ASM disk group • Example DROP DISKGROUP dgroup1 . create tablespace another_test datafile ’+COOKED_DGROUP1’ size 100k. • Example execution of the CREATE TABLESPACE command using an ASM disk group as the datafile location will result will be the creation of ASM files in that ASM disk group. ASM Files • Example ASM File Name +sp_dgroup2/mydb/controlfile/Current. ASM Files • ASM files are physical files stored within ASM disk groups. •DB_CREATE_FILE_DEST •DB_CREATE_ONLINE_LOG_DEST_n •DB_RECOVERY_FILE_DEST •CONTROL_FILES •LOG_ARCHIVE_DEST_n •LOG_ARCHIVE_DEST •STANDBY_ARCHIVE_DEST Alter system set db_create_file_dest=’+cooked_dgroup1’ scope=both.544956473 •+Group_name/your_assigned_alias •+sp_dgroup2/ctrl_files/control_file_01(special) • This is known as a fully qualified ASM Filename. • ASM files can be created in a number of different ways.544956473 {disk group} {DB} {file_type} {file_name} ASM Files • Other types of ASM file names • ASM Numeric File name • ASM Filename Alias •+sp_dgroup2.56.

ASM Templates • When you create an ASM disk group. • The template used defines the level of striping • Fine – 128k stripe size • Coarse – AU Size for disk group is selected. • Each attribute is matrixed to a specific file type.---------1 256 DATAFILE 14 114688 Creating Tablespaces Using ASM Examples • Specific location create tablespace another_test datafile ’+COOKED_DGROUP1’ size 100k. Select tablespace_name. ASM Templates •. 2-way mirroring and 3way mirroring are supported.256.256.dbf’.The template also define the amount of mirroring that is used. type. •Rename an alias Alter diskgroup cooked_dgroup1 Rename alias ’+cooked_dgroup1/alias_dir/alias_tbs_01. TABLESPACE FILE_NAME ---------. if you create a disk group using the default template and then create datafiles in that disk group. file_name from dba_data_files Where tablespace_name=’ANOTHER_TEST’.613064385 SQL> select group_number.----------.dbf’ To ’+cooked_dgroup1/datafiles/alias_tbs_01. Oracle will assign a default template to that disk group. file_name from dba_data_files Where tablespace_name=’TEST_RGF’. GROUP_NUMBER FILE_NUMBER TYPE BLOCKS BYTES -----------.---------. No mirroring. blocks.-------------------------------------------------------TEST_RGF +COOKED_DGROUP1/11gDB/datafile/test_rgf. • A template is simply a named collection of attributes.-------------------. Select tablespace_name.---------------------------------------------------------ANOTHER_TEST +COOKED_DGROUP1/11GDB/datafile/another_test.dbf’ FOR ‘+cooked_dgroup1/11GDB/datafile/alias_tbs. • With asmcmd you can: • List contents of ASM disk groups • Perform searches (like directory listings) • Add or remove directories • Display space availability and utilization 6 .61316861 1’. bytes from v$asm_file.613065911 ASM – The ASMCMD Command •The asmcmd tool is a command line utility that allows you to manage ASM instances and the disk structures and files within those instances. the datafile template will define the redundancy and striping for that data Creating Tablespaces Using ASM Examples • Uses default location create tablespace test_rgf datafile size 100k. • IE: Controlfile or datafile. TABLESPACE_NAME FILE_NAME --------------.260. file_number. • For example.ASM File Aliases •Create an alias with the alter disk group command: Alter diskgroup cooked_dgroup1 add alias ‘+cooked_dgroup1/alias_dir/alias_tbs_01.

• Understand how ASM can relieve you of manually optimizing I/O across all files in the tablespace by using ASM disk groups. Remove an ASM directory or file. 7 . Create an ASM directory Locate where you are on the ASM directory tree. Understand what a failure group is and how they are created. Understand the different system templates for creating ASM files with the associated filename and how the characteristics are applied to the ASM files. • Examples: Command Cd Du Find Help Ls Mkdir Pwd Rm Purpose Change ASM directory Disk Used Find directory or file Display the help screen List files in directory. Configure DB_UNIQUE_NAME for an ASM instance. whether a new ASM file is being created. ASM Exam Cram What do you need to know? Be able to create an ASM instance and configure its initialization parameters.ASM – Starting ASMCMD •Starting ASMCMD C:\>Set ORACLE_SID=+ASM C:\>asmcmd ASMCMD Commands • ASMCMD commands are much like UNIX commands. noting the dependencies with database instances that are using the ASM instance’s disk groups. Describe what happens when an ASM instance is shut down normally or is aborted. or whether multiple ASM files are being created. Differentiate how different ASM filename formats are used and files are created depending on whether the file is an existing ASM file. ASM Exam Cram What do you need to know? Understand the architecture of an ASM instance. Understand about ASM Fast Disk Resync and about preferred mirror read. and ASM_DISKGROUPS. ASM_POWER_LIMIT. ASM_DISKSTRING. • Understand the initialization parameters INSTANCE_TYPE. ASM Exam Cram What do you need to know? Understand how ASM filenames are constructed and used when creating Oracle objects. • Show how ASM operations can be performed online with minimal impact to ongoing database transactions. Show how ASM files are used in SQL commands. • Start up and shut down an ASM instance. Example cd +group1 Du Find + rob11g Help Ls –l Mkdir old Pwd Rm –r current* Or from UNIX: /opt/oracle>export ORACLE_SID=+ASM /opt/oracle>asmcmd ASM Exam CRAM What do you need to know? Enumerate the benefits and characteristics of Automatic Storage Management (ASM). Understand Redundancy and Resync Describe what redundancy is and how it’s implemented in ASM. Enumerate the different states for an ASM instance. Understand and describe the differences between an RDBMS instance and an ASM instance.

and opening the database with RESETLOGS. editing the SPFILE. User Managed Backup Configure Backup Settings User Managed Backup Configure Backup Settings • Main Oracle processes related to backup and recovery • DBWR • LGWR • ARCH • SMON/PMON • CKPT • Oracle memory structures related to backup and recovery • SGA User Managed Backup Configure Backup Settings User Managed Backup Configure Backup Settings • The Data Dictionary • Key role in user managed backups. • Different dictionary views • V$ • DBA/USER/ALL_* • The Data Dictionary • Demonstrate the use of the data dictionary 8 . User Managed Backup OCP Objectives • Configure Backup Settings • Configure multiple archive log file destinations to increase availability. • Identify the need of backup mode. and alter ASM disk groups. Understand the ASM disk group attributes and how they are used. • Perform user-managed backups • Backup a Control File Define multiple failure groups for new disk groups and make sure you understand how the number of failure groups is different for two-way and three-way mirroring. drop. Identify the steps involved in converting nonASM files to ASM files using RMAN. Show how disk rebalancing can be controlled or rolled back.ASM Exam Cram What do you need to know? Be able to create. running an RMAN script for each file to be converted. Migrate a database to ASM disk groups by shutting down the database.

User Managed Backup Configure Backup Settings User Managed Backup Configure Backup Settings • Physical File Structures Related to Backup and Recovery • Oracle Datafiles • Oracle Tablespaces • Online redo logs • Control Files • Parameter Files • Database Modes • Impact the kind of recovery that you can do. • Backup operations while the instance is down and the database is not open. • Online backups. • Startup • Control file backups • Backup control file • Trace file – Create controlfile 9 . the big picture • Backup operations while the instance is down and the database is not open. User Managed Backup Offline Cold Backups User Managed Backup Offline Cold Backups • Locate • Datafiles • Control Files • Online redo logs • Database Down • Recommended – Consistent Shutdown • Shutdown • Shutdown immediate • Shutdown transactional • Backup • Datafiles • Control Files • Online redo logs • Recommend – Control file backups • Bring Database Back Up. • Copy the SPFILE to a PFILE (any mode) • Copy the PFILE to a SPFILE (any mode) • Manual cold backups. • NOARCHIVELOG • ARCHIVELOG User Managed Backup Configure Backup Settings User Managed Backup Key Things To Remember • The Oracle Instance • The Oracle Database • Backup and Recovery.

• Test with alter system switch logfile command. • ARCHIVELOG Mode • Archived Redo logs • ARCHIVELOG Mode • Configuring Archivelog Destination Directories • LOG_ARCHIVE_DEST_n • LOG_ARCHIVE_FORMAT • Flash Recovery Area (FRA) • DB_RECOVERY_FILE_DEST • DB_RECOVERY_FILE_DEST_SIZE User Managed Backup Online Backups • ARCHIVELOG Mode • Put the database in ARCHIVELOG mode • Shutdown consistently • Normal • Immediate • Transactional • Startup mount • Issue Alter database archivelog command. and how these differences can be used to decide the optimal backup strategy. • Understanding the mechanics of online backups. • Issue alter database open command. You will need to understand parameters such as LOG_ARCHIVE_DEST_1 and how to configure them. User Managed Backups Exam Cram What do you need to know? Be able to configure a database for user initiated online backups Understand the different parameters that need to be configured when you are going to backup a database with user based online backups. Wait for it to complete • Backup archived redo logs. 10 . User Managed Backups Exam Cram What do you need to know? Backup your database with an offline backup Understand the steps that need to be performed with an offline backup and do an offline backup. You will need to understand what happens if you have two archivelog destination directories defined. • Perform a log switch. User Managed Backup Executing an Online Backup • Steps for manual online backups • Put tablespaces in hot backup mode • Alter database begin backup • Alter tablespace begin backup • Backup datafiles • Take tablespaces out of hot backup mode • Alter database end backup.User Managed Backup Online Backups User Managed Backup Online Backups • Online backups – Backup the database while it’s running. • Backup control file. Understand the difference between an offline backup and an online backup. • Alter tablespace end backup.

Understand how to determine which archived redo logs you will need to backup when doing an online backup. Understand what a backup control file is. • Assumes online redo logs are intact.User Managed Backups Exam Cram What do you need to know? Backup your database with an online backup Know how to configure your database for an online backup. • Replace all database files previously backed up: • Datafiles • Control Files • Online redo logs. Understand how to put the database in ARCHIVELOG mode so you can do online backups. Do an online backup. Backup your database control file Understand why it is important to backup your control file. 11 . • If the database is not already down – shut it down. Understand the different method of backing up your control file. User Managed Recovery OCP Objectives • Perform User-managed complete database recovery • Perform user-managed incomplete database recovery • Backup and Recover a Control File • Recover from a lost TEMP file • Recover from a lost redo log group • Recover from the loss of a password file User Managed Recovery User-Managed Complete Database Recovery in NOARCHIVELOG Mode • Only full recovery available on NOARCHIVELOG mode. • Startup the database User Managed Recovery User-Managed Complete Database Recovery in ARCHIVELOG Mode • What is ARCHIVELOG mode? • Archived redo logs • ARCH process • Rules Oracle follows User Managed Recovery User-Managed Complete Database Recovery in ARCHIVELOG Mode • Many recovery options in ARCHIVELOG mode • Full • All Datafiles • Specific Tablespaces (some online) • Specific Datafiles (some online) • Loss of online redo logs • Point-in-time (entire database) User Managed Recovery User-Managed Complete Database Recovery in ARCHIVELOG Mode • Full ARCHIVELOG Mode Database Recovery • Shutdown database • Restore control file if required • Restore all datafiles • Recover database • Open the database.

User Managed Recovery User-Managed Control File Backups User Managed Recovery User-Managed Control File Backups • Backup the control file • alter database backup controlfile to trace. RMAN Backup Starting RMAN • Once configured. unarchived online redo log. • Create an archival backup for long-term retention • Create a multi-section compressed and encrypted backup. • Loss of the active online redo log. • RMAN always connects as SYSDBA! • Examples: Rman target=/ Rman target=/ catalog=cat_user/robert@catalog 12 . • Recover from a lost control file • Using Trace File • Using backup control file User Managed Recovery Redo Log Loss User Managed Recovery Other User-Managed Recovery Issues • Loss of an inactive archived online redo log. • Loss of an inactive. • RMAN is a command line driven client. • Configure backup optimization. • alter database backup controlfile to ’filename’. RMAN is ready to back up. apply and use a retention policy • Configure and use the Flash Recovery Area • Create image file backups • Allocate channels to use in backing up. • Restoring a lost TEMPFILE • Restoring a lost password file RMAN Backup OCP Objectives • Configure channels to use in backing up. • OEM interface into RMAN. • Define. • Create a whole database backup • Enable fast incremental backup • Create duplex backup and back up backup sets. Not present in the exam.

RMAN Backup Configuring RMAN RMAN Backup Configuring RMAN •What do we configure? • Channels • Example (Note the %U format option!) CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oracle01/backup/orcl/%U'. RMAN Backup Configuring RMAN RMAN Backup Configuring RMAN • Datafile and Archivelog backup copy configuration • Known as duplexing • Creates multiple copies of backup at the same time. • Applies to: • Datafiles • Archived redo logs • Backup Sets Configure backup optimization on. RMAN> Configure encryption for database on. Configure datafile backup copies for device type disk to 2. 13 .RMAN Backup Configuring RMAN • RMAN Architecture in brief •The RMAN client interface •The database server •The database control file •The optional recovery catalog •Database pfile or spfile •Backup Media and the Media Management Library (MML) •Backup sets and Backup set pieces •RMAN Channels •Snapshot Control File •Flash Recovery Area (FRA) RMAN Backup Configuring RMAN • Persistent configuration settings make RMAN easier to use. • Default channel/device configuration configure channel 1 device type sbt. • Parallelism Configure device type disk parallelism 2. • Example of setting RMAN persistent configuration settings: CONFIGURE RETENTION POLICY TO REDUNDANCY 1. • FRA • DB_RECOVERY_FILE_DEST • DB_RECOVERY_FILE_DEST_SIZE • CONTROL_FILE_RECORD_KEEP_TIME Parameter • Independent of retention criteria! • Control File autobackup configuration Configure controlfile autobackup on. •What do we configure? • Backup (database and archivelog) retention criteria • None • Redundancy (the default) • Recovery window configure retention policy to redundancy 1 . • Default encryption settings • Available encryption algorithms in V$RMAN_ENCRYPTION_ALGORITHMS • Configure as follows: RMAN> Configure encryption algorithm "AES128". •What do we configure? • Backup optimization • Tells RMAN that you don’t want to backup a database file if that backup is not needed.

• Use the backup command • Must backup archived redo logs • Example: Backup database plus archivelog delete input. • Multiplexed – Multi database datafiles in backup set pieces. • Demo of configuring RMAN persistent settings. • Mount mode allows access to the control file. • Use the backup command • Example: Backup database. • May be in multiple backup set pieces. RMAN Backup RMAN Backups RMAN Backup RMAN Backups – Offline Backups • More terms you need to know: • Image copies • Offline backup • Online backup • Offline backups occur with the database mounted. RMAN is ready to back up. RMAN Backup RMAN Backups – Online Backups RMAN Backup RMAN Backups – Online Backups • Online backups occur with the database open. • Default location for the snapshot control file. Configure snapshot controlfile name to ’/oracle01/backup/sncf/sncforcl.ora’. • Backup Set Piece • Physical • One or more per backup set. • One database datafile in only one backup set. • Control file maintains records related to RMAN. 14 . • Control file maintains records related to RMAN. • Default compression settings configure device type disk backup type to compressed backupset.RMAN Backup Configuring RMAN RMAN Backup RMAN Backups • Once configured. • Database in ARCHIVELOG mode • To put in ARCHIVELOG mode • Configure FRA/Backup locations • Shutdown (consistent) • Startup mount • alter database archivelog • alter database open • Online backups occur with the database open. • Exception – Multi-section backups. • Terms you need to know: • Backup Set • Logical • At least one per channel.

• The result is a new full backup. Recover copy of database with tag ’Jacob_Jared_Lizzie’. • Faster restores. RMAN Backup RMAN Backups – Incrementally Updated Backups RMAN Backup RMAN Backups – Incrementally Updated Backups • A combination of a full image backup of the database and then subsequent level 1 incremental backups of the database which are applied to the image copy backup. } RMAN Backup RMAN Backups – Multi-Section Backups RMAN Backup RMAN Backups – Archive log backups • Splits datafiles into separate backup pieces. # it simply tells RMAN that the incremental # to be executed should # be applied to the database copy we made above. • Block change tracking file reduces time required for level 1 backups. • To create: alter database enable block change tracking using file 'c:\oracle\block_change_tracking\orcl_block_change. • No need to restore level 1 backups. • Level 1 backups • Only changed blocks are backed up. • Bigger backup images. • Example RUN { # the recover copy command does not really recover anything. • Example backup archivelog time between "sysdate-1" and "sysdate". • Block change tracking file reduces time required for level 1 backups. •Backup as compressed backupset incremental Backup level 0 database plus archivelog delete input. Backup level 1 database plus archivelog delete input.fil'. • Level 0 backups • Full backup. 15 . • You can backup archived redo logs. Backup incremental level 1 for recover of copy with tag ’Jacob_Jared_Lizzie’ Database. • Allows datafiles to be backed using different channels in parallel.RMAN Backup RMAN Backups – Incremental Backups RMAN Backup RMAN Backups – Incremental Backups • Incremental backups can decrease the overall time that it takes to backup your database. • Example backup section size 40m database.

0 . • Assign to RC tablespace. • Create the recovery catalog schema C:>Rman catalog=rcat_user/rcat_user@rcat Recovery Manager: Release 11. • Grant RECOVERY_CATALOG_OWNER role. connected to target database: ORCL (DBID=1190537904.0 .0. All rights reserved. not open) connected to recovery catalog database RMAN> register database. Set oracle_sid=orcl Rman target=sys/Robert catalog=rcat_user/rcat_user@rcat Recovery Manager: Release 11. connected to recovery catalog database RMAN> create catalog recovery catalog created RMAN Recovery Catalog Register a database with the Recovery Catalog • Use the register database command to register a database with the RC.1. All rights reserved.RMAN Backup RMAN Backups – Control file and SPFILE autobackups RMAN Backup RMAN Backups – Control file backups • RMAN can be configured to automatically backup SPFILES and control files.1. RMAN Recovery Catalog Create a Recovery Catalog • Create RC database or use existing database. • Create and configure a recovery catalog • Synchronize the recovery catalog • Create and use RMAN stored scripts • Back up the recovery catalog • Create and use a virtual private catalog • Acts as a single location to store all your RMAN backup related information. • Create a tablespace for the RC data. 2007.6. • Create a user that will be the RC user.ctl’.Production on Mon Sep 15 23:10:13 2008 Copyright (c) 1982. • Offers global scripting of RMAN operations. database registered in recovery catalog starting full resync of recovery catalog full resync complete 16 .6.0. • RMAN can be used to backup control files • You can backup the current control file backup as copy current controlfile. Oracle. • Redundant storage of RMAN backup records. Oracle.Production on Mon Sep 15 23:12:51 2008 Copyright (c) 1982. RMAN Recovery Catalog OCP Objectives RMAN Recovery Catalog Recovery Catalog Benefits • Identify situations that require the RMAN recovery catalog. • Oracle Data Guard requires the use of a recovery catalog. 2007. backup as copy current controlfile format ’c:\oracle\controlfilebackup\contrf_backup. • Longer term storage of RMAN backup records.

Oracle.Production on Mon Sep 15 23:13:45 2008 Copyright (c) 1982. Grant succeeded. This is a unique account for a specific owner. • Setup • Create the VPC Catalog owner account. not open) connected to recovery catalog database RMAN> unregister database. • Example: RMAN> resync catalog.0 . RMAN Recovery Catalog Using Stored Scripts RMAN Recovery Catalog Using Stored Scripts • The recovery catalog can store scripts for use by RMAN. • Use the create script command to create a script: • Use the global keyword if using VPD if you wish the script to be usable across all databases. User created. • Use the resync catalog command to resynchronize the recovery catalog with the control file.} • Use the replace script command to replace scripts Replace script db_delete_obsolete { delete noprompt obsolete. • Example: create global script db_delete_obsolete { delete obsolete. • Uses VPD to secure the catalog records.1.0. • Backup when the RC is not available for example. • Note this is NOT the main recovery catalog owner account. SQL> grant recovery_catalog_owner to rcat_001.RMAN Recovery Catalog Unregister a database with the Recovery Catalog RMAN Recovery Catalog Synchronizing the Recovery Catalog • Use the unregister database command to unregister a database with the RC.} • Use the delete script command to remove a script: delete script db_delete_obsolete { delete obsolete. connected to target database: ORCL (DBID=1190537904. sqlplus rcat_user/rcat_user@rcat SQL> create user rcat_001 identified by rcat_001 2 default tablespace rcat_data 3 quota unlimited on rcat_data. All rights reserved. • With an RMAN backup.6. Rman target=sys/Robert catalog=rcat_user/rcat_user@rcat Recovery Manager: Release 11. • Restrict users of the catalog to seeing specific records.} • Use the execute script command to execute scripts Run { execute script db_delete_obsolete. database name is "ORCL" and DBID is 1190537904 Do you really want to unregister the database (enter YES or NO)? yes database unregistered from the recovery catalog • Sometimes the control file and recovery catalog will get out of synchronization. 2007. you must make sure the control file gets backed up. } RMAN Recovery Catalog Backup the Recovery Catalog RMAN Recovery Catalog Virtual Private Catalog • The recovery catalog can be backed up using manual backup methods or you can use RMAN. 17 .

• Restore control file if required. while connected to the VPC Catalog owner account created above. RMAN Recovery Basics of RMAN recovery in NOARCHIVELOG mode. All rights reserved. create the VP Catalog using the create virtual catalog command. • Perform complete recovery from a critical or non-critical data file loss using RMAN. • Note this grant gives the rcat_001 rights to see the ORCL database records. rman catalog=rcat_001/rcat_001@rcat RMAN> Create virtual catalog. recover database noredo. • Mount database • Restore database • Recover database (noredo) • Open database • Example RMAN> RMAN> RMAN> RMAN> RMAN> shutdown abort startup mount restore database. found eligible base catalog owned by RCAT_USER created virtual catalog against base catalog owned by RCAT_USER • Now. RMAN Recovery Basics of RMAN recovery in NOARCHIVELOG mode. Oracle. Grant succeeded. • Perform incomplete recovery using RMAN • Recover using incrementally updated backups • Switch to image copies for fast recovery. 2007. RMAN Recovery Catalog Virtual Private Catalog RMAN Recovery OCP Objectives • The revoke command is used to remove privileges: Revoke catalog for database abcs from rcat_001. • Restore SPFILE if required.6.0. alter database open. connected to recovery catalog database RMAN> grant catalog for database orcl to rcat_001. grant access to the recovery catalog objects to the VPC catalog owner: rman catalog=rcat_user/rcat_user@rcat Recovery Manager: Release 11. • Recover using a backup control file.0 . (like the create catalog command). • Determine extent of recovery required.1.RMAN Recovery Catalog Virtual Private Catalog RMAN Recovery Catalog Virtual Private Catalog • From RMAN. 18 .Production on Tue Sep 16 20:25:32 2008 Copyright (c) 1982.

• Determine extent of recovery required. • Example – Loss of single. Database still running. • If recovering critical files • Mount database. alter database open. • Example – All files lost RMAN> RMAN> RMAN> RMAN> RMAN> shutdown abort startup mount restore database. • Recover database • Open database (resetlogs as required) • If recovering non-critical files (database open) • Take datafiles offline. • Example – SYSTEM tablespace lost RMAN> RMAN> RMAN> RMAN> RMAN> shutdown abort startup mount restore tablespace system. • Restore datafiles. • Restore SPFILE if required. • Use restore and recover commands. RMAN Recovery Basics of RMAN recovery in ARCHIVELOG mode. • Used to re-create databases (like test databases). • Define the time to restore too. • Recover datafiles • Bring datafiles online. • Used to recover from software failures. RMAN> RMAN> RMAN> RMAN> sql 'alter database datafile 3 offline'. • Entire database must be restored to the same point-in-time. restore datafile 3. recover datafile 3. • Process is similar to a full database restore. recover database. • Restore datafiles. recover tablespace system. • Different kinds of incomplete based recoveries • Time based • SCN based • Log sequence based 19 . RMAN Recovery Basics of RMAN recovery in ARCHIVELOG mode. • Restore critical files (or all files) as required. alter database open. • If recovering non-critical files (database down) • Mount database. • Take datafiles offline. RMAN Recovery Incomplete Recovery RMAN Recovery Incomplete Recovery • Incomplete recovery allows recovery to a point-intime other than the point-in-time of the failure. • Recover datafiles • Bring datafiles online.RMAN Recovery Basics of RMAN recovery in ARCHIVELOG mode. sql 'alter database datafile 3 online'. non-critical datafile. • Restore control file if required. • Used to recover from user failures. RMAN Recovery Basics of RMAN recovery in ARCHIVELOG mode.

you can quickly switch to those copies for faster restores. incremental. RMAN> Recover database until time ’09/30/2008:18:00:00’. • SCN Based point-in-time recovery • What is an SCN? • Counter in database • Current_SCN in V$DATABASE contains the current SCN value. • If you use image copies. RMAN> Recover database until SCN 55555. • Reset with resetlogs command. copies) for the fastest restore possible. Sql ‘alter database datafile 4 online’. RMAN> Alter database open resetlogs. RMAN Recovery Recovery with Incrementally updated backups. RMAN Recovery Incomplete Recovery RMAN Recovery Incomplete Recovery • Log sequence number based point-in-time recovery • What are log sequence numbers? • Track individual redo logs • Starts with 1. • Increments with each log switch. RMAN> Alter database open resetlogs. • Still have to apply incrementals and/or archived redo logs with the recover command.RMAN Recovery Incomplete Recovery RMAN Recovery Incomplete Recovery • Time based recovery example RMAN> Restore database until time ’09/30/2008:18:00:00’. 20 .dbf’. Recover datafile 4. RMAN Recovery Fast Recovery with Image Copies • Oracle/RMAN will automatically use the correct backup sets (full. • Several views show you the log sequence numbers: • v$log – Current redo logs • v$log_history – Archived redo logs • Example RMAN> Restore database until sequence 55555. • Example RMAN> Restore database until SCN 55555. Switch datafile 4 to copy ‘/oracle/backup/users_01. • Example – Restore a datafile quickly! Sql ’alter database datafile 4 offline’. RMAN> Alter database open resetlogs. RMAN> Recover database until sequence 55555.

FLASHBACK_ON -----------YES 21 . estimated_flashback_size from v$flashback_database_log. alter system set db_flashback_retention_target=4320. • Control file autobackups make for easy recovery of control files and SPFILES. • Must be configured first. Oracle Flashback Technologies – Configure Flashback Database • Configuring to use Flashback Database • Open the database Alter database open. • Example: RMAN> Startup nomount.RMAN Recovery Recover using a Backup Control File Oracle Flashback Technologies – OCP Objectives • RMAN provides automatic backups of control files.---------. OLDEST_FLASH_SCN OLDEST_FLASH_TIME RET_TARGET EST_FLASHBACK_SIZE ---------------. • Determines how long you can flashback the database too. • What are the Oracle Flashback Features? • • • • • • • Flashback Flashback Flashback Flashback Flashback Flashback Flashback Drop (and the Recycle Bin) Query Versions Query Transaction Table Database Data Archive • Enable the flashback capability: alter database flashback on. Monitor Flashback Database and Perform Flashback Database operations • Restore dropped tables from the recycle bin • Perform Flashback Query • Use Flashback Transaction Query • Perform Flashback Table Operations • Set up and use a Flashback Data Archive Oracle Flashback Technologies – Configure Flashback Database Oracle Flashback Technologies – Configure Flashback Database • Configuring to use Flashback Database • Database mounted • Set the DB_FLASHBACK_RETENTION_TARGET parameter. select flashback_on from v$database. RMAN> alter database open resetlogs. • Configure. RMAN> Restore controlfile from autobackup. retention_target. oldest_flashback_time.-----------------979720 20-JUL-08 4320 298967040 • Determine that the database is in flashback mode.----------------. Oracle Flashback Technologies – Configure Flashback Database • How far can you flashback? • V$FLASHBACK_DATABASE_LOG select oldest_flashback_scn. • Control file recoveries require the instance be started.

flashback table "BIN$F2JFfMq8Q5unbC0ceE9eJg==$0" to before drop.---------ESTIMATED_FLASHBACK_SIZE -----------------------20-JUL-08 20-JUL-08 61784064 35880960 99203072 100010 • Determine what point-in-time you want to flashback too. • Determine if you can flashback that far. just renamed. • Open the database with resetlogs.Oracle Flashback Technologies – Configure Flashback Database Oracle Flashback Technologies –Using Flashback Database • How much flashback log space is required? • V$FLASHBACK_DATABASE_STAT select * from v$flashback_database_stat. flashback database to scn 979721. 22 . Purge recyclebin.--------------------979720 20-JUL-08 • Shutdown the database (Consistent) Shutdown immediate Oracle Flashback Technologies –Using Flashback Database • Put the database in MOUNT mode. oldest_flashback_time from v$flashback_database_log. It’s still there.----------------------------------------. Alter database open resetlogs. Drop table my_table purge. OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TIME -------------------.--------. Purge tablespace users.---------. • Can still select from the table.------------------JOB_HISTORY BIN$F2JFfMq8Q5unbC0ceE9eJg==$0 TABLE 2008-04-07:11:52:36 • Flashback the database • Flashback to • Time • SCN • Restore point • Before the last resetlogs operation. • Recover a table from the recycle bin • Use flashback drop command flashback table job_history to before drop rename to job_hist. BEGIN_TIM END_TIME FLASHBACK_DATA DB_DATA REDO_DATA --------. Oracle Flashback Technologies – The Recycle Bin Oracle Flashback Technologies – The Recycle Bin • Recycle bin views • DBA_RECYCLEBIN • USER_RECYCLEBIN • Purge the recycle bin purge table employees. select oldest_flashback_scn. Startup mount Oracle Flashback Technologies – The Recycle Bin • When you drop a table it goes to the recycle bin! • See what’s in the recycle bin SQL> show recyclebin ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME ---------------.-------------.

salary from employees versions between scn minvalue and maxvalue where employee_id = 123. versions_operation. • Dependent objects (IE: indexes) are also rolled back. • Compare current data with historical data."EMPLOYEES" set "SALARY" = '4017' where ROWID = 'AAARAgAAFAAAABYABd'. employee_id. ‘DD-MON HH:MI’) “END DATE”.--------. undo_sql from flashback_transaction_query t. • Allows more tactical response to problems. Oracle Flashback Technologies – Flashback Versions Query • Provides the ability to query a table and retrieve all of the versions of the data that have existed between two specific points in time (specified by a timestamp or an SCN). • The object(s) being flashed back are still available.xid and operation = ‘UPDATE’.85 4017 3900 Oracle Flashback Technologies – Flashback Versions Query • Some Pseudo columns are available too! select to_char(versions_starttime. • Allow user to correct certain kinds of mistakes.93 U 123 4217.85' where ROWID = 'AAARAgAAFAAAABYABd'. • Benefits • Faster than a complete point-in-time restore. • Use to • Recover from user error.85 U 123 4017 I 123 3900 Oracle Flashback Technologies – Flashback Transaction Query • Used to identify changes made to the database at the transaction level. operation.---------U 123 2108."EMPLOYEES" set "SALARY" = '2108."EMPLOYEES" set "SALARY" = ‘4217.----------.-------------------------------------EMPLOYEES UPDATE update "HR". • Uses FLASHBACK_TRANSACTION_QUERY view.Oracle Flashback Technologies – Flashback Query • Flashback query allows you to see table data as it existed at a different point-in-time. START DATE -----------08-MAY 09:13 08-MAY 09:12 08-MAY 09:08 08-MAY 08:15 END DATE -----------08-MAY 09:13 08-MAY 09:12 08-MAY 09:08 V EMPLOYEE_ID SALARY . TABLE_NAME OPERATION UNDO_SQL ---------. EMPLOYEES UPDATE update "HR". EMPLOYEES UPDATE update "HR". 'DD-MON-YYYY HH24:MI:SS')) where employee_id = 102. SALARY ---------2108. (select versions_xid as xid from employees versions between scn minvalue and maxvalue where employee_id = 123) e where t.93 4217. 23 .xid = e.’DD-MON HH:MI’) “START DATE”.93' where ROWID = 'AAARAgAAFAAAABYABd'. • Uses the VERSIONS BETWEEN clause. • Use the AS OF clause for a Flashback Query • Example select * from job_history as of timestamp( to_timestamp('08-MAY-2008 11:50:00'. to_char (versions_endtime. • Keeps the database up and running. select salary from employees versions between scn minvalue and maxvalue where employee_id = 193. • View includes the UNDO_SQL used to undo a specific SQL operation. Oracle Flashback Technologies – Flashback Transaction Query • Example select table_name. Oracle Flashback Technologies – Flashback Table • Roll back data in a table (or tables) to a specific point in time.

• Use flashback table command as seen here: flashback table employees to scn 623411. 24 . flashback archive.Oracle Flashback Technologies – Flashback Table Oracle Flashback Technologies – Flashback Data Archive • Table to be flashed back must have row movement enabled. • To configure for Flashback Data Archive use Create flashback archive command: create flashback archive default audit_flash_archive tablespace audit_archive quota 20g retention 7 year. shipper number(9). DBA_FLASHBACK_ARCHIVE_TABLES Tables that are enabled for archive Diagnosing The Database And Maintaining Performance . Oracle Flashback Technologies – Flashback Data Archive Oracle Flashback Technologies – Flashback Data Archive • Flashback Data Archive • Assign a table to an archive • Using Create Table create table shipments (ship_id number(9). alter table shipments no flashback archive.OCP Objectives Diagnosing The Database And Maintaining Performance – Setup ADR • • • • • • Set Up Automatic Diagnostic Repository Using Support Workbench Perform Block Media Recovery Use the SQL Tuning Advisor Use the SQL Access Advisor to tune a workload Understand Database Replay • What is ADR? • Setting up ADR • DIAGNOSTIC_DEST parameter • Defaults to $ORACLE_BASE alter system set diagnostic_dest="c:\temp". • Flashback Data Archive Views View Name DBA_FLASHBACK_ARCHIVE DBA_FLASHBACK_ARCHIVE_TS Description Information about flashback data archives Tablespaces used for flashback data archives • Using Alter Table alter table employee_history flashback archive audit_flash_archive. • Provides the ability to retain and track all transactional changes to a record over its lifetime • Use tablespaces to store the archives. ship_date date). • Flashback to SCN or Time. • Flashback Data Archive • Also known as Oracle Total Recall.

• DBMS_SQLTUNE • Views • DBMS_SQLTUNE_* • DBMS_ADVISOR_* • DBMS_SQLSET_* • Manual runs via OEM or PL/SQL package calls.---------. CORRUPTION_TYPE “TYPE” FROM V$DATABASE_BLOCK_CORRUPTION. 25 . FILE# BLOCK# BLOCKS TYPE ---------.Diagnosing The Database And Maintaining Performance – Setup ADR Diagnosing The Database And Maintaining Performance – Using Support Workbench • ADR_BASE • ADR_HOME • What’s Support Workbench do? • View Critical Error Alerts • View Problem Details • Gather Additional Diagnostic Information • Create a Service Request • Package and Upload Diagnostic Data to Oracle Support • Track the Service Request and Implement Any Repairs • Close the Incident Diagnosing The Database And Maintaining Performance – Using Support Workbench Diagnosing The Database And Maintaining Performance – Block Media Recovery • How to use Support Workbench • OEM Interface • ADRCI – Command line interface • Block Media Recovery provides the ability to recover corrupted database blocks online. • Use the V$DATABASE_BLOCK_CORRUPTION to determine if/where corruption exists SQL> SELECT NAME.---------. recover the block: RECOVER DATAFILE 1201 BLOCK 1968. VALUE FROM V$DIAG_INFO. BLOCKS.--------1201 1968 2 PHYSICAL Diagnosing The Database And Maintaining Performance – Block Media Recovery Diagnosing The Database And Maintaining Performance – Use the SQL Tuning Advisor • Now. • RMAN provides an interface into BMR. • Analyzes SQL statements for performance improvements • Suggests performance improving changes including: • New Indexes • SQL Profiles • Changing your SQL statement • Gathering statistics • Runs automatically in Oracle Database 11g. BLOCK#. SQL> SELECT FILE#.

• Parameters • MEMORY_TARGET • MEMORY_MAX_TARGET • Still need to set the following buffer pools • KEEP buffer pool • RECYCLE buffer pool • Non-default block size Buffer cache pools • Fixed SGA and other intern memory structures • Log buffer • Implementing Automatic Memory Management • Manually configure SGA parameters • Configuring automatic PGA memory management • Managing resumable space allocation • Describe the concepts of transportable tablespaces and databases • Reclaim wasted space from tables and indexes by using the segment shrink functionality • Understand the database resource manager • Create and use Database Resource Manager Components 26 . • Preprocess the workload • Used to indicate the end of the workload capture. • New indexes • Upgrades • Change to optimizer related parameters • Application SQL changes • OEM and manual interfaces. • Four basic steps: • Capture the database workload • Preprocess the workload • Replay the workload • Analyze the results Diagnosing The Database And Maintaining Performance – Understand Database Replay Diagnosing The Database And Maintaining Performance – Understand Database Replay • Capture the Workload • Used to capture real-time workload events. • Prepares the workload for replay • Several files associated with workload capture are created. • Suggests objects that might improve performance.Diagnosing The Database And Maintaining Performance – Use SQL Access Advisor Diagnosing The Database And Maintaining Performance – Understand Database Replay • OEM and manual interfaces. • Workload clients • State of the schema • Analyze the results • OEM • Manual PL/SQL procedures Managing Database Resources OCP Objectives Managing Database Resources Automatic Memory Management • Provides the ability to manage SGA and PGA memory in one memory allocation. • Replay the workload • Can occur on any database. • Move files to replay server. • Provides recommendations on: • New Indexes • BTREE • Bitmap • FBI’s • Materialized views • Materialized view logs • Partitioned objects • Determine the impact of change on your system.

• Manual memory parameters (ie: DB_CACHE_SIZE) • Eliminates needing to set these parameters • • • • SORT_AREA_SIZE HASH_AREA_SIZE BITMAP_MERGE_AREA_SIZE CREATE_BITMAP_AREA_SIZE Managing Database Resources Configure Automatic PGA Memory Management Managing Database Resources Configure Resumable Space Allocation • Monitoring PGA Memory Management • • • • • • • • V$PGASTAT V$PROCESS V$PROCESS_MEMORY V$SQL_WORKAREA_ACTIVE V$SQL_WORKAREA V$SQL_WORKAREA_HISTOGRAM V$PGA_TARGET_ADVICE V$PGA_TARGET_ADVICE_HISTOGRAM • Reduces the likelihood of failure of database operations due to lack of space. • Static – Use scope=spfile. • Use alter session enable resumable to disable. Alter system set sga_target=250m. • Examples Alter system set db_cache_size=250m scope=spfile. • Configured using the RESUMABLE_TIMEOUT parameter • Set at the session or instance level • Set in terms of seconds. • Enabled if RESUMABLE_TIMEOUT set at the instance level OR the alter session enable resumable command is issued. • Defaults to 0 seconds in 11g.Managing Database Resources Manually Configure SGA Parameters • Can use SGA memory management • SGA_TARGET • SGA_MAX_SIZE • Manual parameter settings • DB_CACHE_SIZE • SHARED_POOL_SIZE • LARGE_POOL_SIZE • JAVA_POOL_SIZE • LOG_BUFFER • Dynamic/Static parameters • Dynamic – Can be set without restarting database. Managing Database Resources Configure Automatic PGA Memory Management Managing Database Resources Configure Automatic PGA Memory Management • Configure with PGA_AGGREGATE_TARGET • Do not need to configure if using Automatic Memory Management (MEMORY_TARGET). 27 . Managing Database Resources Manually Configure SGA Parameters • Set with alter system command • Scope parameter of alter system command • Dynamic – Scope not needed in most cases. • Configure if using • SGA memory management (SGA_TARGET). • Static – Must restart database.

Managing Database Resources Transportable Tablespaces and Databases Managing Database Resources Transportable Tablespaces and Databases • Things to remember about transportable tablespaces • Must be self-contained. • DBMS_RESUMABLE PL/SQL package • *_RESUMABLE view. use RMAN convert to convert the files in a temporary location on the source system 28 . Choose the tablespaces for the transportable tablespace set • Ensure they are self-contained DBMS_TTS. • Check the compatibility parameter. • Check Endian (byte ordering) compatibility v$transportable_platform • Use Data Pump on the source system to specify which tablespaces are included in the transportable set. Show parameter compatible alter tablespace user_data read only. • DBA/User notified of suspension of system via various methods: • The error is reported in the alert log. • A tablespace with objects owned by SYS can not be transported.dmp DIRECTORY=exp_dir TRANSPORT_TABLESPACES=user_data 1. • Basic steps 3. • Transportable Tablespaces are good for a number of things: • Database migrations • Sharing tablespaces with other databases (ie: from OLTP to warehouse) • Tablespace point-in-time recovery (TSPITR) • Archiving data from one database to another • Exporting and importing partitions. Determine compatibility between source and target.TRANSPORT_SET_CHECK • If converting to a different endian format. expdp dumpfile=expdat. Generate the transportable tablespace set • Put all of the tablespaces in the transportable set readonly. • The source and target databases must have the same character set and national character set.Managing Database Resources Configure Resumable Space Allocation Managing Database Resources Transportable Tablespaces and Databases • Will cause sessions to be suspended in these cases: • Out of space condition • Maximum extents reached condition • Space quota exceeded condition. • The SYSTEM tablespace can not be transported. • Things to remember about transportable tablespaces • If there is a tablespace on the destination database that has the same name of the tablespace to be transported. • Tablespaces can come from databases of different block sizes. then that tablespace needs to be renamed before the transport can take place. • Tablespaces can be transported across different Endian byte formats. Managing Database Resources Transportable Tablespaces and Databases Managing Database Resources Transportable Tablespaces and Databases • Basic steps 1. • Resumable Session Suspended alert issued. • Tablespace to be transported will temporarily be made readonly. • Transportable tablespaces allow you to “unplug” a tablespace in one database and “plug” it into another. • A trigger can be registered to execute on a suspension event.

end.dmp DIRECTORY=imp_dir TRANSPORT_DATAFILES=/oracle/oradata/LNEB/user_data 01.DATA_PUMP_DIR The following BFILEs exist in the database: PM. 5. 2. begin tdb_check := dbms_tdb.SALES_TRANSACTIONS_EXT The following directories exist in the database: SYS. 1. Open the database in READ-ONLY mode and retry. SYS.EXP_DIR. Run RMAN CONVERT DATABASE. Verify the pre-requisites. 2. SYS. SYS. / The following external tables exist in the database: SYS. SYS. Use the dbms_tdb. PL/SQL procedure successfully completed. Transport the tablespace set • Physically move the datafiles to the target database. • Put the source tablespace in read write mode.IDR_DIR. 3.AUDIT_DIR. begin tdb_check := dbms_tdb. 4. Example: SQL> set serveroutput on SQL> declare tdb_check boolean. SYS. 7. Database is not open in READ-ONLY mode. 6. SQL> set serveroutput on SQL> declare tdb_check boolean.LOG_FILE_DIR. SYS.XMLDIR.CAPTURE_DIR. Managing Database Resources Transportable Tablespaces and Databases Managing Database Resources Transportable Tablespaces and Databases 1. SH. 4. • Basic steps: 1.EM_TTS_DIR_OBJECT. SYS. 29 . SQL> alter database open read only.WRR$_REPLAY_SEQ_DATA_EXT. Verify that the destination and source systems have the same Oracle version. • Shutdown must be consistent. 1. Verify that there are no restrictions or limitations that the source or destination database may encounter.check_external().skip_none). Identify all external files and directories. Verify using the Opatch utility program. IMPDP DUMPFILE=expdat.CHECK_DB procedure. SQL> shutdown immediate. SQL> startup mount. SYS. Determine what external files and directories exist and plan for the migration.check_db ('Linux IA (64-bit)'.PRINT_MEDIA Managing Database Resources Transportable Tablespaces and Databases Managing Database Resources Transportable Tablespaces and Databases 3. 3.check_external procedure to determine this information. critical patch updates. Verify the prerequisites. 2.dbf • Transportable databases are much like transportable tablespaces.WRR$_REPLAY_SCN_ORDER_EXT. Move files to the destination system. Import the tablespace set • Use the Datapump IMP utility to import the database metadata into the target database. • Uses RMAN for the conversions. Complete the migration. Verify the database is ready for migration • Use DBMS_TDB. SYS. end.SUBDIR. 4. 5. Put the source database in READ-ONLY mode. and patch set exceptions.dbms_tdb.WRR$_REPLAY_CONN_DATA_EXT. • Provides the ability to move an entire database across platforms. patch set version. SYS.MEDIA_DIR. SYS.DATA_FILE_DIR. Determine if you will use the source or destination system to perform the conversion 2. SYS. Start the source database in READ ONLY mode. Verify the source database is ready for migration. Determine if a platform conversion is required.Managing Database Resources Transportable Tablespaces and Databases Managing Database Resources Transportable Tablespaces and Databases • Basic steps 4.

• Also you will need to copy pfile. 7. and schedule. and on-line. 6. • Use a time-based or event-based schedule for executing Scheduler jobs • Create lightweight jobs • Use job chains to perform a series of related tasks • Online segment rebuild will: • Compact the segment. bfiles and the SQL script created by the CONVERT DATABASE command.EMPLOYEES ENABLE ROW MOVEMENT. but now only has a small amount of data. • Or you may have moved them before the convert as an option. Complete the migration • After the files are move. • Can convert on source or target database. • Resets the high water mark • Releases the reclaimed free space • Rebuilding a table: ALTER TABLE HR. • Options • Cascade – Rebuilds all associated objects (indexes) • Compact – Rebuilds but does reset the HWM.EMPLOYEES SHRINK SPACE. defragmenting as a result. Move the converted files to the target system. • Objects that have been allowed to grow to large can impact performance.sql' new database 'orclnx' to platform 'Linux IA (64-bit)' parallelism 4 format 'c:\temp\%d%f' db_file_name_convert 'c:\oracle\oradata\orcl\'. • Platform must be exactly the name contained in the PLATFORM_NAME column in the view V$DB_TRANSPORTABLE_PLATFORM convert database [on destination platform ] transport script 'c:\temp\transport_db_orclnx. • Indexes can become inefficient in certain cases. program. • High water mark causes full table scans to take too long. • Adjust networking files as required.'c:\temp\stage\'.Managing Database Resources Transportable Tablespaces and Databases Managing Database Resources Transportable Tablespaces and Databases 5. Managing Database Resources Reclaim Wasted Space from Tables/Indexes The Database Scheduler OCP Objectives • Create a job. • Oracle Database 11g provides the ability to rebuild segments in-place. • Start the database. • OEM – Automatic Segment Advisor • Manual • Requirements: • Row movement is enabled • All rowid-based triggers defined on the object are disabled. • Create a new password file if required. ALTER TABLE HR. adjust the parameter file as required. These will fail after the rebuild. external table files. • Determine if the application uses any rowid based DML or queries. • Contained a large amount of data at one time. • Created too large initially. 30 . Managing Database Resources Reclaim Wasted Space from Tables/Indexes Managing Database Resources Reclaim Wasted Space from Tables/Indexes • Space in tables and indexes can be wasted. Run the RMAN Convert Database command to convert the database. (pretty rare).

Simplifies management of windows by allowing the members of the group to be manipulated as one object. Program and Schedule The Database Scheduler Create a Job.-----------SYS PURGE_LOG SCHEDULED SYS GATHER_STATS_JOB RUNNING The Database Scheduler Create a Job. • ENABLED procedure – Enable jobs • DISABLED procedure – Disable jobs • Jobs can have attributes • Set with SET_ATTRIBUTE procedure.Consists of two or more Scheduler programs that are linked together to meet an objective.A logical method of classifying jobs with similar attributes. Can be stored as an independent object that can be referenced by many jobs. Schedule . and a repeat interval. The Database Scheduler Create a Job. • An Oracle background process with the responsibility of ensuring that jobs are run on schedule. Program and Schedule Chains . state 2 from dba_scheduler_jobs. • Architecture • The job table is the master container for all enabled jobs in the database. Windows . Program and Schedule • Architecture • The DBMS_SCHEDULER package is used to manage the job scheduler. Can be stored as an independent object that can be referenced by many jobs. Simplifies management by allowing collections of jobs to be manipulated as one object.Contains the code (or a reference to the code) that needs to be run to accomplish a task. The Database Scheduler Create a Job. an optional end date.Contains a start date.Identifies a recurring block of time during which a specific resource plan should be enabled to govern resource allocation for the database. • Exposed through the *_SCHEDULER_JOBS views. SQL> select owner.The Database Scheduler Create a Job. job_name.Instructs the Scheduler to run a specific program at a specific time on a specific date. Program and Schedule • Architecture • The job coordinator. One per instance. An implementation of dependency scheduling. Window Groups . • Process name is cjqNNN. Program and Schedule Job . Program . • Executes jobs in a new session as the owner of the job.-------------------. • The job slave processes • Tasked with carrying out the execution of job programs assigned to them by the job Scheduler . OWNER JOB_NAME STATE ---------. Job Classes . • Attributes include: • Start Date • Enabled • Disabled • OEM also has interfaces into the job scheduler.A logical method of grouping windows. 31 . Program and Schedule The Database Scheduler Create a Job.

run_count from user_scheduler_jobs. Program and Schedule • Create a job • Using CREATE_JOB Example begin dbms_scheduler. start_date => ‘10-OCT-2008 06:00:00 AM’.---------LNEB_JOB FALSE 0 The Database Scheduler Create a Job. end. The Database Scheduler Create a Job.CREATE_JOB • Combines a job and a program. end. Program and Schedule • Create a job • DBMS_SCHEDULER.The Database Scheduler Create a Job. • May need to set job arguments calling SET_JOB_ARGUMENT and/or SET_JOB_ANYDATA_VALUE procedures. job_action => ‘update employee set salary = salary*1. / 32 . end. job_type => ‘PLSQL_BLOCK’.run_job(’LNEB_JOB’. force=>TRUE). / • We can drop the job begin dbms_scheduler. end. • NUMBER_OF_ARGUMENTS • PROGRAM_NAME • START_DATE The Database Scheduler Create a Job.drop_job(job_name=>’LNEB_JOB’. Program and Schedule • Was the job created? SQL> select job_name. or PL/SQL code to be executed). force=>TRUE).stop_job(job_name=>’LNEB_JOB’.create_job ( job_name => ‘LNEB_job’. JOB_NAME ENABLED RUN_COUNT ------------------------. Program and Schedule • Create a job • Jobs have attributes • REPEAT_INTERVAL • SCHEDULE_NAME • END_DATE • COMMENTS • ENABLED • AUTO_DROP The Database Scheduler Create a Job. / The Database Scheduler Create a Job.TRUE). repeat_interval => ‘FREQ=YEARLY’. / • We can run the job begin dbms_scheduler. Program and Schedule • Create a job • Jobs have attributes • JOB_NAME • JOB_TYPE • PLSQL_BLOCK • STORED_PROCEDURE • EXECUTABLE • JOB_ACTION • Code to be executed (ie: Name of executable.05. Program and Schedule • We can stop the job begin dbms_scheduler.’. enabled. comments => ‘Cost of living adjustment’).

define_program_argument( program_name => ‘STATS_PROGRAM’. program_type => ‘STORED_PROCEDURE’. • PROGRAM_NAME • PROGRAM_TYPE • PLSQL_BLOCK • STORED_PROCEDURE • EXECUTABLE • PROGRAM_ACTION • NUMBER_OF_ARGUMENTS • ENABLED • COMMENTS The Database Scheduler Create a Job. Program and Schedule • Attributes of a schedule • SCHEDULE_NAME • START_DATE • END_DATE • REPEAT_INTERVAL • COMMENTS 33 . comments => ‘Gather stats for a schema’). / • Use the DROP_PROGRAM_ARGUMENT procedure to drop program arguments. number_of_arguments => 1.define_program_argument( program_name => ‘STATS_PROGRAM’. end. argument_type => ‘VARCHAR2’).create_program( program_name => ‘STATS_PROGRAM’.CREATE_PROGRAM procedure. end. • Use the DROP_PROGRAM procedure to drop programs.Define the argument begin dbms_scheduler. argument_position => 1. Program and Schedule • Create a program • We also need to define the argument -. • A schedule also defines the repeat interval of a job. / -.The Database Scheduler Create a Job. Program and Schedule • Create a program • Use the DBMS_SCHEDULER. The Database Scheduler Create a Job. much like a job. Program and Schedule • Programs • A program defines the action that will occur when a job runs. argument_position => 1.CREATE_PROGRAM procedure. / The Database Scheduler Create a Job. argument_type => ‘VARCHAR2’). The Database Scheduler Create a Job. •Schedules can be: • Time-based • Event-based • Dependency The Database Scheduler Create a Job. end.GATHER_SCHEMA_STATS’. begin dbms_scheduler.Define the argument begin dbms_scheduler. program_action => ‘DBMS_STATS. Program and Schedule • A schedule defines when jobs run as well as when windows are opened. Program and Schedule • Programs • A program has many attributes. • A program can be • PL/SQL Block • Stored Procedure • OS Executable • Programs can be created when jobs are defined or independently with the DBMS_SCHEDULER.

• A job chain consists of two or more Scheduler programs that are linked together to meet an objective. comments => ‘Runs nightly at 8:00 PM’). • Example of a lightweight job: BEGIN DBMS_SCHEDULER. comments => 'Heartbeat monitor job'). run program F • Run program ZZ. start_date => SYSTIMESTAMP. The Database Scheduler Using Job Chains • Example • Run program A • If program A completes successfully. • A Scheduler job. 34 .create_schedule( schedule_name => ‘NIGHTLY_8_SCHEDULE’. Program and Schedule • Create a schedule: begin dbms_scheduler. • Consider using a lightweight job when you have a high-frequency short-duration job. / The Database Scheduler Create Lightweight Jobs • A lightweight job has the following characteristics: • They are not schema objects • Lower overhead • Better create and drop time when compared to regular jobs. end. repeat_interval => ‘FREQ=DAILY. can reference a chain instead of a program to start the process. program_name => 'lne_prog'.INTERVAL=30'. • Monitor job Chain jobs • *_SCHEDULER_RUNNING_JOBS • *_SCHEDULER_JOB_LOG • *_SCHEDULER_JOB_RUN_DETAILS • *_SCHEDULER_RUNNING_CHAINS views. / The Database Scheduler Using Job Chains • Job chains are used to implement dependency scheduling. •They store less metadata and job runtime data than regular jobs.CREATE_JOB ( job_name => 'example_lightweight_job'. The Database Scheduler Create Lightweight Jobs The Database Scheduler Create Lightweight Jobs • Lightweight jobs inherit their privileges from the program • You cannot grant privileges to lightweight jobs.The Database Scheduler Create a Job. • Note the use of the calendaring syntax. BYHOUR=20’. • A job chain can contain logic with respect to the jobs that are executed and the order in which they are executed in. repeat_interval => 'FREQ=SECONDLY. job_style => 'LIGHTWEIGHT'. run program B • If both program A and B complete successfully. referred to as a chain job. •They must reference an enabled ‘PLSQL_BLOCK’ or ‘STORED_PROCEDURE’ program to specify a job action. END. run program C • If program A or B does not succeed.

DEFINE_CHAIN_STEP ( chain_name => 'lne_chain'. you define the steps and any rules. END. END.DEFINE_CHAIN_STEP ( chain_name => 'lne_chain'. •Each step can point to • A program • Another chain • An inline event • An event schedule.DEFINE_CHAIN_RULE ( chain_name => 'lne_chain'. / • Define the chain steps with the DEFINE_CHAIN_STEP procedure. • Use the DEFINE_CHAIN_RULE procedure. BEGIN DBMS_SCHEDULER. rule_name => 'lne_rule2'). step_name => 'lne_step2'. condition => 'lne_step1 completed'. condition => 'TRUE'. program_name => 'start_lne'). action => 'START lne_step1'.DEFINE_CHAIN_STEP ( chain_name => 'lne_chain'. DBMS_SCHEDULER. action => 'START lne_step2'. rule_name => 'lne_rule1'. event_schedule_name => 'lne_event_schedule').DEFINE_CHAIN_RULE ( chain_name => 'lne_chain'. • After the chain is created. comments => 'Never break the chain').CREATE_CHAIN ( chain_name => 'lne_chain'. step_name => 'lne_step3'. step_name => 'lne_step1'.ENABLE ('lne_chain'). END. BEGIN DBMS_SCHEDULER.DEFINE_CHAIN_EVENT_STEP ( chain_name => 'lne_chain'. END. each of which point to a specific program. / The Database Scheduler Using Job Chains • You must enable a chain before a job can run it: BEGIN DBMS_SCHEDULER. END. step_name => 'lne_step4'. comments => 'start the chain'). The Database Scheduler Using Job Chains • Example • Adds three steps. / 35 . / The Database Scheduler Using Job Chains • If you have a chain step that needs to wait for an event use the DEFINE_CHAIN_EVENT_STEP procedure: BEGIN DBMS_SCHEDULER. BEGIN DBMS_SCHEDULER. DBMS_SCHEDULER. DBMS_SCHEDULER. evaluation_interval => NULL. program_name => 'lne_run_stage1'). / The Database Scheduler Using Job Chains • We will also need to define chain rules.The Database Scheduler Using Job Chains The Database Scheduler Using Job Chains • Create a chain using the CREATE_CHAIN procedure. rule_set_name => NULL. program_name => 'lne_run_stage2').

bysecond=0'. END.The Database Scheduler Using Job Chains • Creating jobs that use chains • Use the RUN_CHAIN procedure to run a chain • Use the CREATE_JOB procedure to create a job that runs a chain BEGIN DBMS_SCHEDULER. repeat_interval => 'freq=daily.byminute=30.CREATE_JOB ( job_name => 'lne_chain_job1'. job_action => 'lne_chain'. / The Database Scheduler Using Job Chains • Monitor jobs with the following views: • *_SCHEDULER_RUNNING_JOBS • *_SCHEDULER_JOB_LOG • *_SCHEDULER_JOB_RUN_DETAILS Where to go from here…? • • • • Read! Surf! Take sample tests! Use Oracle! 36 . enabled => TRUE).byhour=7. job_type => 'CHAIN'.

Sign up to vote on this title
UsefulNot useful