Oracle Database Administration

How does one create a new database?
One can create and modify Oracle databases using the Oracle “dbca” (Database Configuration Assistant) utility. The dbca utility is located in the $ORACLE_HOME/bin directory. The Oracle Universal Installer (oui) normally starts it after installing the database server software. One can also create databases manually using scripts. This option, however, is falling out of fashion, as it is quite involved and error prone. Look at this example for creating and Oracle 9i database:
CONNECT SYS AS SYSDBA ALTER SYSTEM SET DB_CREATE_FILE_DEST=’/u01/oradata/’; ALTER SYSTEM SET DB_CREATE_ONLINE_LOG_DEST_1=’/u02/oradata/’; ALTER SYSTEM SET DB_CREATE_ONLINE_LOG_DEST_2=’/u03/oradata/’; CREATE DATABASE;

What database block size should I use?
Oracle recommends that your database block size match, or be multiples of your operating system block size. One can use smaller block sizes, but the performance cost is significant. Your choice should depend on the type of application you are running. If you have many small transactions as with OLTP, use a smaller block size. With fewer but larger transactions, as with a DSS application, use a larger block size. If you are using a volume manager, consider your “operating system block size” to be 8K. This is because volume manager products use 8K blocks (and this is not configurable).

How does one coalesce free space?
SMON coalesces free space (extents) into larger, contiguous extents every 2 hours and even then, only for a short period of time. SMON will not coalesce free space if a tablespace’s default storage parameter “pctincrease” is set to 0. With Oracle 7.3 one can manually coalesce a tablespace using the ALTER TABLESPACE ... COALESCE; command, until then use: SQL> alter session set events ‘immediate trace name coalesce level n’; Where ‘n’ is the tablespace number you get from SELECT TS#, NAME FROM SYS.TS$; You can get status information about this process by selecting from the SYS.DBA_FREE_SPACE_COALESCED dictionary view.

How does one prevent tablespace fragmentation?
Always set PCTINCREASE to 0 or 100. Bizarre values for PCTINCREASE will contribute to fragmentation. For example if you set PCTINCREASE to 1 you will see that your extents are going to have weird and wacky sizes: 100K, 100K, 101K, 102K, etc. Such extents of bizarre size are rarely re-used in their entirety. PCTINCREASE of 0 or 100 gives you nice round extent sizes that can easily be reused. Eg. 100K, 100K, 200K, 400K, etc. Thiru Vadivelu contributed the following: Use the same extent size for all the segments in a given tablespace. Locally Managed tablespaces (available from 8i onwards) with uniform extent sizes virtually eliminates any tablespace fragmentation. Note that the number of extents per segment does not cause any performance issue anymore, unless they run into thousands and thousands where additional I/O may be required to fetch the additional blocks

where extent maps of the segment are stored. Where can one find the high water mark for a table?
There is no single system table, which contains the high water mark (HWM) for a table. A table’s HWM can be calculated using the results from the following SQL statements: SELECT BLOCKS FROM DBA_SEGMENTS WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);

1

ANALYZE TABLE owner.table ESTIMATE STATISTICS; SELECT EMPTY_BLOCKS FROM DBA_TABLES WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table); Thus, the tables’ HWM = (query result 1) - (query result 2) - 1 NOTE: You can also use the DBMS_SPACE package and calculate the HWM = TOTAL_BLOCKS UNUSED_BLOCKS - 1.

How are extents allocated to a segment?
Oracle8 and above rounds off extents to a multiple of 5 blocks when more than 5 blocks are requested. If one requests 16K or 2 blocks (assuming a 8K block size), Oracle doesn’t round it up to 5 blocks, but it allocates 2 blocks or 16K as requested. If one asks for 8 blocks, Oracle will round it up to 10 blocks. Space allocation also depends upon the size of contiguous free space available. If one asks for 8 blocks and Oracle finds a contiguous free space that is exactly 8 blocks, it would give it you. If it were 9 blocks, Oracle would also give it to you. Clearly Oracle doesn’t always round extents to a multiple of 5 blocks.

The exception to this rule is locally managed tablespaces. If a tablespace is created with local extent management and the extent size is 64K, then Oracle allocates 64K or 8 blocks assuming 8K-block size. Oracle doesn’t round it up to the multiple of 5 when a tablespace is locally managed. Can one rename a database user (schema)? No, this is listed as Enhancement Request 158508. Workaround: Do a user-level export of user A create new user B Import system/manager fromuser=A touser=B Drop user A Can one rename a tablespace? No, this is listed as Enhancement Request 148742. Workaround: Export all of the objects from the tablespace Drop the tablespace including contents Recreate the tablespace Import the objects Can one resize tablespaces and data files?
One can manually increase or decrease the size of a datafile from Oracle 7.2 using the command. ALTER DATABASE DATAFILE ‘filename2’ RESIZE 100M; Because you can change the sizes of datafiles, you can add more space to your database without adding more datafiles. This is beneficial if you are concerned about reaching the maximum number of datafiles allowed in your database. Manually reducing the sizes of datafiles allows you to reclaim unused space in the database. This is useful for correcting errors in estimations of space requirements. Also, datafiles can be allowed to automatically extend if more space is required. Look at the following command: CREATE TABLESPACE pcs_data_ts DATAFILE ‘c:\ora_apps\pcs\pcsdata1.dbf’ SIZE 3M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED DEFAULT STORAGE (INITIAL 10240 NEXT 10240 MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0) ONLINE PERMANENT;

2

How does one create a standby database? While your production database is running, take an (image copy) backup and restore it on duplicate hardware. Note that an export will not work!!! On your standby database, issue the following commands: ALTER DATABASE CREATE STANDBY CONTROLFILE AS ‘filename’; ALTER DATABASE MOUNT STANDBY DATABASE; RECOVER STANDBY DATABASE;
On systems prior to Oracle 8i, write a job to copy archived redo log files from the primary database to the standby system, and apply the redo log files to the standby database (pipe it). Remember the database is recovering and will prompt you for the next log file to apply. Oracle 8i onwards provide an “Automated Standby Database” feature, which will send archived, log files to the remote site via NET8, and apply then to the standby database. When one needs to activate the standby database, stop the recovery process and activate it: ALTER DATABASE ACTIVATE STANDBY DATABASE;

How does one give developers access to trace files (required as input to tkprof)?
The “alter session set sql_trace=true” command generates trace files in USER_DUMP_DEST that can be used by developers as input to tkprof. On Unix the default file mask for these files are “rwx r-- ---“. There is an undocumented INIT.ORA parameter that will allow everyone to read (rwx r—r--) these trace files: _trace_files_public = true

Include this in your INIT.ORA file and bounce your database for it to take effect. How does one see the uptime for a database?
Look at the following SQL query: SELECT to_char (startup_time,’DD-MON-YYYY HH24: MI: SS’) “DB Startup Time” FROM sys.v_$instance; Marco Bergman provided the following alternative solution: SELECT to_char (logon_time,’Dy dd Mon HH24: MI: SS’) “DB Startup Time” FROM sys.v_$session WHERE Sid=1 /* this is pmon */ / Users still running on Oracle 7 can try one of the following queries: Column STARTED format a18 head ‘STARTUP TIME’ Select C.INSTANCE, to_date (JUL.VALUE, ‘J’) || to_char (floor (SEC.VALUE/3600), ‘09’) || ‘:’ -- || Substr (to_char (mod (SEC.VALUE/60, 60), ‘09’), 2, 2) || Substr (to_char (floor (mod (SEC.VALUE/60, 60)), ‘09’), 2, 2) || ‘.’ || Substr (to_char (mod (SEC.VALUE, 60), ‘09’), 2, 2) STARTED from SYS.V_$INSTANCE JUL, SYS.V_$INSTANCE SEC, SYS.V_$THREAD C Where JUL.KEY like ‘%JULIAN%’ and SEC.KEY like ‘%SECOND%’; Select to_date (JUL.VALUE, ‘J’) || to_char (to_date (SEC.VALUE, ‘SSSSS’), ‘ HH24:MI:SS’) STARTED from SYS.V_$INSTANCE JUL, SYS.V_$INSTANCE SEC where JUL.KEY like ‘%JULIAN%’ and SEC.KEY like ‘%SECOND%’;

3

value/1024 sort_size from sys. ‘J’) + (SEC.V$_LOCK with type ‘TS’.process. I don’t see them in V$DATAFILE or DBA_DATA_FILE? Tempfiles.tablespace. u. u. sys. Where are my TEMPFILES. s.extents. Sum (u. s. are not listed in v$datafile or dba_data_files.v_$sort_usage u. u.v_$sort_usage u where s. s. one can just query SYS.username.select to_char (to_date (JUL.v$sort_usage. s. sys. For usage stats.KEY like ‘%SECOND%’.bbbb’ where ‘ffff’ is the file it is in and ‘bbbb’ is first block of the segment.serial#. SUM (bytes free) FROM V$temp_space_header GROUP BY tablespace_name.VALUE/86400). SUM (bytes used). u.process.name = ‘db_block_size’ and s.contents.username. true temporary tablespace information is not listed in DBA_FREE_SPACE. unlike normal datafiles.v_$parameter VP where s. 4 .osuser. Instead use the V$TEMP_SPACE_HEADER view: SELECT tablespace_name.value / How does one get the view definition of fixed views/tables? Query v$fixed_view_definition. V$INSTANCE SEC where JUL. If your temporary tablespace is set to TEMPORARY.V_$SORT_SEGMENT From Oracle 8.serial#. Look at these examples: select s.v_$session s.addr = u.VALUE.KEY like ‘%JULIAN%’ and SEC.v_$session s. -Return a DATE ‘DD-MON-YY HH24:MI:SS’) STARTED from V$INSTANCE JUL. Instead query v$tempfile or dba_temp_files: SELECT * FROM v$tempfile. there is an entry in SYS.osuser like ‘&1’ group by s. u.blocks)*vp. vp. all sorts are done in one large temporary segment.username.session_addr / select s.osuser.saddr = u.session_addr and vp. s. How can one see who is using a temporary segment? For every user using temporary space.blocks from sys. How do I find used/free space in a TEMPORARY tablespace? Unlike normal tablespaces. Example: SELECT * FROM v$fixed_view_definition WHERE view_name=’V$SESSION’. sys.0.”USER”. SELECT * FROM dba_temp_files. see SYS. s. All temporary segments are named ‘ffff.

Oracle Backup and Recovery Why and when should I backup my database? Backup and recovery is one of the most important aspects of a DBAs job. If you lose your company’s data.If the databases are available and in ARCHIVELOG mode. What strategies are available for backing-up an Oracle database? The following methods are valid for backing-up an Oracle database: Export/Import . Backup frequency normally depends on the following factors: • Rate of data change/ transaction rate • Database availability/ Can you shutdown for cold backups? • Criticality of the data/ Value of the data to the company • Read-only tablespace needs backing up just once right after you make it read-only • If you are running in archivelog mode you can backup parts of a database over an extended cycle of days • If archive logging is enabled one needs to backup archived log files timeously to prevent database freezes • Etc. Frequently test your ability to recover and document all possible scenarios. Remember. log. Hardware and software can always be replaced.While the database is off-line or on-line. Off-site vaulting is also highly recommended. Hot or On-line Backups . weekly and monthly backups. but your data may be irreplaceable! Normally one would schedule a hierarchy of daily. For example. It is advisable to use more than one of these methods to backup your database. set the tablespaces into backup mode and backup their files. and control files. Ensure enough backup media (tapes) are available and that old backups are expired in-time to make media available for new backups. use the “rman” utility to backup the database. Cold or Off-line Backups . however consult with your users before deciding on a backup schedule.Shut the database down and backup up ALL data. Also remember to backup the control files and archived redo log files. you could very well lose your job. also cover yourself by doing database exports. Carefully plan backup retention periods. it’s the little things that will get you. Most failed recoveries are a result of organizational errors and miscommunications. Also test ALL 5 . if you choose to do on-line database backups.Exports are “logical” database backups in that they extract logical definitions and data from the database to a file. RMAN Backups .

backup and recovery scenarios carefully. This can be done to replace damaged files or to copy/move a database to a new location. shutdown using these commands: alter system checkpoint. Except for Oracle exports. Always do full system level exports (FULL=YES). Other backup strategies normally back-up the physical data files. also remember to backup all required software libraries. One of the advantages of exports is that one can selectively re-import tables. ALTER TABLESPACE xyz BEGIN BACKUP. however one cannot rollforward from an restored export file. If you cannot take your database down for a cold (off-line) backup at a convenient time. What is the difference between online and offline backups? A hot backup is a backup performed while the database is online and available for read/write. one can only do on-line backups when running in ARCHIVELOG mode. Do the following queries to get a list of all files that needs to be backed up: select name from sys. 6 . As workaround to this problem. tapes). parameter files. If your database is in ARCGIVELOG mode. one can still use archived log files to roll forward from an off-line backup. Sometimes Oracle takes forever to shutdown with the “immediate” option. Ensure that you backup all data files. Sql> connect SYS as SYSDBA Sql> RECOVER DATABASE UNTIL TIME ‘2001-03-06:16:00:00’ USING BACKUP CONTROLFILE. shutdown abort startup restrict shutdown immediate Note that if you database is in ARCHIVELOG mode. One can roll-forward until a specific point-in-time (before the disaster occurred). Recovery is the process of applying redo logs to the database to roll it forward. all control files and all log files. select member from sys. you also need to backup archived log files. Backup all files to secondary storage (eg. A cold backup is a backup performed while the database is off-line and unavailable to its users. How does one backup a database using the export utility? Oracle exports are “logical” database backups (not physical) as they extract data and logical definitions from the database into a file.v_$datafile. password files. It is better to be save than sorry.v_$logfile. How does one do on-line database backups? Each tablespace that needs to be backed-up must be switched into backup mode before copying the files out to secondary storage (tapes). When completed. select name from sys. restart your database. etc. Look at this simple example. switch your database into ARCHIVELOG mode and perform hot (on-line) backups. How does one do off-line database backups? Shut down the database from sqlplus or server manager. or roll-forward until the last transaction recorded in the log files. To completely restore a database from an export file one practically needs to recreate the entire database. Regardless of your strategy.v_$controlfile. Full exports include more information about the database in the export file than user level exports. What is the difference between restoring and recovering? Restoring involves copying backup files from secondary storage (backup media) to disk.

! cp xyfFile1 /backupDir/ ALTER TABLESPACE xyz END BACKUP; It is better to backup tablespace for tablespace than to put all tablespaces in backup mode. Backing them up separately incurs less overhead. When done, remember to backup your control files. Look at this example: ALTER SYSTEM SWITCH LOGFILE; -- Force log switch to update control file headers ALTER DATABASE BACKUP CONTROLFILE TO ‘/backupDir/control.dbf’; NOTE: Do not run on-line backups during peak processing periods. Oracle will write complete database blocks instead of the normal deltas to redo log files while in backup mode. This will lead to excessive database archiving and even database freezes.

How does one backup a database using RMAN?
The biggest advantage of RMAN is that it only backup used space in the database. Rman doesn’t put tablespaces in backup mode, saving on redo generation overhead. RMAN will re-read database blocks until it gets a consistent image of it. Look at this simple backup example. rman target sys/*** nocatalog run { allocate channel t1 type disk; backup format ‘/app/oracle/db_backup/%d_t%t_s%s_p%p’ ( database ); release channel t1; } Example RMAN restore: rman target sys/*** nocatalog run { allocate channel t1 type disk; # set until time ‘Aug 07 2000 :51’; restore tablespace users; recover tablespace users; release channel t1; } The examples above are extremely simplistic and only useful for illustrating basic concepts. By default Oracle uses the database controlfiles to store information about backups. Normally one would rather setup a RMAN catalog database to store RMAN metadata in. Read the Oracle Backup and Recovery Guide before implementing any RMAN backups. Note: RMAN cannot write image copies directly to tape. One needs to use a third-party media manager that integrates with RMAN to backup directly to tape. Alternatively one can backup to disk and then manually copy the backups to tape.

How does one put a database into ARCHIVELOG mode?
The main reason for running in archivelog mode is that one can provide 24-hour availability and guarantee complete data recoverability. It is also necessary to enable ARCHIVELOG mode before one can start to use on-line database backups. To enable ARCHIVELOG mode, simply change your database startup command script, and bounce the database: SQLPLUS> connect sys as sysdba SQLPLUS> startup mount exclusive; SQLPLUS> alter database archivelog; SQLPLUS> archive log start; SQLPLUS> alter database open; NOTE1: Remember to take a baseline database backup right after enabling archivelog mode. Without it one would not be able to recover. Also, implement an archivelog backup to prevent the archive log

7

directory from filling-up. NOTE2: ARCHIVELOG mode was introduced with Oracle V6, and is essential for database point-intime recovery. Archiving can be used in combination with on-line and off-line database backups. NOTE3: You may want to set the following INIT.ORA parameters when enabling ARCHIVELOG mode: log_archive_start=TRUE, log_archive_dest=... and log_archive_format=... NOTE4: You can change the archive log destination of a database on-line with the ARCHIVE LOG START TO ‘directory’; statement. This statement is often used to switch archiving between a set of directories. NOTE5: When running Oracle Real Application Server (RAC), you need to shut down all nodes before changing the database to ARCHIVELOG mode.

How does one backup archived log files?
One can backup archived log files using RMAN or any operating system backup utility. Remember to delete files after backing them up to prevent the archive log directory from filling up. If the archive log directory becomes full, your database will hang! Look at this simple RMAN backup script: RMAN> run { 2> allocate channel dev1 type disk; 3> backup 4> format ‘/app/oracle/arch_backup/log_t%t_s%s_p%p’ 5> (archivelog all delete input); 6> release channel dev1; 7> }

Does Oracle write to data files in begin/hot backup mode?
Oracle will stop updating file headers, but will continue to write data to the database files even if a tablespace is in backup mode. In backup mode, Oracle will write out complete changed blocks to the redo log files. Normally only deltas (changes) are logged to the redo logs. This is done to enable reconstruction of a block if only half of it was backed up (split blocks). Because of this, one should notice increased log activity and archiving during on-line backups.

My database was terminated while in BACKUP MODE, do I need to recover?
If a database was terminated while one of its tablespaces was in BACKUP MODE (ALTER TABLESPACE xyz BEGIN BACKUP;), it will tell you that media recovery is required when you try to restart the database. The DBA is then required to recover the database and apply all archived logs to the database. However, from Oracle7.2, you can simply take the individual datafiles out of backup mode and restart the database. ALTER DATABASE DATAFILE ‘/path/filename’ END BACKUP; One can select from V$BACKUP to see which datafiles are in backup mode. This normally saves a significant amount of database down time.
Thiru Vadivelu contributed the following:

From Oracle9i onwards, the following command can be used to take all of the datafiles out of hot backup mode: ALTER DATABASE END BACKUP;

The above commands need to be issued when the database is mounted. My database is down and I cannot restore. What now?
Recovery without any backup is normally not supported, however, Oracle Consulting can sometimes extract data from an offline database using a utility called DUL (Disk UnLoad). This utility reads data in the data files and unloads it into SQL*Loader or export dump files. DUL does not care about rollback segments, corrupted blocks, etc, and can thus not guarantee that the data is not logically corrupt. It is intended as an absolute last resort and will most likely cost your company a lot of money!!!

8

I’ve lost my REDOLOG files, how can I get my DB back?
The following INIT.ORA parameter may be required if your current redo logs are corrupted or blown away. Caution is advised when enabling this parameter as you might end-up losing your entire database. Please contact Oracle Support before using it.
_allow_resetlogs_corruption = true

I’ve lost some Rollback Segments, how can I get my DB back?
Re-start your database with the following INIT.ORA parameter if one of your rollback segments is corrupted. You can then drop the corrupted rollback segments and create it from scratch.

Caution is advised when enabling this parameter, as uncommitted transactions will be marked as committed. One can very well end up with lost or inconsistent data!!! Please contact Oracle Support before using it.
_Corrupted_rollback_segments = (rbs01, rbs01, rbs03, rbs04)

What are the differences between EBU and RMAN?
Enterprise Backup Utility (EBU) is a functionally rich, high performance interface for backing up Oracle7 databases. It is sometimes referred to as OEBU for Oracle Enterprise Backup Utility. The Oracle Recovery Manager (RMAN) utility that ships with Oracle8 and above is similar to Oracle7’s EBU utility. However, there is no direct upgrade path from EBU to RMAN.

How does one create a RMAN recovery catalog? Start by creating a database schema (usually called rman). Assign an appropriate tablespace to it and grant it the recovery_catalog_owner role. Look at this example:
sqlplus sys SQL> create user rman identified by rman; SQL> alter user rman default tablespace tools temporary tablespace temp; SQL> alter user rman quota unlimited on tools; SQL> grant connect, resource, recovery_catalog_owner to rman; SQL> exit;

Next, log in to rman and create the catalog schema. Prior to Oracle 8i this was done by running the catrman.sql script.
rman catalog rman/rman RMAN> create catalog tablespace tools; RMAN> exit;

You can now continue by registering your databases in the catalog. Look at this example:
rman catalog rman/rman target backdba/backdba RMAN> register database;

What are the common RMAN errors (with solutions)?
Some of the common RMAN errors are: RMAN-20242: Specification does not match any archivelog in the recovery catalog.

Add to RMAN script: sql ‘alter system archive log current’; RMAN-06089: archived log xyz not found or out of sync with catalog
Execute from RMAN: change archivelog all validate;

What third party tools can be used with Oracle EBU/ RMAN?
The following Media Management Software Vendors have integrated their media management software packages with Oracle Recovery Manager and Oracle7 Enterprise Backup Utility. The Media Management Vendors will provide first line technical support for the integrated backup/recover solutions.

Veritas NetBackup EMC Data Manager (EDM) HP OMNIBack II IBM’s Tivoli Storage Manager - formerly ADSM Legato Networker

9

McGraw-Hill Professional Publishing) Oracle Monitoring and Performance Tuning Why and when should one tune? One of the biggest responsibilities of a DBA is to ensure that the Oracle database is tuned properly. one needs to remember than you cannot tune a Buick into a Ferrari. One should do performance tuning for the following reasons: The speed of computing might be wasting valuable human time (users waiting for response).formerly from Spectralogic Sun Solstice Backup . Selective denormalization can provide valuable performance improvements. For example.) to take appropriate action. data replication. Also look at proper data partitioning. Infrastructure availability: • • • • • • • • Is the database up and responding to requests Are the listeners up and responding to requests Are the Oracle Names and LDAP Servers up and responding to requests Are the Web Listeners up and responding to requests Is the archive log destination filling up? Objects getting close to their max extents Tablespaces running low on free space/ Objects what would not be able to extend User and process limits reached Things that can cause service outages: Things that can cause bad performance: See question “What tuning indicators can one use?”. or buying a third-party monitoring product can achieve this. etc. Database Design (if it’s not too late): Poor system performance usually results from a poor database design. aggregation tables for decision support systems. The order in which steps are listed needs to be maintained to prevent tuning side effects. Application Tuning: 10 . Although this FAQ is not overly concerned with hardware issues.ManageIT Backup and Recovery Sterling Software’s SAMS:Alexandria . Writing custom scripts. and Optimize hardware usage to save money (companies are spending millions on hardware). it is no good increasing the buffer cache if you can reduce I/O by rewriting a SQL statement. If an alarm is triggered. always keep the “data access path” in mind. the system should automatically notify the DBA (email.Backup Strategy • Oracle Backup and Recovery Handbook (Rama Velpuri. The Oracle RDBMS is highly tunable and allows the database to be monitored and adjusted to increase its performance. When designing. Where should the tuning effort be directed? Consider the following areas for tuning. page. implementing Oracle’s Enterprise Manager. What database aspects should be monitored? One should implement a monitoring system to constantly monitor the following aspects of a database. One should generally normalize to the 3NF. Enable your system to keep-up with the speed business is conducted. etc. Books on Oracle Backup and Recovery? Kevin Loney’s New DBA FAQs: Part 1 .

Install Statspack sqlplus “/ as sysdba” @spcreate. SNAP_TIME from STATS$SNAPSHOT. What tuning indicators can one use? The following high-level tuning indicators can be used to establish if a database is performing optimally or not: • Buffer Cache Hit Ratio Formula: Hit Ratio = (Logical Reads . Pin large objects into memory to prevent frequent reloads. etc) by looking at your buffer hit ratios. missing indexes. tables and package on a database (Run as SYS).sql . • Get a list of snapshots select SNAP_ID. read the documentation in file $ORACLE_HOME/rdbms/admin/spdoc. Also look for frequent disk sorts. log buffer.Tuning Pack What is STATSPACK and how does one use it? Statspack is a set of performance monitoring and reporting utilities provided by Oracle from Oracle8i and above.snap.Delete a range of Snapshot Id’s from the database spreport.SQL and UTLESTAT. For more information.Physical Reads) / Logical Reads Action: Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) to increase hit ratio • Library Cache Hit Ratio Action: Increase the SHARED_POOL_SIZE to increase hit ratio What tools/utilities does Oracle provide to assist with performance tuning? Oracle provide the following tools/ utilities to assist with performance monitoring and tuning: • TKProf • UTLBSTAT. full table scans.sql .sql -. spdrop. buffer cache. though the old BSTAT/ESTAT scripts are still available.txt.sql .Installs the STATSPACK user. Statspack provides improved BSTAT/ESTAT functionality.Purge a range of Snapshot Id’s between the specified begin and end Snap Id’s spauto. For more information about STATSPACK. read the related Oracle FAQ dealing with your specific operating system. Tune the Operating System: Monitor and tune operating system CPU. Install Statspack: cd $ORACLE_HOME/rdbms/admin sqlplus “/ as sysdba” @spdrop.sql . latches and wait events carefully and eliminate where possible. data fragmentation. etc. -.Take a performance snapshots exec statspack.Begin and end stats monitoring • Statspack • Oracle Enterprise Manager .sql -. @spreport.Report on differences between values recorded in two snapshots sptrunc. I/O and memory utilization.Experience showed that approximately 80% of all Oracle system performance problems are resolved by coding optimal SQL.Enter tablespace names when prompted Use Statspack: sqlplus perfstat/perfstat exec statspack.Deinstall STATSPACK from database (Run as SYS) sppurge.Schedule a dbms_job to automate the collection of STATPACK statistics spcreate.Truncates all data in Statspack tables When is cost based optimization triggered? 11 . Also consider proper scheduling of batch tasks after peak working hours. Disk I/O Tuning: Database files needs to be properly sized and placed to provide maximum disk subsystem throughput. Memory Tuning: Properly size your database buffers (shared pool.sql .SQL .sql-.sql .sql .snap. row chaining.Enter two snapshot id’s for difference report Other Statspack Scripts: • • • • • • • sppurge. Eliminate Database Contention: Study database locks.

it won’t help much to just have the larger tables analyzed. to extract the required information.NUM_ROWS .CLUSTERING_FACTOR . Why is Oracle not using the damn index? This problem normally only arises when the query plan is being generated by the Cost Based Optimizer. Some factors that can cause a plan to change are: • Which tables are currently analyzed? Were they previously analyzed? (ie. Was the query using RBO and now CBO?) • Has OPTIMIZER_MODE been changed in INIT.This defines how ordered the rows are in the index. How can one optimize %XYZ% queries? It is possible to improve %XYZ% queries by forcing the optimizer to scan all the entries from the index instead of the table.A higher value will make the cost of a FULL TABLE SCAN cheaper. Generally. The $ORACLE_HOME/rdbms/admin/catio. My query was fine last week and now it is slow. For more details. If CLUSTERING_FACTOR approaches the number of blocks in the table. As the NUM_DISTINCT decreases.sql script creates a sample_io procedure and table to gather the required information. Change statistics of objects by doing an ANALYZE. Usually the previous plan is not available. what percentage was used? • Have the statistics changed? • Has the INIT. After executing the procedure. the CBO can change the execution plan when you: 1.ORA parameters been changed? • What do you think the plan should be? Run the query with hints to see if this produces the required performance. 2.This column defines the number of distinct values the column holds. Generate a current explain plan of the offending query and compare it to a previous one that was taken when the query was performing well. the rows are ordered. This can be done by specifying hints. sort_area_size. In such a case. for the index to be used 12 . • USER_INDEXES. If one table involved in a statement does not have statistics.ORA parameter DB_FILE_MULTIBLOCK_READ_COUNT .NUM_DISTINCT . The usual cause is because the CBO calculates that executing a Full Table Scan would be faster than accessing the table via the index.ORA parameter DB_FILE_MULTIBLOCK_READ_COUNT been changed? • Has the INIT.If NUM_DISTINCT = NUM_ROWS then using an index would be preferable to doing a FULL TABLE SCAN. Oracle has to revert to rule-based optimization for that statement.ORA parameter SORT_AREA_SIZE been changed? • Have any other INIT. Fundamental things that can be checked are: • USER_TAB_COLUMNS. If the index is physically smaller than the table (which is usually the case) it will take less time to scan the entire index than to scan the entire table. Why? The likely cause of this is because the execution plan has changed. look at the header comments in the $ORACLE_HOME/rdbms/admin/catio. • Remember that you MUST supply the leading column of an index.ORA? • Has the DEGREE of parallelism been defined/changed on any table? • Have the tables been re-analyzed? Were the tables analyzed using estimate or compute? If estimate.It’s important to have statistics on all tables for the CBO (Cost Based Optimizer) to work correctly. the rows are randomly ordered. Change some initialization parameters (for example: hash_join_enabled. Where can one find I/O statistics per table? The UTLESTAT report shows I/O per tablespace but one cannot see what tables in the tablespace has the most I/O. So you really want for all tables to have statistics right away. the cost of using an index increase thereby is making the index less desirable.sql script. • Decrease the INIT. one can do a simple SELECT * FROM io_per_object. If it approaches the number of rows in the table. • USER_TABLES. db_file_multiblock_read_count). it is unlikely that index entries in the same leaf block will point to rows in the same data blocks.

Make sure all objects are analyzed. Compare this to the explain plan when not using an index. How does one tune Oracle Wait events? Some wait events from V$SESSION_WAIT and V$SYSTEM_EVENT views: Event Name: Tuning Recommendation: db file sequential Tune SQL to do less I/O. This row is overwritten by the next ANALYZE INDEX command. This statistic is NORMALLY indicating disk contention on full table scans. Redistribute I/O across read disks. The ‘badness’ of the index can then be judged by the ratio of ‘DEL_LF_ROWS’ to ‘LF_ROWS’.event = ‘db file sequential read’ b. but can be multiple blocks).average_wait “SEQ READ”.V$BH log buffer space Increase LOG_BUFFER parameter or move log files to faster disks What is the difference between DBFile Sequential and Scattered Reads? Both “db file sequential read” and “db file scattered read” events signify time waited for I/O read requests to complete. This event is also used for rebuilding the controlfile and reading datafile headers (P2=1). except that the session is reading multiple data blocks and scatters them into different discontinuous buffers in the SGA. Rarely.• (unless you use a FAST FULL SCAN or SKIP SCANNING). There are many other factors that affect the cost. Single block I/Os are usually the result of using indexes. sys. db file scattered read: Similar to db file sequential reads. Obtain an explain plan of the query either using TKPROF with TIMED_STATISTICS. but sometimes the above can help to show why an index is not being used by the CBO. or with AUTOTRACE to see the statistics. In general.v_$system_event a. When should one rebuild an index? You can run the ‘ANALYZE INDEX VALIDATE STRUCTURE’ command on the affected indexes each invocation of this command creates a single row in the INDEX_STATS view. db file sequential read: A sequential read operation reads data into contiguous memory (usually a single-block read with p3=1. 13 . Instead they should think of how data is read into the SGA buffer cache. so that one can see the CPU utilization. try specifying an index hint.event = ‘db file scattered read’. Most people confuse these events with each other as they think of how data is read from disk.v_$system_event b a. these waits would then show up as sequential reads instead of scattered reads. Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i)/ Analyze buffer busy waits contention from SYS. and 1000’s of a second for Oracle 9i and above. this event is indicative of disk contention on index reads.average_wait “SCAT READ” sys. The following query shows average wait time for sequential versus scattered reads: prompt select from where and “AVERAGE WAIT TIME FOR READ REQUESTS” a. so copy the contents of the view into a local table after each ANALYZE. If from checking the above you still feel that the query should be using an index. Time is reported in 100’s of a second for Oracle 8i releases and below. data from full table scans could be fitted into a contiguous buffer area. b.

development teams. More seriously though. What are the three major characteristics that you bring to the job market? What motivates you to do a good job? What two or three things are most important to you at work? What qualities do you think are essential to be successful in this kind of work? What courses did you attend? What job certifications do you hold? What subjects/courses did you excel in? Why? What subjects/courses gave you trouble? Why? How does your previous work experience prepare you for this position? 14 . DBAs get the enviable task of figuring out all of the things no one else can figure out. or doesn’t have the ability to do.DBA Tasks. assign privileges) • Perform database tuning and performance monitoring • Perform application tuning and performance monitoring • Setup and maintain documentation and standards • Plan growth and changes (capacity planning) • Work as part of a team and provide 7x24 support when required • Perform general technical trouble shooting and give consultation to development teams • Interface with Oracle Corporation for technical support. related utilities and tools A good understanding of the underlying operating system A good knowledge of the physical database design Ability to perform both Oracle and operating system performance tuning and monitoring Knowledge of ALL Oracle backup and recovery scenarios A good knowledge of Oracle security management A good knowledge of how Oracle acquires and manages resources A good knowledge Oracle data integrity Sound knowledge of the implemented application systems Experience in code migration. vendors and systems administrators Provide a strategic database direction for the organisation A DBA should have the ability to handle multiple projects and deadlines A DBA should possess a sound understanding of the business Interview Questions • • • • • • • • • Tell us about yourself/ your background. database change management and data management through the various stages of the development life cycle A sound knowledge of both database and system performance tuning A DBA should have sound communication skills with management. configuration and upgrading of Oracle server software and related products • Evaluate Oracle features and Oracle related products • Establish and maintain sound backup and recovery policies and procedures • Take care of the Database design and implementation • Implement and maintain database security (create and maintain users and roles. here is a list of typical DBA responsibilities: • Installation. • Required Skills: • • • • • • • • • • • • • • • Good understanding of the Oracle database. Responsibilities and Skills Required DBA Responsibilities: The job of the DBA seems to be everything that everyone else either doesn’t want to do.

Why would you prefer to work on one and not on the other? 15 . . what will you do to resolve it? Compare Oracle to any other database that you know. the ‘ideal’ supervisor. Why should we hire you? Where do you see yourself fitting in to this organization . (b) 10 years from now? How does this position match your career goals? What have you done in the past year to improve yourself? In what areas do you feel you need further education and training to be successful? What do you know about our company? Why do you want to work for this company. how would you approach it and what questions will you ask? If a customer calls you about a hanging database session.in 5 years? Why are you looking for a new job? How do you feel about re-locating? Are you willing to travel? What are your salary requirements? When would you be available to start if you were selected? Did you use online or off-line backups? What version of Oracle were you running? Haw many databases and what sizes? If you have to advise a backup strategy for a new application.. .• • • • • • • • • • • • • • • • • • • • • • • • • • How do you define ‘success’? What has been your most significant accomplishment to date? Describe a challenge you encountered and how you dealt with it. Describe the ‘ideal’ job. .initially? .. . Describe a failure and how you dealt with it. What leadership roles have you held? What prejudices do you hold? What do you like to do in your spare time? What are your career goals (a) 3 years from now.

or. One can get a list of all hidden parameters by executing this query: select * from SYS. level 12 This shows both bind variable names and wait events in the SQL trace files • 1401 trace name errorstack. but will spin or sleep until they obtain a resource. enqueues and semaphores? A latch is an internal Oracle mechanism used to protect data structures in the SGA from simultaneous access. Semaphores are controlled by the following Unix parameters: semmni.Oracle Database Internals What is the difference between locks.indx = c. The alter session method only affects the user’s current session. “Session Value”.ORA parameter file can activate events. Latches are more restrictive than locks in that they are always exclusive.. Atomic hardware instructions like TEST-AND-SET is used to implement latches. x$ksppcv b.ksppinm. Latches are never queued.1)=’_’ order by a. The following two examples are simply to demonstrate syntax.ksppinm “Parameter”. What database events can be set? The following events are frequently used by DBAs and Oracle Support to diagnose problems: • 10046 trace name context forever. level 12 1401 trace name errorstack. E. semmsl = semmns Where can one get a list of all hidden Oracle parameters? Oracle initialization or INIT.g. by issuing an ALTER SESSION SET EVENTS command: E.1.ora for each instance) semmni = number of instances running simultaneously. level 4 Trace SQL statements and show bind variables in trace output. level 8 This shows wait events in the SQL trace files • 10046 trace name context forever. semmns and semmsl.ksppstvl Remember: Thou shall not play with undocumented parameters! What is a database EVENT and how does one set it? Oracle trace events are useful for debugging the Oracle database server.indx and a. or time out. Both support queuing and concurrency. latches.1. whereas changes to the INIT.. event=’1401 trace name errorstack. b. level 4 1401 trace name processstate 16 . alter session set events ‘10046 trace name context forever.ksppstvl “Instance Value” from x$ksppi a. Either adding them to the INIT. level 12’ . • 10046 trace name context forever.indx and substr(ksppinm.ORA file will affect all sessions once the database has been restarted. x$ksppsv c where a. level 4’. They are queued and serviced in a first-in-first-out (FIFO) order. c.indx = b. Refer to later notes on this page for an explanation of what these particular events do. Enqueues and locks are different names for the same thing.ORA parameters with an underscore in front are hidden or unsupported parameters.g. Typical settings are: semmns = sum of the “processes” parameter for each instance (see init<instance>. Semaphores are an operating system facility used to control waiting. The following query displays parameter names with their current value: select a.1) = ‘_’.X$KSPPI where substr(KSPPINM.

The 1401 can be replaced by any other Oracle Server error code that you want to trace. They might be version specific.Dumps out trace information if an ORA-1401 “inserted value too large for column” error occurs. On Unix. level 2 Data block check • 10211 trace name context forever. • 60 trace name errorstack level 10 Show where in the code Oracle gets a deadlock (ORA-60). level 1’ / • Dump a database block (File/ Block must be converted to DBA address) Convert file and block number to a DBA (database block address). • Dump control file contents alter session set events ‘immediate trace name CONTROLF level 10’ / • Dump file headers alter session set events ‘immediate trace name FILE_HDRS level 10’ / • Dump redo log headers alter session set events ‘immediate trace name REDOHDR level 10’ / • Dump the system state NOTE: Take 3 successive SYSTEMSTATE dumps. level 1 Memory heap check • 10262 trace name context forever. The following lists of events are examples only. level 300 Allow 300 bytes memory leak for connections Note: You can use the Unix oerr command to get the description of an event. you can type “oerr ora 10053” from the command prompt to get event details. so please call Oracle before using them: • 10210 trace name context forever. level 10 10211 trace name context forever. with 10-minute intervals alter session set events ‘immediate trace name SYSTEMSTATE level 10’ / • Dump the process state alter session set events ‘immediate trace name PROCESSSTATE level 10’ / • Dump Library Cache details alter session set events ‘immediate trace name library cache level 10’ / • Dump optimizer statistics whenever a SQL statement is parsed (hint: change statement or flush pool) alter session set events ‘10053 trace name context forever. level 10 10231 trace name context forever. exec :x := dbms_utility.12). level 10 These events prevent database block corruptions • 10049 trace name context forever. Eg: variable x varchar2.make_data_block_address(1. level 2 Index block check • 10235 trace name context forever. print x alter session set events ‘immediate trace name blockdump level 50360894’ / 17 . How can one dump internal database structures? The following (mostly undocumented) commands can be used to obtain information about internal database structures. and may help to diagnose the problem. level 2 Memory protect cursor • 10210 trace name context forever.

The list may not be complete or accurate. Cache Buffer Current Buffer Header Fixed Table. Anyone brave enough to test this one for us? Previously this functionality was available with ORADBX (ls -l $ORACLE_HOME/rdbms/lib/oradbx. but it is hard to find them. Look at these examples: SQLPLUS> REM Trace SQL statements with bind variables SQLPLUS> oradebug setospid 10121 Oracle pid: 91. One should generally not write queries against these tables as they are internal to Oracle. What is in all those X$ tables? The following list attempts to describe some x$ tables. X$K2GTE2 X$K2GTE X$BH Kernel 2 Phase Commit Global Transaction Entry Fixed Table Kernel 2 Phase Commit Global Transaction Entry Fixed Table Buffer headers contain information describing the current contents of a piece of the buffer cache. The db_block_lru_statistics parameter has to be set to true to gather information in this table. It can predict the potential loss of decreasing the number of database buffers. but represents an attempt to figure out what information they contain. and Oracle may change them without any prior notification. level 12 Statement processed. Look at these examples: From Server Manager (Oracle7.e 0x8066d338 from convres dump) Are there any undocumented commands in Oracle? Sure there are.mk oradbx) SQL*Plus: ALTER SESSION SET CURRENT_SCHEMA = SYS.o. File Header Fixed Table SGA Cache Entry Fixed Table Sequence Cache Statistics Fixed Table Histogram structure Fixed Table X$KCBCBH X$KCVFH X$KDNCE X$KDNST X$KDXHS 18 . make -f oracle. Unix process pid: 10121. SQLPLUS> oradebug TRACEFILE_NAME /app/oracle/admin/orcl/bdump/pmon_1436.trc SQLPLUS> REM Trace Process Statistics SQLPLUS> oradebug setorapid 2 Unix process pid: 1436. image: oracleorcl SQLPLUS> oradebug EVENT 10046 trace name context forever. SQLPLUS> ! vi /app/oracle/admin/orcl/bdump/ora_10121.How does one use ORADEBUG from Server Manager/ SQL*Plus? Execute the “ORADEBUG HELP” command from svrmgrl or sqlplus to obtain a list of valid ORADEBUG commands. image: ora_pmon_orcl SQLPLUS> oradebug procstat Statement processed.trc SQLPLUS> REM List semaphores and shared memory segments in use SQLPLUS> oradebug ipc SQLPLUS> REM Dump Error Stack SQLPLUS> oradebug setospid <pid> SQLPLUS> oradebug event immediate trace name errorstack level 3 SQLPLUS> REM Dump Parallel Server DLM locks SQLPLUS> oradebug lkdebug -a convlock SQLPLUS> oradebug lkdebug -a convres SQLPLUS> oradebug lkdebug -r <resource handle> (i.3 and above): ORADEBUG HELP It looks like one can change memory locations with the ORADEBUG POKE command.

For example. See the gets and waits for different types of enqueues: Oracle Kernel Subsystems Listed below are some of the important subsystems in the Oracle kernel. you will at least know where they come from: 19 .X$KDXST X$KGHLU X$KGLBODY X$KGLCLUSTER X$KGLINDEX X$KGLLC X$KGLPN X$KGLTABLE X$KGLTR X$KGLTRIGGER X$KGLXS X$KKMMD X$KKSBV X$KSMSP X$KSQDN X$KSQST X$KSUCF X$KSUPL X$KSURU X$KSQST X$KTTVS X$KVII X$KVIS X$KVIT X$KXFPCDS X$KXFPCMS X$KZDOS X$KZSRO X$LE X$MESSAGES Statistics collection Fixed Table One-row summary of LRU statistics for the shared pool Derived from X$KGLOB (col kglhdnsp = 2) Derived from X$KGLOB (col kglhdnsp = 5) Derived from X$KGLOB (col kglhdnsp = 4) Latch Clean-up state for library cache objects Fixed Table Library cache pin Fixed Table Derived from X$KGLOB (col kglhdnsp = 1) Library Cache Translation Table entry Fixed Table Derived from X$KGLOB (col kglhdnsp = 3) Library Cache Access Table Fixed table to look at what databases are mounted and their status Cursor Cache Bind Variables Each row represents a piece of memory in the shared pool Global database name Enqueue statistics by type Cost function for each Kernel Profile (join to X$KSUPL) Resource Limit for each Kernel Profile Resource Usage for each Kernel Profile (join with X$KSUPL) Gets and waits for different types of enqueues Indicate tablespace that has valid save undo segments Internal instance parameters set at instance initialization Oracle Data Block (size_t type) variables Instance internal flags. variables and parameters that can change during the life of an instance Client Dequeue Statistics Client Messages Statistics Represent an os role as defined by the operating system Security state Role: List of enabled roles Lock Element: each PCM lock that is used by the buffer cache (gc_db_locks) Displays all the different messages that can be sent to the Background processes X$NLS_PARAMETE NLS database parameters RS Handy X$table queries Some handy queries based on the X$ memory tables: • Largest # blocks you can write at any given time: • select kviival write_batch_size from x$kvii where kviitag = ‘kcbswc’. select * from x$ksqst where ksqstget > 0. This table might help you to read those dreaded trace files and internal messages. if you see messages like this.

Bind and execute SQL and PL/SQL Distributed Execution Layer .OPIRIP: Uncaught error 447. From Oracle8 you can just type “password” from SQL*Plus. -.Assign password -. assign the required privileges: GRANT CONNECT.Remove user After creating a new user. RESOURCE TO scott.Parse SQL. DROP USER scott CASCADE.Assign sort space -.2PC handling Network Program Interface Security Layer . Error stack: KCF: write/open error block=0x3e800 online=1 Kernel Subsystems: OPI KK KX K2 NPI KZ KQ RPI KA KD KT KC KS KJ KG KV S or ODS Oracle Program Interface Compilation Layer . 20 . type “password user_name”. compile PL/SQL Execution Layer .Assign space for table and -. x$KVIS and X$KVII) Operating System Dependencies Oracle Security How does one change an Oracle user’s password? Issue the following SQL command: ALTER USER <username> IDENTIFIED BY <new_password>. or if you need to change another user’s password.Validate privs Query Layer Recursive Program Interface Access Layer Data Layer Transaction Layer Cache Layer Services Layer Lock Manager Layer Generic Layer Kernel Variables (eg. Look at this example: SQL> password Changing password for SCOTT Old password: New password: Retype new password: How does one create and drop database users? Look at these examples: CREATE USER scott IDENTIFIED BY tiger DEFAULT TABLESACE tools index segments TEMPORARY TABLESPACE temp.

-.number of password changes required before the current password can be reused • PASSWORD_LOCK_TIME . etc. 21 . This means that one can hack an account for years without ever locking the user.GRANT DBA TO scott. all accounts except SYS and SYSTEM will be locked after creating an Oracle9iDB database using the DB Configuration Assistant (dbca). This password file is created with the orapwd utility. ALTER USER scott PROFILE my_profile. Remote connections via Net8 are classified as non-secure. Some of the things that one can restrict: • FAILED_LOGIN_ATTEMPTS . One needs to create a password files before remote administrators (like OEM) will be allowed to connect.failed login attempts before the account is locked • PASSWORD_LIFE_TIME . What is an administrative (privileged) user? Oracle DBAs and operators typically use administrative accounts to manage the database and database instance.Make user a DB Administrator Remember to give the user some space quota on its tablespaces: ALTER USER scott QUOTA UNLIMITED ON tools.number of days an account will be locked after maximum failed login attempts • PASSWORD_GRACE_TIME .number of days after the grace period begins during which a warning is issued and login is allowed • PASSWORD_VERIFY_FUNCTION . -. SYSDBA and SYSOPER allow access to a database instance even if it is not running. For example. forced to choose new passwords. These passwords are stored in password files. Look at these examples: ALTER USER scott ACCOUNT LOCK -. passwords don’t ever expire. An administrative account is a user that is granted SYSOPER or SYSDBA privileges. Oracle will allow users to choose single character passwords and passwords that match their names and userids. -. A password is required for “non-secure” administrative access.number of days before a password can be reused • PASSWORD_REUSE_MAX . Control of these privileges is managed outside of the database via password files and special operating system groups.Force user to choose a new password How does one enforce strict password control? By default Oracle’s security is not extremely good. From Oracle8 one can manage passwords through profiles.limits the number of days the same password can be used for authentication • PASSWORD_REUSE_TIME . or the “ORA_DBA” (ORA_sid_DBA) group on NT. For example. How does one connect to an administrative user? If an administrative user belongs to the “dba” group on Unix. Look at this example: connect sys/password as sysdba How does one create a password file? The Oracle Password File ($ORACLE_HOME/dbs/orapw or orapwSID) stores passwords for users with administrative privileges. This is equivalent to the desupported “connect internal” method.unlocks a locked users account ALTER USER scott PASSWORD EXPIRE. unlocked. Also. How does one manage Oracle database users? Oracle user accounts can be locked.lock a user account ALTER USER scott ACCOUNT UNLOCK. DBA’s must unlock these accounts to make them available to users.password complexity verification script Look at this simple example: CREATE PROFILE my_profile LIMIT PASSWORD_LIFE_TIME 30. he/she can connect like this: connect / as sysdba No password is required.

ORA file and ensure REMOTE_LOGIN_PASSWORDFILE=exclusive is set. Why are OPS$ accounts a security risk in a client/server environment? If you allow people to log in with OPS$ accounts from Windows Workstations. GRANT SYSDBA TO scott. you can rely on operating system passwords. How does one switch to another user in Oracle? Users normally use the “connect” statement to connect from one database user to another. However.bsq 22 .ora file. Of course it is not advisable to bridge Oracle’s security. If REMOTE_OS_AUTHENT is set to FALSE (recommended).. Below are a few of them: SYS/CHANGE_ON_INSTALL or INTERNAL Oracle Data Dictionary/ Catalog Created by: ?/rdbms/admin/sql. you cannot be sure who they really are. Who created all these users in my database?/ Can I drop this user? Oracle creates a number of default database users or schemas when a new database is created.sql script in the Useful Scripts and Sample Programs Page. If you set REMOTE_OS_AUTHENT=TRUE in your init. PASSWORD F894844C34402B67 SQL> alter user scott identified by lion. User altered. with Windows. IDENTIFIED EXTERNALLY will only be in effect from the local host. This password is visible in the process table of many systems. you cannot. DBAs can switch from one user to another without a password. but look at this example: SQL> select password from dba_users where username=’SCOTT’. SQL> connect scott/lion Connected. remote users will be unable to connect without a password. regardless of whether you have identified your ID with a password or defined it to be IDENTIFIED EXTERNALLY. Note: Also see the su.. User altered. REM Do whatever you like. or by using the orapwd utility. Administrators needs to be aware of this! How does one add users to a password file? One can select from the SYS. Oracle assumes that the remote OS has authenticated the user. Also.bsq and various cat*. New users can be added to the password file by granting them SYSDBA or SYSOPER privileges. • Startup the database (SQLPLUS> STARTUP) NOTE: The orapwd utility presents a security risk in that it receives a password from the command line.V_$PWFILE_USERS view to see which users are listed in the password file. you will be able to log on locally with or without a password. With terminals. SQL> connect scott/tiger Connected.sql scripts Can password be changed: Yes (Do so right after the database was created) Can user be dropped: NO SYSTEM/MANAGER The default DBA user name (please do not use SYS) Created by: ?/rdbms/admin/sql.Follow this procedure to create a new password file: • Log in as the Oracle software owner • Runcommand: orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=mypasswd • Shutdown the database (SQLPLUS> SHUTDOWN IMMEDIATE) • Edit the INIT. SQL> alter user scott identified by values ‘F894844C34402B67’. if you are using “OPS$” as your prefix. SQL> connect system/manager Connected.

called from catalog. Created by: ?/ord/admin/ordinst. • Must ANALYZE.Only if you do not use the Intelligent Agents ORDPLUGINS/ORDPLUGINS Object Relational Data (ORD) User used by Time Series. A list of defined policies can be obtained from DBA_AUDIT_POLICIES. Audit records are stored in DBA_FGA_AUDIT_TRAIL. etc Created by: ?/ord/admin/ordinst.sql DSSYS/DSSYS Oracle Dynamic Services and Syndication Server Created by: ?/ds/sql/dssys_init. -. ‘EMP’.Drop users cascade from all production environments CTXSYS/CTXSYS Oracle interMedia (ConText Cartridge) administrator user Created by: ?/ctx/admin/dr0csys. ADAMS/WOOD.sql.Will trigger auditing 23 .sql PERFSTAT/PERFSTAT Oracle Statistics Package (STATSPACK) that supersedes UTLBSTAT/UTLESTAT Created by: ?/rdbms/admin/statscre. Training/ demonstration users containing the popular EMPLOYEES and DEPARTMENTS tables Created by: ?/demo/schema/mksample.add_policy(‘HR’.sql Remember to change the passwords for the SYS and SYSTEM users immediately after installation! Except for the user SYS.. select * from EMP where c1 = 11.sql ORDSYS/ORDSYS Object Relational Data (ORD) User used by Time Series.bsq Can password be changed: Yes (Do so right after the database was created) Can user be dropped: NO SCOTT/TIGER.Drop users cascade from all production environments HR/HR (Human Resources).sql TRACESVR/TRACE Oracle Trace server Created by: ?/rdbms/admin/otrcsvr. etc.ora file Can user be dropped: YES . execute dbms_fga.put the new password in snmp_rw. CLARK/CLOTH and BLAKE/PAPER. Training/ demonstration users containing the popular EMP and DEPT tables Created by: ?/rdbms/admin/utlsampl.Can password be changed: Yes (Do so right after the database was created) Can user be dropped: NO OUTLN/OUTLN Stored outlines for optimizer plan stability Created by: ?/rdbms/admin/sql.sql MDSYS/MDSYS Oracle Spatial administrator user Created by: ?/ord/admin/ordinst.sql AURORA$ORB$UNAUTHENTICATED/INVALID Used for users who do not authenticate in Aurora/ORB Created by: ?/javavm/install/init_orb. there should be no problem altering these users to use a different default and temporary tablespace. Look at this example: • Add policy on table with autiting condition. SH/SH (Sales History). ‘policy1’.sql Can password be changed: Yes Can user be dropped: YES .sql Can password be changed: Yes .sql called from ?/javavm/install/initjvm. JONES/STEEL. this feature works with CBO (Cost Based Optimizer) analyze table EMP compute statistics. What is Fine Grained Auditing? Fine Grained Auditing (DBMS_FGA) allows auditing records to be generated when certain rows are selected from a table. OE/OE (Order Entry).sql DBSNMP/DBSNMP Oracle Intelligent agent Created by: ?/rdbms/admin/catsnmp. ‘deptno > 10’)..sql Can password be changed: Yes Can user be dropped: YES .

V$VPD_POLICY to see existing VPD configuration. A VPD offers Fine-Grained Access Control (FGAC) for secure separation of data.. without them knowing about it. Its contains detail of the backups taken etc in its central repository Facility for testing validity of backups also commands like crosscheck to check the status of backup. select sqltext from sys..fga_log$. WHY USE RMAN ? • • • • • • • • • • • • • • • • • • • No extra costs …Its available free RMAN introduced in Oracle 8 it has become simpler with newer versions and easier than user managed backups Proper security You are 100% sure your database has been backed up. -. RMAN WHAT IS RMAN ? Recovery Manager is a tool that: manages the process of creating backups and also manages the process of restoring and recovering from them.fga_log$. controlled and managed from the Policy Manager. Oracle 10g has got further optimized incremental backup which has resulted in improvement of performance during backup and recovery time Parallel operations are supported Better querying facility for knowing different details of backup No extra redo generated when backup is taken. What is Fine Grained Access Control? See question “What is a Virtual Private Database”. delete from sys.select * from EMP where c1 = 09.compared to online backup without RMAN which results in saving of space in hard disk RMAN an intelligent tool Maintains repository of backup metadata Remembers backup set location Knows what need to backed up Knows what is required for recovery Knows what backups are redundant UNDERSTANDING THE RMAN ARCHITECTURE An oracle RMAN comprises of RMAN EXECUTABLE This could be present and fired even through client side TARGET DATABASE This is the database which needs to be backed up . VPD configuration is done via the DBMS_RLS (Row Level Security) package. Access to rows are restricted according to a user’s security sensitivity tag or label. one could even store multiple companies’ data within the same schema. What is a Virtual Private Database? Oracle 8i introduced the notion of a Virtual Private Database (VPD). This ensures that users only have access to data that pertains to them. Using this option. What is Oracle Label Security? Oracle Label Security (formerly called Trusted Oracle MLS RDBMS) uses the VPD (Virtual Private Database) feature of Oracle8i to implement row level security. Faster backups and restores compared to backups without RMAN RMAN is the only backup tool which supports incremental backups. Oracle Label Security is configured.. an Enterprise Manager-based GUI utility. Select from SYS.No auditing • Now we can see the statments that triggered the auditing condition. RECOVERY CATALOG Recovery catalog is optional otherwise backup details are stored in target 24 .

Oracle Enhancement for RMAN in 10 G Flash Recovery Area Right now the price of hard disk is falling.database controlfile . . Example of taking backup using RMAN Taking RMAN Backup In non archive mode in dos prompt type RMAN You get the RMAN prompt RMAN > Connect Target Connect to target database : Magic <Dbid=129283912> using target database controlfile instead of recovery catalog Lets take a simple backup of database in non archive mode shutdown immediate . Backups in RMAN Oracle backups in RMAN are of the following type RMAN complete backup OR RMAN incremental backup These backups are of RMAN proprietary nature IMAGE COPY The advantage of uing Image copy is its not in RMAN proprietary format. Backup Format RMAN backup is not in oracle format but in RMAN format. It is a repository of information queried and updated by Recovery Manager It is a schema or user stored in Oracle database. We can fire the same command in archive log mode And whole of datafiles will be backed Backup database plus archivelog.. Archivelog backup sets One more important point of data file backup sets is it do not include empty blocks.Shutdowns the database startup mount backup database . A single backup piece consists of physical files which are in RMAN proprietary format. Oracle backup comprises of backup sets and it consists of backup pieces. It is just Restore database. RMAN has become intelligent to identify which datafiles has to be restored and the location of backuped up file.its start backing the database alter database open. Many dba are taking oracle database backup inside the hard disk itself since it results in lesser mean time between recoverability. The new parameter introduced is DB_RECOVERY_FILE_DEST = /oracle/flash_recovery_area By configuring the RMAN RETENTION POLICY the flash recovery area will automatically delete obsolete backups and archive logs that are no longer required based on that configuration 25 . A backup set would contain many backup pieces.backup sets and pieces Recovery catalog is a must in following scenarios • • In order to store scripts For tablespace point in time recovery Media Management Software Media Management software is a must if you are using RMAN for storing backup in tape drive directly. Backup sets are logical entity In oracle 9i it gets stored in a default location There are two type of backup sets Datafile backup sets.. Restoring database Restoring database has been made very simple in 9i .. One schema can support many databases It contains information about physical schema of target database datafile and archive log ..

backup sets and image copy Oracle 9i New features Persistent RMAN Configuration A new configure command has been introduced in Oracle 9i .This will results in faster backups lesser space consumption and also reduces the time needed for daily backups Incrementally Updated Backups Oracle database 10g Incrementally Updates Backup features merges the image copy of a datafile with RMAN incremental backup. etc. Now with 9i backup optimization parameter we can prevent repeat backup of read only tablespace and archive log. Block Media Recovery If we can restore a few blocks rather than an entire file we only need few blocks. in addition. RMAN will automatically calculate the appropriate backup rate. We even dont need to bring the data file offline. New Features in Oem to identify RMAN related backup like backup pieces. Binary compression technique reduces backup space usage by 50-75%. that lets you configure various features including automatic channels. DBAs can optionally specify whether backups should minimize time or system load. By specifying a duration. Configure Backup Optimization Prior to 9i whenever we backed up database using RMAN our backup also used take backup of read only table spaces which had already been backed up and also the same with archive log too. DBAs can weigh backup performance against system service level requirements. after every backup or copy command. Syntax for it as follows Block Recover datafile 8 block 22. parallelism .The merging of the image copy and incremental backup is initiated with RMAN recover command. Similar syntax is supported for restores backup device sbt backup set all Copy a disk backup to tape (backing up a backup Additionally it supports • Backup of server parameter file • Parallel operation supported • Extensive reporting available • Scripting • Duplex backup sets • Corrupt block detection • Backup archive logs 26 . Controlfile Auto backups Through this new feature RMAN will automatically perform a controlfile auto backup. These automatic allocations and options can be overridden by commands in a RMAN command file. The resulting image copy is now updated with block changes captured by incremental backups. RMAN automatically attempts to read from an alternate location this is called as archive log failover There are additional commands like backup database not backed up since time ‘31-jan-2002 14:00:00’ Do not backup previously backed up files (say a previous backup failed and you want to restart from where it left off). This results in faster recovery. With the new DURATION option for the RMAN BACKUP command. The command for this is as follows Configure backup optimization on Archive Log failover If RMAN cannot read a block in an archived log from a destination.backup options.Oracle has introduced new features in incremental backup Change Tracking File Oracle 10g has the facility to deliver faster incrementals with the implementation of changed tracking file feature.

It provides tools to monitor the Oracle environment and automate tasks (both one-time and repetitive in nature) to take database administration a step closer to “Lights Out” management. So if you really don’t want to miss something critical please start using RMAN. Considerable improvement has been made in 10g to optimize the algorithm to handle changed block. • Console: This is a graphical interface from where one can schedule jobs. Unix XTerm (oemapp command) or Web browser session (oem_webstage). Observation Introduced in Oracle 8 it has become more powerful and simpler with newer version of Oracle 9 and 10 g. • Intelligent Agent (OIA): The OIA runs on the target database and takes care of the execution of jobs and events scheduled through the Console. Compulsory Media Management only if using tape backup Incremental backups though used to consume less space used to be slower since it used to read the entire database to find the changed blocks and also They have difficult time streaming the tape device. If you changed the location of backup set it is compulsory for you to register it using RMAN or while you are trying to restore backup It resulted in hanging situations There is no method to know whether during recovery database restore is going to fail because of missing archive log file. NOTE: Use command oemctrl instead of oemctl for Oracle 8i and below. The OEM Console connects to the management server to monitor and configure the Oracle enterprise. The console can be opened from a Windows workstation. . The default OEM administrator is “sysman” with a password of “oem_temp”. events. How does one create a repository? For OEM v2 and above. Oracle Enterprise Manager and Management Server What is OEM (Oracle Enterprise Manager)? OEM is a set of systems management tools provided by Oracle Corporation for managing the Oracle environment. start the Oracle Enterprise Manager Configuration Assistant (emca on Unix) to create and configure the management server and repository. Remember to setup a backup for the repository database after creating it. and monitor the database. What are the components of OEM? Oracle Enterprise Manager (OEM) has the following components: • Management Server (OMS): Middle tier server that handles communication with the intelligent agents.. The syntax was a bit complex …RMAN has now become very simple and easy to use.Pitfalls of using RMAN Previous to version Oracle 9i backups were not that easy which means you had to allocate a channel compulsorily to take backup You had to give a run etc . 27 . How does one stop and start the OMS? Use the following command sequence to stop and start the OMS (Oracle Management Server): oemctl start oms oemctl status oms sysman/oem_temp oemctl stop oms sysman/oem_temp Windows NT/2000 users can just stop and start the required services.

run OS commands. Let us call it Dummy_Space. This would trigger the creation of the repository.ora file: (SID_DESC = (GLOBAL_DBNAME = DB_name_for_OEM) (SID_NAME = . Please note that names entered are case sensitive. A size between 200. Dummy_User. Assign DBA. navigate to menu “Navigator/ Discover Nodes”. 3. How does one list one’s databases in the OEM Console? Follow these steps to discover databases and other services from the OEM Console: 1.x (very old!!!) repository on WindowsNT: • Create a tablespace that would hold the repository data.e. Add ‘Log on as a batch job’ under advanced rights in User manager. Start the OEM Console. I. See section “How does one start the Oracle Intelligent Agent?”.jou file (binary) are reported to the console job subsystem. • Monitoring of events registered in Enterprise Manager. SQL*Plus commands etc. Look at these examples: agentctl start blackout agentctl stop blackout agentctl start blackout ORCL agentctl stop blackout ORCL management # Blackout the entrire agent # Resume normal monitoring and management # Blackout database ORCL # Resume normal monitoring and # Blackout jobs for agentctl start blackout -s jobs -d 00:20 20 minutes What is the Oracle Intelligent Agent? The Oracle Intelligent Agent (OIA) is an autonomous process that needs to run on a remote node in the network to make the node OEM manageable. • Fire up Enterprise manager and log in as Dummy_User and enter the password. Lets call this user Dummy_user. Start the Oracle Intelligent Agent on the machine you want to discover. Assign Dummy_Space as the default tablespace. Enterprise manager is ready to accept jobs. It also gives you the flexibility of scheduling custom jobs written with the TCL language.). How does one backout events and jobs during maintenance slots? Managemnet and data collection activity can be suspended by imposing a blackout. The Oracle Intelligent Agent is responsible for: • Discovering targets that can be managed (Database Servers. Note that OEM will not be able to send e-mail and paging notifications when the Console is not started.. etc. • Create an operating system user with the same name as the Oracle username.ORA file (optional). you can close down the OEM console. What kind of jobs can one schedule with OEM? OEM comes with pre-defined jobs like Export. 28 . The OIA maintains a . Import. From now on. Imp_Full_database roles to this user. These names will be listed in the OEM Console. When the console is launched communication with the Agent is established and the contents of the .. and • Executing tasks associated with jobs submitted to Enterprise Manager. Should the OEM Console be displayed at all times (when there are scheduled jobs)? When a job is submitted the agent will confirm the status of the job. The OEM Discovery Wizard will guide you through the process of discovering your databases and other services. A portion of a listener. When the status shows up as scheduled.The following describes means to create a OEM V1. The processing of the job is managed by the OIA (Oracle Intelligent Agent). run sql scripts. Net8 Listeners. SNMPAgent. 2. Ensure the GLOBAL_DBNAME parameter is set for all databases in your LISTENER.jou file in the agent’s subdirectory.250 MB would be ideal. Exp_Full_database. • Create an Oracle user who would own this repository.

Where can one get more information about TCL? One can write custom event checking routines for OEM using the TCL (Tool Command Language) language. enter values similar to these: Event Name: /oracle/script/myalert Object: * Severity: * Message: * One can now write the script and invoke the oemevent command to send alerts to the console.download and learn about TCL • OraTCL at Sourceforge .ora.OCX C:\Orawin95\Bin> RegSvr32 vojt. Check the following sites for more information about TCL: • The Tcl Developer Xchange . Sometimes you get a Failed status for the job that was executed successfully. Select test “Unsolicited Event”. ensure your environment variables are set correctly and delete the following files before trying again: 1) In $ORACLE_HOME/network/admin: snmp_ro.4 is buggy.0. Check with Oracle for any available patches.ver and services.Download the OraTCL package • Tom Poindexter’s Tcl Page . • If you are unable to launch the console or there is a communication problem with the intelligent agent (daemon). SNMP_RW. Solution B: Your version of Intelligent Agent could be buggy. the Intelligent Agent that comes with Oracle 8.ora files ($Oracle_Home/network/admin folder) Start the Oracle Agent service. For OEM 9i and above: agentctl start agent agentctl stop agent For OEM 2. 2) Also delete ALL files in $ORACLE_HOME/network/agent/.OCX 29 . When entering the parameters. start the “OracleAgent” Service. Ensure OCX files are registered.Q Files ($Oracle_home/network/agent folder) Backup and delete SNMP_RO. Select option “Enable Unsolicited Event”.Q files and Delete all the *.How does one start the Oracle Intelligent Agent? One needs to start an OIA (Oracle Intelligent Agent) process on all machines that will to be managed via OEM. It is a bad practice to create the repository with SYS and System.ora.ora.1 and below: lsnrctl dbsnmp_start lsnrctl dbsnmp_status On Windows NT.Oratcl was originally written by Tom Poindexter Are there any troubleshooting tips for OEM? • Create the OEM repository with a user (which will manage the OEM) and store it in a tablespace that does not share any data with other database users. Check the log to see the results of the execution rather than relying on this status. If the agent doesn’t want to start. For example. Look at this example: oemevent /oracle/script/myalert DESTINATION alert “My custom error message” where DESTINATION is the same value as entered in the “Monitored Destinations” field when you’ve registered the event in the OEM Console. Can one write scripts to send alert messages to the console? Start the OEM console and create a new event.ora and snmp_rw. C:\Orawin95\Bin> RegSvr32 mmdx32. dbsnmp. Type the following in the DOS prompt (the current directory should be $ORACLE_HOME\BIN: • If you have a problem starting the Oracle Agent Solution A: Backup the *.

• Oracle Payables: Lets an organization process more invoices with fewer staff members and tighter controls. bank float. • Oracle Inventory: Helps an organization make better inventory decisions by minimizing stock and maximizing cash flow.GL is relatively easy to implement. What is the difference between Fields and FlexFields? A field is a position on a form that one uses to enter. or delete information. consolidation. eliminates paper flow. and increases productivity. There are two types of flexfields: key flexfields and descriptive flexfields.and short-term accounting system issues. planning. you should switch your current GL system first. If you implement Oracle Financials. increases financial controls. Improves cash flow by letting an organization process more payments faster. Each segment has an assigned name and a set of valid values. and reporting of sales information. • Oracle Purchasing: Improves buying power. 30 . helps negotiate bigger discounts. • Oracle Receivables:. what kind of information should be entered in the field. Use the following query to determine if MuliOrg is intalled: select multi_org_flag from fnd_product_groups. without off-line research. • Oracle Revenue Accounting Gives an organization timely and accurate revenue and flexible commissions reporting. and improve collection effectiveness. and financial reporting needs. and prevention of duplicate payment. Helps correctly account for cash. Regardless of the size of the business. allocations. What is the most important module in Oracle Financials? The General Ledger (GL) module is the basis for all other Oracle Financial modules. view. Helps save money through maximum discounts. This keeps each operating unit’s transaction data separate and secure. What is the MultiOrg and what is it used for? MultiOrg or Multiple Organizations Architecture allows multiple operating units and their relationships to be defined within a single installation of Oracle Applications. • Oracle General Ledger: Offers a complete solution to journal entry. update. A field prompt describes each field by telling what kind of information appears in the field.Oracle E-Business Suite (Oracle Applications) What is Oracle Financials? Oracle Financials products provide organizations with solutions to a wide range of long. Oracle Applications uses flexfields to capture information about your organization. budgeting. • Oracle Order Entry: Provides organizations with a sophisticated order entry system for managing customer commitments. All other modules provide information to it. or alternatively. reduce outstanding receivables. • Oracle Sales Analysis: Allows for better forecasting. You should go live with it first to give your implementation team a chance to be familiar with Oracle Financials. A flexfield is an Oracle Applications field made up of segments. • Oracle Personnel: Improves the management of employee. Oracle Financials can meet accounting management demands with: • Oracle Assets: Ensures that an organization’s property and equipment investment is accurate and that the correct asset tax accounting strategies are chosen.related issues by retaining and making available every form of personnel data.

’yyyy-mm-dd hh24:mi:ss’))*24*60. rows_processed.30) table_name. If the import has more 31 .txt contains: BUFFER=100000 FILE=account. For more information on how to load and unload data from files.’INTO “’).v_$sqlarea where sql_text like ‘INSERT %INTO “%’ and command_type = 2 and open_versions > 0. The following examples demonstrate how the imp/exp utilities can be used: exp scott/tiger file=emp.3 or higher (7.txt . round((sysdate-to_date(first_load_time. you can import and export data with the “Schema Manager” GUI that ships with Oracle Enterprise Manager (OEM). read the SQL*Loader FAQ. These parameters can be listed by executing the following commands: “exp help=yes” or “imp help=yes”. One cannot export data and expect to import it into a non-Oracle database. The imp/exp utilities use an Oracle proprietary binary file format and can thus only be used between Oracle databases..dmp tables=(emp..dmp log=emp. Look at this example: exp scott/tiger tables=emp query=\”where deptno=10\” Can one monitor how fast a table is imported? If you need to monitor how fast rows are imported from a running import job. trunc(rows_processed/((sysdate-to_date(first_load_time. or using parameter files.log tables=emp rows=yes indexes=no exp scott/tiger file=emp. Look at the imp/exp parameters before starting.dmp fromuser=scott touser=scott tables=dept exp userid=scott/tiger@orcl parfile=export. For this to work one needs to be on Oracle 7. How does one use the import/export utilities? Look for the “imp” and “exp” executables in your $ORACLE_HOME/bin directory. using command line parameters. try one of the following methods: Method 1: select substr(sql_text. One can run them interactively.Oracle Import/ Export What is import/export and why does one need it? The Oracle export (EXP) and import (IMP) utilities are used to perform logical database backup and recovery.dmp full=yes imp scott/tiger file=emp.2 might also be OK). Can one export a subset of a table? From Oracle8i one can use the QUERY= export parameter to selectively unload a subset of the data from a table. They are also used to move Oracle data from one machine. database or schema to another. • Transporting tablespaces between databases • Etc. where export. Ensure that all the data can be read.’yyyy-mm-dd hh24:mi:ss’))*24*60)) rows_per_min from sys.1) minutes.dmp FULL=n OWNER=scott GRANTS=y COMPRESS=y NOTE: If you do not like command line utilities.instr(sql_text. The export/import utilities are also commonly used to perform the following tasks: • Backup and recovery (small databases only) • Reorganization of data/ Eliminate database fragmentation • Detect database corruption.dept) imp scott/tiger file=emp.

this will create the required tables in the appropriate tablespaces • Import the table(s) with the IGNORE=Y option. Change the default tablespace for the user: • Revoke the “UNLIMITED TABLESPACE” privilege from the user • Revoke the user’s quota from the tablespace from where the object was exported.pipe p # read the pipe .dmp FILESIZE=10m LOG=scott.pipe > scott. they will generate numbers inconsistent with the rest of the database. This example uses gzip. # create a named pipe mknod exp.sql scripts that can be executed as user SYS enabling older imp/exp versions to work (for backwards compatibility). One can alter this behaviour by following one of these procedures: Pre-create the table(s) in the correct tablespace: • Import the dump file using the INDEXFILE= option • Edit the indexfile. Depending on the type of data. This command will tell IMP to display a dot for every N rows imported.pipe . and import it using a later version of the import utility. Oracle also ships some previous catexpX. Contributed by Osvaldo Ancarola. If the sequences are not dropped.. It offers the best compression I know of. Look at this example: exp SCOTT/TIGER FILE=D:\F1. When importing from multi-file export you must provide the same filenames in the same sequence in the FILE= parameter.dmp. Bs. this statement will only show information about the current table being imported.log Use the following technique if you use an Oracle version prior to 8i: Create a compressed export on the fly. • Make the tablespace to which you want to import the default tablespace for the user • Import the table Does one need to drop/ truncate objects before importing? Before one import rows into already populated tables. This is quite an effective way of upgrading a database from one release of Oracle to the next. Remove remarks and specify the correct tablespaces. one can run $ORACLE_HOME/rdbms/admin/catexp7. the export utility supports multiple output files.output to zip file in the background gzip < exp. Indexes can easily be recreated after the data was successfully imported..gz & # feed the pipe exp userid=scott/tiger file=exp. For example. One must always DROP existing Sequences before re-importing. Can one import tables to a different tablespace? Oracle offers no parameter to specify a different tablespace to import data into.than one table. 32 .3 exp/imp utilities to run against an Oracle 8 database. • Run this indexfile against your database.sql on an Oracle 8 database to allow the Oracle 7. If not. This forces the import utility to create tables in the user’s default tablespace. This feature enables large exports to be divided into files whose sizes will not exceed any operating system limits (FILESIZE= parameter). but you can also substitute it with zip. the new data will be appended to the existing tables. This means that one can take an export file created from an old export version. Can one import/export between different versions of Oracle? Different versions of the import utility is upwards compatible. Can one export to multiple files?/ Can one beat the Unix 2 Gig limit? From Oracle8i. Method 2: Use the FEEDBACK=n import parameter. Note: It is also advisable to drop indexes before importing to speed up the import process. Argentina.exp. compress or whatever. you probably can export up to 10 gigabytes to a single file.E:\F2. As. Objects will be re-created in the tablespace they were originally exported from. one needs to truncate or drop these tables to get rid of the old data.

empname. deptno ) The mydata. IMPORT: • Create an indexfile so that you can create indexes AFTER you have imported data.”Scott Tiger”.g.Use the IGNORE=Y import parameter to ignore these errors. Invoke the utility without arguments to get a list of available parameters. • Place the file to be imported on a separate physical disk from the oracle data files • Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) considerably in the init$SID. Do this by setting INDEXFILE to a filename and then import.g. No data will be imported but a file containing index definitions will be created.”Frank Naude”. 500. You must edit this file afterwards and supply the passwords for the schemas on all CONNECT statements.) violated .ctl) will load an external data file containing delimited data: load data infile ‘c:\data\mydata. Look at the following example: sqlldr scott/tiger control=loader.csv’ into table emp fields terminated by “.ora file • Set the LOG_BUFFER to a big value and restart oracle..Create bigger rollback segments or set parameter COMMIT=Y while importing IMP-00015: Statement failed . 40 10002. Its syntax is similar to that of the DB2 Load utility. SQL*Loader supports various load formats.You are importing duplicate rows.) • Create a BIG tablespace with a BIG rollback segment inside. Oracle SQL*Loader What is SQL*Loader and what is it used for? SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. 1000..csv file may look like this: 10001. It will take forever. . DO NOT export to an NFS mounted filesystem. ORA-01555: Snapshot too old . object already exists. but be careful as you might end up with duplicate rows. 20 33 .. but comes with more options. sal. and multi-table loads. The rollback segment must be as big as your biggest table (I think?) • Use COMMIT=N in the import parameter file if you can afford it • Use ANALYZE=N in the import parameter file to avoid time consuming ANALYZE statements • Remember to run the indexfile previously created What are the common Import/ Export problems? ORA-00001: Unique constraint (. 2M) Set the RECORDLENGTH parameter to a high value (e.Ask your users to STOP working while you are exporting or use parameter CONSISTENT=NO ORA-01562: Failed to extend rollback segment . 64K) Stop unnecessary applications to free-up resources for your job. Use IGNORE=NO to skip tables that already exist (imp will give an error if the object is re-created).” optionally enclosed by ‘”’ ( empno. If you run multiple export sessions.. • Stop redo log archiving if it is running (ALTER DATABASE NOARCHIVELOG. Set all other rollback segments offline (except the SYSTEM rollback segment of course). ensure they write to different physical disks.How can one improve Import/ Export performance? EXPORT: • • • • • Set the BUFFER parameter to a high value (e. selective loading..ctl This sample control file (loader.. How does one use the SQL*Loader utility? One can load data into an Oracle database by using the sqlldr (sqlload on some platforms) utility.

utl_file.AAAAAAAAAA 22222. begin fp := utl_file. data2 ) BEGINDATA 11111. and use BEGINDATA to start the data section in the control file. However.”A.C. utl_file_dir=’c:\oradata’ parameter declare fp utl_file. Can one load variable and fix length data records? Yes. In the first we will load delimited data (variable length): LOAD DATA INFILE * INTO TABLE load_delimited_data FIELDS TERMINATED BY “.fclose(fp).’ || col2 || ‘.Another Sample control file with in-line data formatted as fix length records.’tab1.fopen(‘c:\oradata’.putf(fp. 55).ora.txt select col1 || ‘.D. data2 POSITION(6:15) ) BEGINDATA 34 . ‘%s.B. %s\n’.” OPTIONALLY ENCLOSED BY ‘”’ TRAILING NULLCOLS ( data1.” If you need to load positional data (fixed length). look at the following control file examples.’ || col3 from tab1 where col2 = ‘XYZ’. utl_file. load data infile * replace into table departments ( dept position (02:05) char(4). look at the following control file example: LOAD DATA INFILE * INTO TABLE load_positional_data ( data1 POSITION(1:5). end. The trick is to specify “*” as the name of the data file.’w’). you can use SQL*Plus to select and format your data and then spool it to a file: set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on spool oradata. ‘TextField’.txt’. deptname position (08:27) char(20) ) begindata COSC COMPUTER SCIENCE ENGL ENGLISH LITERATURE MATH MATHEMATICS POLY POLITICAL SCIENCE Is there a SQL*Unloader to download data to a flat file? Oracle does not supply any data unload utilities. or ManageIT Fast Unloader from CA to help you unload data from Oracle. spool off Alternatively use the UTL_FILE PL/SQL package: rem Remember to update initSID. TOAD from Quest.file_type. / You might also want to investigate third party tools like SQLWays from Ispirer Systems.

time_loaded “to_char(SYSDATE. Note that this only applies for the conventional load path and not for direct path loads. deptno POSITION(17:18) CHAR. mailing_addr “decode(:mailing_addr. LOAD DATA INFILE * INTO TABLE modified_data ( rec_no “my_db_sequence. :addr. ‘YYMMDD’)” ) BEGINDATA 11111AAAAAAAAAA991201 22222BBBBBBBBBB990112 LOAD DATA INFILE ‘mail_orders. mailing_city “decode(:mailing_city. city. mailing_state ) Can one load data into multiple tables at once? Look at the following control file: LOAD DATA INFILE * REPLACE INTO TABLE emp WHEN empno != ‘ ‘ ( empno POSITION(1:4) INTEGER EXTERNAL. data2 POSITION(6:15) ) BEGINDATA 11111AAAAAAAAAA 22222BBBBBBBBBB Can one modify data as it loads into the database? Data can be modified as it loads into the Oracle Database. null. null. mgr POSITION(20:23) INTEGER EXTERNAL ) INTO TABLE proj 35 . data1 POSITION(1:5) “:data1/100”.nextval”. :mailing_addr)”. :mailing_city)”. where n = number of logical rows to skip. data2 POSITION(6:15) “upper(:data2)”.txt’ BADFILE ‘bad_orders. zipcode. Look at this example: LOAD DATA INFILE * INTO TABLE load_positional_data SKIP 5 ( data1 POSITION(1:5). ename POSITION(6:15) CHAR. region CONSTANT ‘31’. data3 POSITION(16:22)”to_date(:data3. ‘HH24:MI’)”.” ( addr. :city. state.11111AAAAAAAAAA 22222BBBBBBBBBB Can one skip header records load while loading? Use the “SKIP n” keyword.txt’ APPEND INTO TABLE mailing_list FIELDS TERMINATED BY “.

there are no positional fields—the next field begins after some delimiter. This option can only be used with direct data loads. field2 FILLER.One cannot use POSTION(x:y) as it is stream data. • CONTINUEIF . (01) is the first character. field3 ) How does one load multi-line records? One can create one logical record from multiple physical records using one of the following two clauses: • CONCATENATE: . by having a ‘#’ character in column 1. Make sure you have big rollback segments ready when you use a high value for ROWS=. but by setting the ROWS= parameter to a large value.use if a condition indicates that multiple records should be treated as one. How does one use SQL*Loader to load images. there are cases when you can’t use direct load. SDF (Secondary Data file .dat’ BADFILE ‘mydata. Run multiple load jobs concurrently. service_key POSITION(01:11) INTEGER EXTERNAL. ignoring fields that one does not want.use when SQL*Loader should combine the same number of physical records together to form one logical record.for loading nested tables and VARRAYs) or LOGFILE. How can get SQL*Loader to COMMIT only at the end of the load file? One cannot. Look at this example: -. This will significantly slow down load times even with ROWS= set to a high value. Add the following option in the command line: DIRECT=TRUE.WHEN projno != ‘ ‘ ( projno POSITION(25:27) INTEGER EXTERNAL. Look at this example: 36 . call_b_no POSITION(12:29) CHAR ) Can one skip certain columns while loading data? One cannot use POSTION(x:y) with delimited data.’ ( field1. The LOBFILE method provides and easy way to load documents. This will effectively bypass most of the RDBMS processing. Turn off database logging by specifying the UNRECOVERABLE option. committing can be reduced. Eg. Luckily. --> LOAD DATA TRUNCATE INTO TABLE T1 FIELDS TERMINATED BY ‘. not in column X. Can one improve the performance of SQL*Loader? A very simple but easily overlooked hint is not to have any indexes and/or constraints (primary key) on your load tables during the load process. FILLER columns are used to skip columns/fields in the load file. sound clips and documents? SQL*Loader can load data from a “primary data file”. (30:37) are characters 30 to 37: LOAD DATA INFILE ‘mydata. empno POSITION(1:4) INTEGER EXTERNAL ) Can one selectively load only the records that one need? Look at this example. However.bad’ DISCARDFILE ‘mydata. images and audio clips into BLOB and CLOB columns. Refer to chapter 8 on Oracle server Utilities manual.dis’ APPEND INTO TABLE my_selective_table WHEN (01) <> ‘H’ and (01) <> ‘T’ and (30:37) = ‘19991217’ ( region CONSTANT ‘31’. from Oracle 8i one can specify FILLER columns.

Control File: LOAD DATA INFILE * INTO TABLE image_table REPLACE FIELDS TERMINATED BY ‘. Therefore. and they wanted it fixed immediately. image_data BLOB). and to do it properly. and loads directly into the Oracle data files. But it’s a more ‘lonely’ job than being a Development DBA. After I while I got to be able to do this without becoming fully awake so I could to go back to bed and back to sleep again. and has simply to keep things up and running. so it is a very difficult and demanding job.jpg What is the difference between the conventional and direct path loader? The conventional path loader essentially loads the data by using standard INSERT statements. He or she. often gets involved when all the design decisions have been made.P.00 in the morning. There are Development DBAs and Production DBAs. Of course. you need to like technical responsibility. giving advice on performance and writing good SQL. That can be satisfying at a human level because you are part of a team and you share the satisfaction of the team’s accomplishments. I have many years experience of working as a Production DBA. I knew that if the phone rang. The direct path loader (DIRECT=TRUE) bypasses much of the logic involved with that. it’s easy to find out whether you would be a good DBA.’ ( image_id INTEGER(5).Morgan and Salomon Smith Barney. of course. Oddly enough. it is also a rewarding job. it meant they had a problem. such as J.Given the following table: CREATE TABLE image_table ( image_id NUMBER(5).image2. or to say that everything was OK. image_data LOBFILE (file_name) TERMINATED BY EOF ) BEGINDATA 001. A Production DBA (on the other hand) is responsible for maintaining Databases within an organisation. switch on my PC. More information about the restrictions of direct path loading can be obtained from the Utilities Users Guide. If they called. What is a DBA? A DBA is a Database Administrator. and get paid for it !!! To enjoy being a DBA. both financially and in terms of job satisfaction. sometimes the phone would ring at home when I was in bed at 3.gif 002. These are the Steps you follow :- 37 . maintaining live Databases in Investment Banks. and they did not care what else you were doing. You need to enjoy the feeling that ‘this is my territory’ and to take sole responsibility for a technically demanding role.image1. file_name VARCHAR2(30). Those were some of the most demanding and high-pressure years in my professionalcareer. so I would have to get up. and this is the most common job that you find a database specialist doing. A Development DBA usually works closely with a team of developers and gets more involved in design decisions. nobody was calling to ask about my health. This usually meant bringing the Database Servers down and then up again. login remotely and fix the problem. file_name CHAR(30).

please let us know.Buy a book. then if you really wanted to. One option is to sign up as an Oracle Partner. Check out the Oracle 9i Partner Accelerator Kit for an overview. Oracle has recently introduced a qualification of Internet Database Operator.(see elsewhere on this Site). although there will be plenty of Oracle 8i installations for a long time to come. or Oracle 8i on NT in 24 hours). If you find it boring then give it up. VENDORS: Microsoft SQL Server is easier to get started with. Surprisingly enough. Being a DBA in a development environment is much less stressful. then it’s certainly going to be difficult.see below) because of the demand. because everything is Windows-driven. which gives you 5 days free training and then use. but (like a degree . There is a great demand. It doesn’t pay so well. because it is geared towards the Command Line. because being a DBA doesn’t take so much time. going through your chosen ‘Step-by-Step’ book. but you might be able to get an interesting role combining DBA with Development work. creating Data Sets and sample data. but I’ve also been told that it is very difficult. Start doing DBA tasks. Can you get a job as an Oracle DBA with Certification but no experience ? If you get certified as an Oracle DBA but don’t have any experience. it can be difficult to find a job. but they will definitely help to prove commitment and competence if you are trying to change careers. and see how Oracle expects you to 38 . get started as a DBA by doing daily tasks on your Database at home. it’s easy to find work . I’ve also met many people who have obtained Microsoft Certification but then never use it. If you buy a book with an evaluation copy of a DBMS then the next Step is made a whole lot easier. IBM’s DB2 is somewhere in between. I have heard about people who have been able to do it. Neither Certification nor Degrees are necessary if you know your stuff. It is very difficult to get a job as a Production DBA without hands-on experience. DB2 or SQL Server on a PC using NT. It is easier to find a job as a Development DBA. but it pays better. and I’ve heard that many of the questions asked in the Certification exams are not the kind of questions. It obviously helps if you have a background as an Oracle developer. Certification will help you get a job. There is a very useful set of Oracle 8i Documentation available online (Courtesy Ars Digita and Philip Greenspun) which will help you learn a lot about how Oracle works. I think Microsoft Certification process is just another example of how Microsoft tries to increase their revenue stream. which is the kind of thing. then give it up. 9i is moving much closer to point-and-click and away from command-line administration. which come up as part of the job. Oracle has a steeper learning curve. Else. Certification is not always mandatory if you have experience as a DBA. This qualification will look good on your CV but it will not help you get a job because it only teaches you how to install Oracle Products and get them to work.either a permanent job or a contract. which developers often ask for. which offers the cheapest path to Certification. you could move into a slot as a Production DBA. you should offer experience in PL/SQL. and prepare for an interview. and it’s hard to find openings for Junior DBAs. It also teaches you some basics about SQL in Oracle. which have copies of all three Oracle. If you don’t like the prospect of always being at the end of a phone ‘Help Line’. Get Oracle. advising developers on writing efficient SQL. Hint: Look for a book called SQL Reference. IBM’s DB2 and Microsoft’s SQL Server on the CD-ROM that comes with the book. (except for TOAD). and if you have no other Oracle experience. the training to get Certification as an Internet Database Operator. by Groff and Weinberg. (such as SAMS Teach Yourself DB2 in 21 days. Personally. To do this.(although that’s a valuable skill but it is not enough on its own). So if you have any experiences that you would like to share and help other people trying to plan what to do. at a relatively modest (for Oracle Education) cost of one 4-day Course and a Certification Examination. The announcement of Oracle 9i means that the water has just become muddier because it means that a great deal of the current lengthy training may be unnecessary. which is likely to remain so for the next few years. and is a natural progression as you begin to experience ‘burn-out’ in a production environment.

This writes completed Transactions onto a Journal or History File and deletes them from the Log File. All of these new features mean that Oracle is moving towards to a point-and-click approach for many common DBA tasks. It is possible to have many Database Server processes running simultaneously. In other words. that’s not always necessary. look at Oracle’s new Wizard for creating a Database for Data Warehousing. and is primarily intended for developers who work close to the Database. all the data 39 . What are the major Components in an RDBMS ? ANSWER : This describes the three major Components which make up the run-time processes. associated experience is essential. Working on a systems migration project. so that I could provide high-priority. Oracle . This means that many ‘Command Line’ skills being taught will become obsolete in the future. with good Unix Shell Scripting skills. which is Oracle’s Procedural Language. 8 & v8i environment. Working with PL/SQL often includes some DBA work. Working within an Oracle 7. it’s always good to have at least a Bachelor’s degree.and lower-priority for background batch jobs. It is therefore much more of a development job and offers design challenges and is more creative than 100% DBA work.as is solid commercial experience with PL/SQL.England and Germany running on the same UNIX box.a very attractive Career Option involves PL/SQL. you will have proven technical ability and excellent interpersonal skills. so I created some UNIX daemons which ran all the time and would notify me automatically if the Archive process was not running. The Recovery Process handles the situations where is there is a Database crash and it recovers to the last known point at which the Database was running OK and had ‘integrity’. As for Qualifications. and produces a Query Execution Plan. create database load scripts and set-up development databases is essential. 2) An Archive Process. I also worked as a DBA at J. decides how to execute it. 1) The Database Server. This takes the SQL.high-CPU percentage. I used to work as a DBA for Salomon. This is an embarrassing process. but because of the demand. you need to keep up-to-date with new versions of your chosen RDBMS(s). no more transactions can start. This is done to avoid the Log File getting filled up because then everything fails and the Servers have to be brought down to recover. Beware. and then you’ll be on the road again.high-memory allocation for the very demanding real-time applications. with each one tailored to a particular kind of “SQL Query”.P. The worst part is that as the DBA. This was in the situation where the normal messages from starting up the Database Server would not make it clear whether the Archive process had started correctly. everybody’s program hangs and the phone rings off the hook. PL/SQL includes and extends SQL. Smith Barney. It also allowed me to handle each database independently. 3) A Recovery Process. but don’t deliver. Here’s a typical Help Wanted Ad to give you a feeling for the skills required ”PL/SQL Developer With DBA Skills” Multinational Multimedia organisation requires an experienced PL/SQL Developer who also has had DBA exposure. The position will demand some DBA support (approximately 20% of the role) however the support will be of a wholly ad-hoc nature. one for each location. Subsequently.another Career Option As well as DBA work. An ability to be able to write PL/SQL packages & procedures. Smith Barney supporting databases for Florida. that if you talk a good interview. I always had three Servers running.Morgan where the user were just as demanding as Salomon. rather than close to the User. you often do not know that the Archive process is not running until the Log File fills up. you will get found out very quickly. with a sub-Component called the Query Optimiser. in data extraction and migration from a Database. This will make the work of an Oracle DBA work much more like it is for IBM’s DB2 and Microsft SQL Server. for example.administer a Database using Oracle Enterprise Manager. and bring down the server for England without affecting the Servers and the Databases for Florida and Germany. Then finally.

Namely by values in column positions within rows of tables. and rollback). 9. the name of the containing column and the Primary key value of the containing row. with no open Transactions. and independent of data type. and © supports data definition operations (including view definitions). (b) Can be used both interactively and within application programs. data manipulation operations (update as well as retrieval). The guaranteed access rule This rule is essentially a restatement of the fundamental requirement for primary keys. 6. The nonsubversion rule 40 . Ted Codd and his Rules for Relational Databases THE RULES: 0. distinct from all regular values (for example. The view-updating rule All views that are theoretically up datable must be updatable by the system. 2. (Yes. 4. MANAGEMENT system. and transaction management operations (begin. update. It says that every individual scalar value in the database must be logically addressable by specifying the mane of the containing table.” in the case of numeric values). (b) When existing distributed data is redistributed around the system. security and integrity constraints. Integrity independence Integrity constraints must be specified separately from application programs and stored in the catalog. 3. Distribution independence Existing applications should continue to operate successfully (a) When a distributed version of the DBMS is first introduced. that system must use its RELATIONAL facilities (exclusively) to MANAGE the DATABASE. Physical data independence Self-explanatory. 7. inline. relational catalog that is accessible to authorized users by means of their regular query language. commit. It is also implied that such representations must be manipulated by the DBMS in a systematic way. Active online catalog based on the relational model The system is required to support an online. It must be possible to change such constraints as and when appropriate without unnecessarily affecting existing applications. and DELETE operators. and delete The system must support set-at-a-time INSERT. The comprehensive data sub language rule The system must support a least one relational language that (a) Has a linear syntax. UPDATE. there is a Rule 0!) For a system to qualify as a RELATIONAL. The information rule The information rule simply requires all information in the database to be represented in one and only one way. Logical data independence Self-explanatory 10. 8. High-level insert. 12. “distinct from zero or any other number. 1. 5. 11. Systematic treatment of null values The DBMS is required to support a representation of “missing information and inapplicable Information” that is systematic. DATABASE.representing a consistent set of related records had been written to the Database at the end of a committed Transaction.

An excellent book covering this very new area is “The Data Webhouse” by Ralph Kimball. What is Data Warehousing? Data Warehousing is concerned with the activities involved with creating a DataRepository where you store all the facts you know about some large enterprise or activity. Whereas the common use of databases is to store details of ‘transactions’ such as Bank account details. The explanation seemed to be that men would call in to buy beer for the weekend and the wives would say “While you are in the supermarket. A major growth area for DW at present is the storage and analysis of ‘clickstream data’ of traffic on Internet Web Sites.If the system provides a low-level (record-at-a-time) interface.for example. As a result of this analysis they started putting diapers/nappies next to the beer and increased the sales of both items. trying to identify patterns in buying behaviour so they can sell more stuff to the poor unsuspecting customer.) bypassing a relational security or integrity constraint. and the term was first used by Dr. OLAP requirements are not very well met by SQL so extensions have been developed by the vendors of OLAP products. The beer and nappies example is a case of OLAP in practice.for example. Then DW involves analyzing Facts by different combinations of Diumensions. and then analyse the data in different ways. and vice versa. How do I set a database in archivelog or noarchivelog? 1) shutdown the database sql> shutdown 2) startup the database in mount state sql> startup mount 3) set the database in archivelog or noarchivelog sql> alter database archivelog | noarchivelog 4) open the database sql> alter database open 5) Take a full backup What are the different ways to stop an Oracle instance? There are 4 ways to shutdown an Oracle Instance. product and product category.then they find the answer to both of these is Friday evening -and hey presto they can make more money by making it easier for the beer-buyers to buy nappies (and please the wife). of IBM Research. For example.g. What it means is that you are online analyzing masses of data. date and time of purchase. From this example. “When do we sell most beer? “And “When do we sell most nappies” . Typically this is done by large retail organisations. This is typically used to identify hits and page impressions to determine how many people will see a particular banner advertisement on the Web Site. 2) Dimensions . like Brio or Cognos. 1) Normal 2) Transactional 3) Immediate 4) Abort 1) Normal During “normal” shutdown no new connections are allowed and the server will wait for all users 41 . you can see that most DW examples and work are pretty boring.please pick up some diapers/nappies for the baby”. 3) OLAP: OLAP stands for ‘On-Line Analytical Processing. then that interface cannot be used to subvert the system (e.to look for patterns on the data. The most commonly quoted example is that somewhere in the States they discovered that on Friday nights the sales of beer and diapers/nappies went up.Ted Codd. TERMS IN COMMON USE in DW is: Facts . who was the father of the relational database and SQL. sales in a shop for the beer and nappies example.

2. So after disconnecting the clients and rolling back any active transactions Oracle will shut down the Instance. It opens the database and any data that is not locked by unrecovered transactions is available to the users It rolls back uncommitted transactions (rolled back by SMON or by the server process as they access the locked data) 2) Combining or coalesces free space in the data files 3) Deallocates temporary segments to return them as free space in the data files. 4) Abort During abort” shutdown no new connections are allowed. oracle:/home/oracle APPS> $ opatch lsinventory Invoking OPatch 10. then the variousbackground processes are terminated and the allocated memory for the SGAare de-allocated. Why is a checkpoint initiated? A checkpoint is initiated to ensure that modified data in memory are written to the datafiles on regular basis. Check patches applied to db There are several ways to identify whether a patch applied to database.to disconnect before shutting down. (Only from that (check)point redo log entries need to be processed). Restart dead dispatchers after a failed process. All rights reserved. so no data is lost during a crash or failure.0. A checkpoint is also initiated to reduce the time needed to do instance recovery.2. The redo buffers and database buffer are written to the datafiles.4. A checkpoint is initiated to ensure that all committed data has been written to the data files when shutting down. Oracle Corporation. Added by Deepak – 1. Freeing up other resources reserved by the user after a failed process. 2) Transactional During “transactional” shutdown no new connections are allowed and the server will disconnect users as soon as they complete their current transaction. What are the responsibilities of the system monitor (SMON)? The system monitor is responsible for: 1) Instance Recovery It rolls forward any data that has been recorded in the online redo log files but not to the data files. 42 . Note that before invoking opatch you have to set or export ORACLE_HOME and then change the directory to opatch. Few of them – 1)By invoking $ opatch lsinventory.0.3 Oracle Interim Patch Installer version 10. Instance recovery will be needed on the next startup.3 Copyright (c) 2007. Finally Oracle will close and dismount the database. Releasing all currently held table and row locks after a failed process. uncommitted transactions will not be rolled back redo and database buffers are “not” written to disk and the database is not closed or dismounted. What does the Process monitor (PMON) do? The process monitor is responsible for: Rolling back the current user’s transaction after a failed process. 3) Immediate During “immediate” shutdown no new connections are allowed.4. The server will not wait for clients to disconnect nor for transactions to complete and will do a rollback if needed. After that Oracle will immediately shut down the Instance. The server will not wait for connected users to disconnect.

0.0 Oracle Database 10g Release 2 Patch Set 3 10.2.2.4. ----------------------------------------------------------------------------OPatch succeeded.0.0 There are 2 products installed in this Oracle Home.0 Oracle Database 10g Release 2 Patch Set 3 10.4.2.0.0 OUI location : /APPS/app/oracle/product/10.0/db/oui Log file location : /APPS/app/oracle/product/10.2.4.4.3 Copyright (c) 2007.2.2. Oracle Corporation. Installed Products (160): 10.2.1.2.2.0.0/db/cfgtoollogs/opatch/opatch2010-01-07_00-2617AM.Oracle Home : /APPS/app/oracle/product/10.2.2.4.0.4. There are no Interim patches installed in this Oracle Home.loc OPatch version : 10.0/db/cfgtoollogs/opatch/lsinv/lsinventory201001-07_00-26-17AM.3 OUI version : 10.2.3 OUI version : 10.4.0/db/cfgtoollogs/opatch/opatch2010-01-07_00-1928AM.0 43 .0/db/cfgtoollogs/opatch/lsinv/lsinventory20100107_00-19-28AM. 2)By invoking $ opatch lsinventory -details oracle:/APPS/app/oracle/product/10. All rights reserved.log Lsinventory Output file location : /APPS/app/oracle/product/10.0.2.0.log Lsinventory Output file location : /APPS/app/oracle/product/10.loc OPatch version : 10.0/db Central Inventory : /APPS/app/oracle/oraInventory from : /var/opt/oracle/oraInst.2.2.2.2.0.0/db/OPatch AHDP> $ opatch lsinventory -details Invoking OPatch 10.2.0/db/oui Log file location : /APPS/app/oracle/product/10.4.2.0.0.1.txt ----------------------------------------------------------------------------Installed Top-level Products (2): Oracle Database 10g 10.0 OUI location : /APPS/app/oracle/product/10.3 Oracle Interim Patch Installer version 10.0. Oracle Home : /APPS/app/oracle/product/10.0 There are 2 products installed in this Oracle Home.2.0/db Central Inventory : /APPS/app/oracle/oraInventory from : /var/opt/oracle/oraInst.txt Installed Top-level Products (2): Oracle Database 10g 10.4.0.0 SQLJ Runtime Patch 10.1.2.

2.0.42.0 6864068 CPUApr2008 05-AUG-09 07.1.0 Sun JDK extensions 9.4.1.3.22.4.-----------------------------30-JUL-08 05.0.2.0 XML Parser for Oracle JVM 10.41.0 XML Parser for Oracle JVM Patch 10.0.0 XDK Required Support Files 10. rebuild the index needs twice the space the original index Test 1: create table lock conn scott / tiger select sid.0 Sun JDK 1.4.2.2.43. SQL> select * from sys.SSL Required Support Files for InstantClient 10.2.1. ----------------------------------------------------------------------------OPatch succeeded. create index test_index on test (name).290171 PM CPU 6452863 view recompilation 08-SEP-08 08.18.4.2.1. rebuild process can still take the old users to query the index.0.registry$history. username from v $ session.3.110066 PM CPU SERVER 10.0 Upgraded from 10.4.0.59.0. 3)Login to oracle as sys user and invoke select * from sys.0.0 XDK Required Support Files Patch 10. There are no Interim patches installed in this Oracle Home.0.0.0.2.2.registry$history.08.0 05-AUG-09 07.0.2.0.0 XML Parser for Java 10.0.158451 AM UPGRADE SERVER 10.040347 AM CPU 6452863 view recompilation 4)Various OS Commands.0 XML Parser for Java Patch 10.2.4.2. so that you can not lock the table. ACTION_TIME ACTION NAMESPACE ------------------------------.2. ensure that the original form of the dml operations in the process can be run properly.13. $ showrev -p $ owhat bin/oracle Create Index and Rebuilt Index create index and rebuild index on the original table will be added when the 4 locks on obj$ plus 3 locks to prevent DML operations on the original table create index online and rebuild index online using a temporary table to deal with new or to re-create the original table when the index changes the index column.4.-----------------------------VERSION ID COMMENTS BUNDLE_SERIES -----------------------------------. index.0 SSL Required Support Files for InstantClient Patch 10. 44 .03.0 There are 160 products installed in this Oracle Home.

OBJECT_ID = L. OBJECT_ID = L. LMODE FROM V $ LOCK L. / * Mon Lock equivalent * / 1. SQL> commit. 'Share'. / * S * / 5. DBA_OBJECTS O WHERE O. OBJECT_NAME LMODE -----------------------------.ID1 AND L.SID USERNAME ------. / * N * / 2. / * R * / 4. SQL> create table test_rebuild as select * from dba_objects. First create a large table.---------OBJ $ 3 TEST 4 Test 2: rebuild online lock alter index test_index rebuild online. 6398 rows created.---------SYS_JOURNAL_10499 4 TEST 2 Attached to the lock type 0. SQL> insert into test_rebuild select * from test_rebuild. 'Row-S (SS)'.ID1 AND L. Insertion of non-stop data SQL> / 409472 rows created. SELECT OBJECT_NAME. LMODE FROM V $ LOCK L.------------139 143 SCOTT SQL> SELECT OBJECT_NAME. 'Row-X (SX)'. OBJECT_NAME LMODE -----------------------------. SQL> desc test_rebuild Name Null? Type 45 . 'Exclusive'. DBA_OBJECTS O WHERE O. 'None'. 'Null'. TYPE = 'TM' AND SID = 143. / * X * / Test 3: In the online renewal process. / * C * / 6. / * L * / 3. to ensure there is sufficient time to observe the details of the index rebuild process. Commit complete. the database is to record. TYPE = 'TM' AND SID = 143. 'S / Row-X (SSX)'. Table created.

Index created. Modifications to the non-indexed column SYS_JOURNAL_xxxx no records. ROWID OBJECT_NAME -----------------. 1 row updated. the temporary creation table records the two movements.----------------------------------------.test_rebuild where rownum <2. Added: If the building is the combination of the index create index idx_rebuild on test_rebuild (object_name.-------------------------------. while recording changes rowid. status) online 46 . 15:13:30 session2> select rowid. the representative I insert a new value.test_rebuild set object_name = 'new' where rownum <2.SYS_JOURNAL_6668. C0 OPTODE PARTNO RID -------------------------------------------------.-------..----old D 0 AAAAABAAFAAAAI0AAA new I 0 AAAAABAAFAAAAI0AAA When session1 Report Index altered. Commit complete. object_id from user_objects get such example update operation. Then the three began to highlight open session 15:13:09 session1> alter index idx_rebuild rebuild online. object_name from scott. xxxx that index object_id.-------------------OWNER VARCHAR2 (30) OBJECT_NAME VARCHAR2 (128) SUBOBJECT_NAME VARCHAR2 (30) OBJECT_ID NUMBER DATA_OBJECT_ID NUMBER OBJECT_TYPE VARCHAR2 (18) CREATED DATE LAST_DDL_TIME DATE TIMESTAMP VARCHAR2 (19) STATUS VARCHAR2 (7) TEMPORARY VARCHAR2 (1) GENERATED VARCHAR2 (1) SECONDARY VARCHAR2 (1) SQL> create index idx_rebuild on test_rebuild (object_name).SYS_JOURNAL_6668.---------------------------AAABoLAAFAAAAI0AAA old 15:13:41 session2> update scott. 15:13:57 session3> select * from scott. 15:13:54 SQL> commit. will prompt table does not exist Oracle can be seen in the changes to the index out of the process will modify the value to write to create a temporary table SYS_JOURNAL_xxxx. can query select index_name. a representative of the old value of D to delete. And then query select * from scott.

a channel will correspond to a service process. the need to consider the I / O device of the type. I / O parallel processing capacity. pfile. the maximum number of open files and so on. The target database RMAN backup and recovery is a database. password file other than data files. I/O communication between devices. you can use control file instead of recovery catalog. etc.SYS_JOURNAL_6668. Backup. RMAN will create a complete backup.. oracle 9i as the functions of automatic backup control file. is not recommended to create the target database. The query select * from scott. 7. spfile. If you want RMAN backups directly to tape. You don't have to give the FILENAME Backup controlfile copy <filename> creates a BACKUPSET from a copy of controlfile. backup sets and backup time when the issue of backup command. the backup storage for more information. 6. including one to the multiple backup sets. The physical file corresponding to the backup piece.---------. RMAN can back up in addition to the online log. you can store the backup script. RMAN tool is RMAN commands. backup set is a logical structure.. in the distribution channel. media management tools such as backup software can call the RMAN to back up and recovery. backup and recovery process for all the work in the following circumstances will result in a service process when connecting to the target database is assigned a new channel 3. You have to give the FILENAME. the largest database file read rate. 4. RMAN architecture as follows: 1. C0 C1 O PARTNO RID -----------------------------. originated in the Oracle version 8. using recovery catalog can also manage multiple target databases.. using a large extent can be replaced to restore control file directory. generally in the $ORACLE_HOME /bin directory. it will create the temporary table has two columns C at the beginning RMAN Backup current controlfile creates a BACKUPSET containing controlfile. the service process RMAN service process is a background process. media management Media Management Layer (MML) is a third-party tools or software for the management of the tape read and write and document tracking management. control files. If you do not use recovery catalog.------. you must configure the media management. I / O devices to create the file size. contains a set of physical files. 5.---------------new invalid I 0 BAEAAAAAFAAAAI0AAA old invalid D 0 BAEAAAAAFAAAAI0AAA Combination of the two columns built an index. services. channel-channel is a service process and I / O devices read and write channels. 2. you can run the rman this command to start the RMAN tool for backup and restore interface. Backup 47 . with the RMAN tool for communication between the database and also for the RMAN tool and disk / tape. archived log. Recovery catalog to store information on backup and restore a database.

such as [Oracle @ db oracle] $ $ ORACLE_HOME / bin / rman Recovery Manager: Release 9. can produce a disk or tape.0. 2002.rman) Run stored in the recovery catalog script RMAN> RUN (EXECUTE SCRIPT backup_whole_db). The process requires more process and memory needs of a large pool allocation 2. SHELL script. pay attention to set the correct environment variables in the script [Oracle @ db worksh] $ more rmanback. ) 3. control files. start and run RMAN 2. 2. if executed in cron. do not use the recovery catalog.2 export ORACLE_SID = test 48 . Backup sets and backup the following provisions: A data file can not span a backup set. Oracle Corporation.3 how to run RMAN commands like 1. you can target database that contains the data files. run a command block RMAN> run ( copy datafile 10 to '/ oracle/prod/backup/prod_10. if you use a recovery catalog. version requirements RMAN tool version and the target database must be the same version. if local. data files. you can use the following similar command RMAN> Connect target / 2.rman RMAN> @ backup_db.2 Basic operation method 9i default nocatalog. run the script $ Rman TARGET / @ backup_db. NLS_LANG. the remote requires authentication using the password file. can use OS authentication.dbf'. RMAN> Connect the target database. ORACLE_HOME. enter the command rman RMAN command line interface. Second. All rights reserved. 4. a single execution RMAN> backup database.2. The permissions need SYSDBA system privileges required. 4. but can span the backup piece. need another set NLS_DATE_FORMAT 3.0 .4.sh #! / Bin / ksh # Set env export ORACLE_HOME = / opt/oracle/product/9.rman RMAN> RUN (@ backup_db. also need attention: * Create a RMAN recovery catalog script version must be equal to or greater than the version to restore directory where the database creates RMAN recovery catalog script version must be equal to or greater than the target database version 2.piece is the most basic physical structure. if used in a time-based backup and recovery. PATH. but can not be stored in the same archive log backup set.Production Copyright (c) 1995.1 Operation requirements 1. the basic needs of the environment variable ORACLE_SID. control files can be saved in the same backup sets. archived log files and spfile.

RMAN default configuration parameters can be seen through the show all come out. CONFIGURE RETENTION POLICY TO NONE. RMAN> show all. CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/ U01/app/oracle/product/9. backup strategies. so. 3. a redundancy strategy.f'. Clear will maintain the strategy to restore the default.export NLS_LANG = "AMERICAN_AMERICA.0. CONFIGURE DEVICE TYPE DISK PARALLELISM 1.2/dbs/snapcf_U02. Run ( 49 . CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1. CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 5 DAYS. RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1. RMAN's automatic configuration Oracle 9i can configure the number of parameters such as channel. CONFIGURE CONTROLFILE AUTOBACKUP OFF.bak' filesperset = 2. and set the information in the script does not affect the re-set. will replace the default channel allocation.-------------". 3. one strategy is time to decide at least one backup to restore to the specified date. you can run block.1 maintain a backup strategy to keep two strategies.end ----------------. CONFIGURE DEFAULT DEVICE TYPE TO DISK. if the excess over the three backups will be marked as redundant backup. CONFIGURE BACKUP OPTIMIZATION OFF. through a set can be repeatedly used.2-channel configuration and automatic channel allocation configuration through the CONFIGURE automatic distribution channel.-----------". date 3. CONFIGURE MAXSETSIZE TO UNLIMITED. but also through a different channel number to specify the distribution. The second strategy described at least three redundant backup exist. exit. manually specify the channel distribution. CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1. provides at least a few redundant backup.start -----------------. NONE can maintain a strategy of failure to make a backup. the backup will be marked prior to Obsolete. date # Backup start $ ORACLE_HOME / bin / rman <<EOF connect target delete noprompt obsolete. In the first strategy is to ensure that at least one backup can be restored to Sysdate-5 time point.zhs16gbk" export PATH = $ PATH: $ ORACLE_HOME / bin echo "----------------------------. backup database format '/ netappdata1/rmanback/tbdb2 /% U_% s. CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR TYPE DISK TO '% F'. CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/ U01/ORACLE/BACKUP /% U' CONFIGURE CHANNEL n DEVICE TYPE DISK FORMAT '/ U01/ORACLE/BACKUP /% U' Of course. CONFIGURE RETENTION POLICY TO REDUNDANCY 5. maintain the information. EOF echo "-----------------------------.

. will use the default channel configuration. 3. maxpiecesize = integer The maximum number of concurrent open files (default 16) Allocate channel . the parallel degree of 4. If you specify a channel configuration. Determine the number of parallel open channel number. the snapshots can be configured as follows CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/ U01/app/oracle/product/9. Specified in subsequent backup and recovery. Note that if for an IO device. you can also specify a default in the configuration of parallel level. used to control the read consistency of the file. maxopenfile = integer 3. . but this set is in standby database failure. this feature is particularly effective. you can configure in the channel configuration or the backup location specified in multiple copies CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/ u01/backup /% U'. or after any change in the database's structure... The configuration can be specified as the backup control file path and format CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR TYPE DISK TO '% F'. if that does not worry. CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 2. you can set the automatic backup control file CONFIGURE CONTROLFILE AUTOBACKUP ON. you can set up multiple copies of backup sets. '/ u02/backup /% U'.7 Optimizing the backup set in the configuration backup can be optimized.. . CONFIGURE DEFAULT DEVICE TYPE TO SBT.. can also run the operation block in the specified channel to determine the degree of parallel backup and restore. 3.bak' . such as RMAN> CONFIGURE DEVICE TYPE SBT PARALLELISM 2. in case of default is the disk. ) Here are some characteristics of read channel rate limiting Allocate channel . will use the specified channel. if the channel is not specified.5 Configure the default IO device type IO device type can be a disk or tape. . As CONFIGURE DEVICE TYPE DISK PARALLELISM 4.0. CONFIGURE DEFAULT DEVICE TYPE TO DISK.. the corresponding configuration changes also needs to be done.allocate channel cq type disk format = '/ u01/backup /% u.. . During the backup.6 Configuring the number of multiple backup copies of a single backup set. such as 50 .. such as CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 2.. If you specify more than one copy.. By the following command. you can configure the automatic backup control file. 3. rate = integer The maximum size limit backup piece Allocate channel . automated backup control file backup or copy Zairen He happened the Order of. will produce a snapshot control file.4 Parallel backup set RMAN supports parallel backup and restore.. '/ u02/backup /% U'..2/dbs/snapcf_U02.3 Automatic backup control file starting from 9i. 3. of course.. Did not resume the directory for the backup strategy is.. 4 channels simultaneously open the backup and recovery..f'. the following command can be re-configured.. RMAN> backup datafile n format '/ u01/backup /% U'.

dbf'. sequence number and time RESETLOG SCN 3. all RMAN backup sets created and the corresponding backup pieces. such as tablespaces.dbf'. copy # second datafile 3 to '$ HOME/prd3. will back up data files. a bit like OS hot backup. you can copy the entire data file to another location. ) 4. Example of a backup database. If the optimal set to open. copy # first datafile 1 to '$ HOME/prd1. starting from a number of documents to create % U a unique file name. sql 'alter system archive log current'. YYYYMMDD for the date. ResetlogSCN and time normal offline. on behalf of% u_% p_% c % S Backup set number % T Backup set timestamp % T years day format (YYYYMMDD) Fourth.2 backup and backup sets RMAN backup is to generate only regular RMAN backup sets can be identified. the RMAN backup RMAN can be used to back up the primary or standby database. or backup sets to run an optimization algorithm. allocate channel t2 type 'SBT_TAPE'. archive logs. but the results can only be written to the hard disk. Example of a file copy run ( allocate channel d1 type disk. ) RMAN can also be achieved with multiple mirror backup 51 . allocate channel d3 type disk.8 backup file format backup file to customize a variety of formats. data files. read-only or normal log off filing the same thread. the right to fill to the maximum of eight characters % U the name of a representative of eight characters and create the backup set time % P Backup piece of the backup set number. One IIIIIIIIII the database DBID. The same DBID. as follows % C backup copies of films % D database name % D in the first few days of the mid-(DD) % M in the first few months in the (MM) % F DBID a unique name based on this format in the form of c-IIIIIIIIII-YYYYMMDD-QQ. open the two channels. allocate channel d2 type disk. in addition to other than the backup copy command.1 The file copy of the original file copy. 4. backup filesperset 2 format 'df_% t_% s_% p' database. so. datafile 2 to '$ HOME/prd2. archive log. QQ is the sequence of a 1-256 % N database name. checkpoint SCN.dbf'. and separate files are separate. the database backup to tape run ( allocate channel t1 type 'SBT_TAPE'. control files. server files and backup sets.CONFIGURE BACKUP OPTIMIZATION ON.

After the Oracle 92 release. so in order to reduce recovery time. you can use FOREVER parameters. RMAN> backup archivelog all delete input.' DD_MM_YYYY)" nologs. sql 'ALTER SYSTEM ARCHIVE LOG CURRENT'. up to 30 characters in length. SET BACKUP COPIES 3.3 Common backup parameters 1. because archived logs can be backed up locally. so RAC archive log backup to become more complex. such as Restore database from tag = 'tag name' 4. the cumulative incremental backup is a backup since the changes in higher-level block. RMAN> backup archivelog like 'oracle / arc / dest / log%'. less need to focus on restoring the backup data. Cumulative incremental backup.Run ( allocate channel d1 type disk. RMAN automatically provides a TAG. The following are common examples of the backup archive RMAN> sql 'alter system archive log current'. we can connect to the Two examples of the channel to back up two instances of the archive log.'?/% U'.bak' filesperset = 5. Whatever incremental backup. In the RAC environment.'?/ oradata /% U'. or the need to compare all the data blocks in the database. ALLOCATE CHANNEL node_c2 DEVICE TYPE DISK CONNECT 'sys / pass @ dbin2'. run ( ALLOCATE CHANNEL node_c1 DEVICE TYPE DISK CONNECT 'sys / pass @ dbin1'. Keep the special parameters can be maintained long-term backup or copy them from the default backup strategy of keeping. we must first understand the difference between incremental and cumulative incremental backups. so you can connect to an instance you can back up the entire database. backup archivelog all delete input format '/ u01/dbbak /% U_% s. That can not keep them NOLOGS since the backup archive log. the default is the LOGS. is the default incremental backup. said that since the parameters of the retention of the backup. the difference is incremental backup since the changes in higher-level or equivalent backup block. such as RMAN> BACKUP DEVICE TYPE DISK DATAFILE 1 TAG 2> "wkly_bkup". RMAN> backup archivelog from time '01-jan-00 'until time '30-jun-00'. but because the recovery time. however. Cumulative incremental backups increases the time.4 incremental backup before incremental backup in the notes. and because the formation of a number of 52 . RMAN> backup archivelog from logseq 20 until logseq 50 thread 1. such as RMAN> BACKUP DATABASE KEEP UNTIL TIME 2> "to_date ('31-MAR-2002 '. allocate channel d3 type disk. you can see. RMAN> backup archivelog all. 2. allocate channel d2 type disk. RMAN> backup archivelog from scn 1 until scn 9999. ). also can easily recover from a backup set. the Oracle version 9. through the backup flag TAG. the format TAGYYYYMMDDTHHMMSS as TAG20020208T133437. and incremental backups of the backup and recovery principles. because the database is shared. Incremental difference. ) 4. this process is also a long process. BACKUP DATAFILE 7 FORMAT '/ tmp /% U'. RMAN> BACKUP TABLESPACE SAMPLE KEEP FOREVER NOLOGS. the backup if you want a permanent and effective. Tag parameters specify the backup set of signs. the cumulative incremental backups incremental backups more efficient than the differences.

------. 4. BACKUP VALIDATE DATABASE ARCHIVELOG ALL. 2 ROUND (SOFAR / TOTALWORK * 100. full or not suitable for OLTP systems. 4. you can only back up that less than 10% of the data. such as data file exists. of course the price is the log IO and disk space to pay. whether Select incremental backup as your backup strategy. such as: BACKUP VALIDATE DATABASE. so RMAN does not need to compare the database of each block. you need to have a clear understanding of their own. especially back up to 90%.5 Validate backup checks we can check whether the command to back up.------. through a simple command. many people may not want to start back up it again. because the special increment by the log. TOTALWORK.2) "% _COMPLETE" 3 FROM V $ SESSION_LONGOPS 4 WHERE OPNAME LIKE 'RMAN%' 5 AND OPNAME NOT LIKE '% aggregate%' 6 AND TOTALWORK! = 0 7 AND SOFAR <> TOTALWORK. Incremental backup requires a foundation. so incremental backups in version 9 is still tasteless.7 RMAN The following dynamic performance view has a relationship with the RMAN backup some dynamic performance view. the existence of bad blocks can not be backed up. such as level 0 incremental backup is the foundation of all backup. SERIAL #. V$ARCHIVED_LOG V$BACKUP_CORRUPTION V$COPY_CORRUPTION V$BACKUP_DATAFILE V$BACKUP_REDOLOG V$BACKUP_SET V$BACKUP_PIECE V$BACKUP_DEVICE V$CONTROLFILE_RECORD_SECTION Here is a view.different incremental backup backup set.---------- 53 . information is obtained from the control file. SQL> SELECT SID. An example of the incremental difference backup incremental level 1 database. 4. and the reasons for abnormal termination of the backup. version 10 through the back of the merger. and completely reduced recovery time. In addition. The following are examples of zero-level backup backup incremental level 0 database. level 0 backup and full backup of the difference is level 0 backup can be used as the basis for other incremental backup backup backup and all is not possible.------.6 Restart the backup for the backup abnormal end. Such as through the following SQL script. CONTEXT.--------. we can roughly monitor the extent to RMAN backups. make recovery becomes more unreliable and slow. will be the backup progress. no need to choose an incremental backup. you can make incremental backups into a truly incremental. Oracle version 10 in the incremental backup made a big improvement. SOFAR. SID SERIAL # CONTEXT SOFAR TOTAL WORK% _COMPLETE --. ultimately. unless very large data warehouse system. An example of the cumulative incremental backup incremental level 1 cumulative database. RMAN> BACKUP NOT BACKED UP SINCE TIME 'SYSDATE-14' 2> DATABASE PLUS ARCHIVELOG. so that the result of incremental backups can be combined together. then how should we do? RMAN provides a way to start back up.

may only completely restore the database. restore and recovery 5. you can restore data files to a new location SET NEWNAME FOR datafile '/ U01/oradata/tools01. no recovery archive log. The database and data files. in case of file corruption. and in addition to RMAN. In addition to restoration of database and data files.' Under normal circumstances.015. and for the recovery operation is very flexible. RMAN> RUN ( 2> ALLOCATE CHANNEL c1 TYPE DISK. RMAN can back up the parameter file. 3> ALTER DATABASE MOUNT. RMAN> RECOVER TABLESPACE tools. we can restore control file.36 5. 5> RECOVER DATABASE.1 General Reduction and Recovery RMAN in the recovery process can be divided into restore (restore) and restore (recover). you can use the following two simple commands to complete RMAN> restore database. restore operations can only be in use RMAN or RMAN packages do. 54 . restore the database can take relatively less time.947. RMAN> SQL "ALTER TABLESPACE tools OFFLINE IMMEDIATE".13. a means to restore database consistency.. The RMAN backup.65 128. 7> ALTER DATABASE OPEN RESETLOGS. using the following command can be Restore controlfile from 'file name' Restore controlfile from autobackup Restore controlfile from tag = '. 5> RESTORE DATABASE.751.. SET ARCHIVELOG DESTINATION TO '/ u02/tmp_restore'.dbf'. in case of no parameter file.. you can restore from the specified tag RMAN> RESTORE DATAFILE 1 FROM TAG = 'tag name' The recovery time is not fully recovered. the recovery process will automatically search for the required archive logs. RMAN> SQL "ALTER TABLESPACE tools ONLINE".) Incomplete recovery in RMAN can also log-based recovery RMAN> RUN ( 2> SET UNTIL SEQUENCE 120 THREAD 1.dbf'.111. the correct understanding of these two concepts will help to restore the correct database. we can specify where to restore. SWITCH DATAFILE ALL. need to start to nomount.160 56. 4> SET UNTIL TIME = '2002-12-09: 11:44:00 '. Restore and restore a database. or restore a data file. one is the physical meaning of the file to restore and copy. 3> ALLOCATE CHANNEL c2 TYPE DISK. To restore a table space. . RESTORE ARCHIVELOG ALL. RMAN> recover database. 6> RECOVER DATABASE. 4> RESTORE DATABASE. # recovers through log 119 6> ALTER DATABASE OPEN RESESTLOGS. RESTORE datafile '/ u01/oradata/tools01.360 61. Therefore.128. you can use RMAN to restore spfile parameter file. of course.. their meaning is very different. can be completed in SQLPLUS. 7>) If possible. RMAN> RESTORE TABLESPACE tools.dbf' TO '/ tmp/tools01. If you use the server parameter file (spfile).587.

dbms_backup_restore. fullname). done). use the following command to restore the view out the bad block RMAN> BLOCKRECOVER CORRUPTION LIST 2> RESTORE UNTIL TIME 'sysdate .restoresetdata file. this time may only be restored from the file. such as: BLOCKRECOVER datafile 6 BLOCK 3. begin devtype: = dbms_backup_restore.Repeat the above copycontrolfile for each control file end. Causes of damage produced block generally intermittent or random IO errors or block of memory error. dbms_backup_restore. Recover can be tested. Block error information is stored in V $ DATABASE_BLOCK_CORRUPTION. The following is a call dbms_backup_restore package. pass the test. recid. DBV tools or third-party media management tools.restorebackuppiece ('backup_piece'. and data files online. we can know whether the restore operation completed normally. Recovery block when the block must specify the specific number.4-level recovery block restoration Block Media Recovery (BMR). the error message recorded in the alert file. SQL> RECOVER TABLESPACE sales TEST. 98. / 5. restore operations can also check whether the normal restore or if the backup set is valid. BLOCKRECOVER datafile 2 BLOCK 12. To recover the bad block information from the alarm and tracking files. done boolean.10'. recid number.3 Reduction of inspection and test to check the same with the backup. 99 datafile 9 BLOCK 19. Backup bad block information stored in V $ BACKUP_CORRUPTION V $ COPY_CORRUPTION Can use the following command to recover bad blocks.2 The special circumstances of the restoration of lost in the assumption that recovery catalog and control file.deviceallocate ('sbt_tape'. only the backup sets and backup pieces. the block can reduce recovery time. 4194405 FROM TAG 55 . 13 datafile 7 BLOCK 5.copycontrolfile ('first_control_file'.using Rman temporary parameter file to start the database Nomount under execute the following command can be Restore controlfile from autobackup Restore controlfile from 'file name' 5. declare devtype varchar2 (100). and get a specific query. dbms_backup_restore. block the restoration of the smallest unit. test recovery error. dbms_backup_restore. table and index analysis. stamp number. BLOCKRECOVER TABLESPACE SYSTEM DBA 4194404. SQL> RECOVER DATABASE UNTIL CANCEL TEST 5. 'Second_control_file'. RMAN> VALIDATE BACKUPSET 218. stamp.restorecontrolfileto ( 'First_control_file'). fullname varchar2 (80). params => 'ENV = (NSR_SERVER = backup_server) '). Such as: RMAN> RESTORE DATABASE VALIDATE. from file recovery example. .

5. run the copy command. in linux / unix environment may be considered to establish a link to complete). this time to the standby 56 . and change the database name. As CONNECT TARGET CONNECT AUXILIARY SYS / aux_pwd @ newdb DUPLICATE TARGET DATABASE TO ndbnewh LOGFILE '? / Dbs/log_1. drsys. '? / Dbs/log_2.f'.f' SIZE 100M SKIP READONLY NOFILENAMECHECK. such as a more complex replication command: RUN ( ALLOCATE AUXILIARY CHANNEL newdb1 DEVICE TYPE sbt.f'. copy the primary database initialization parameter file to the copy machine and make the appropriate changes. and the need to copy the backup copy to the machine the same directory (if not the same directory. Copy command can also backup from the tape copy. to start to back-mount standby database. one is conventional Restore command from the main database using backup control file copy in the past.f') SIZE 200K REUSE. In the above command before. 4194405 RESTORE UNTIL TIME 'SYSDATE-2'. and backup and archive logs generated after the backup. and finally with resetlog open the database. and start copying the database to nomount next. the command will restore all data files. 4.f') SIZE 200K GROUP 3 ('? / Oradata/newdb/redo03_1. note the following points 1. back up all data on the primary database files.6 Using RMAN to create standby database using RMAN to create standby database can be used two ways. GROUP 2 ('? / Oradata/newdb/redo02_1.ora lOGFILE GROUP 1 ('? / Oradata/newdb/redo01_1. re-create the control file. and start using the new parameter file to restore the database to a consistent state. RMAN provides a special command to complete this operation.'/ h2/oracle/oradata/newdb /') UNTIL TIME 'SYSDATE-1' # specifies incomplete recovery SKIP TABLESPACE cmwlite. in the copy machine to create a new password file.5 Database replication can be used RMAN to copy and clone the database. BLOCKRECOVER TABLESPACE SYSTEM DBA 4194404.f') SIZE 200K. 6. 2.f' SIZE 100M. 5 in the main database or copy the database to run RMAN. '? / Oradata/newdb/redo01_2. '? / Oradata/newdb/redo03_2. are connected to the primary database and copy the database instance. skip the copy of the table space does not need. create the specified redolog. you can also change the database file of the new path and return to the previous point in time.f'. configure the primary database to copy the database or copy a database of network connections to the main database. example # skip desired tablespaces PFILE =? / Dbs / initNEWDB."Weekly_backup". DUPLICATE TARGET DATABASE TO newdb DB_FILE_NAME_CONVERT = ('/ h1/oracle/dbs/trgt /'. such as modifying the database name and instance name 3. '? / Oradata/newdb/redo02_2. control files. ) 5.

The whole process including the creation of the standby control file. the parameter file path specified in the reduction of conversion and data files. The following detailed description of this process. copy the backup to the standby database. RMAN> Backup filesperset 10 ArchiveLog all delete input. like other methods. RMAN> Backup current controlfile for standby. Report need backup of data files Report need backup [redundancy | days | incremental n]. SQL> alter database recover managed standby database disconnect. Another way is to copy the commands. the master database from backup to restore RMAN copied out. such as the reporting database can be backed up data files for all objects Report schema Or RMAN> REPORT SCHEMA AT TIME 'SYSDATE-14'. start to the Mount. start RMAN rman target / auxiliary sys / change_on_install @ STANDBY 6. such as view the backup information List backup View the backup summary information List backup summary View the file copy of the information List copy See detailed backup information List backup of datafile 'file name' list incarnation of database. start the RMAN command. start the standby database to the next nomount 2. 57 .1Report command Report command can detect those files to backup. all the same path 4. such as DUPLICATE TARGET DATABASE FOR STANDBY NOFILENAMECHECK. archive log restore so. 6.2 List command List command is usually used to view the backup and copy information. 7. RMAN> sql "Alter System Archive Log Current". Finally. connect to the database (DBID as the main database). And then back-end. and access to the management of backup recovery mode. 1. the final restoration of the log and start to manage recovery mode. back up the primary database and standby control file and all archives RMAN> Backup Database. RMAN management 6. the backup file can be deleted and those who can not obtain information. create a backup parameter file and password file. start creating standby database RMAN> duplicate target database for standby dorecover nofilenamecheck. RMAN> REPORT SCHEMA AT SEQUENCE 100 THREAD 1.database there is no data file. Report out of date or unavailable data file backup and copy Report obsolete [orphan] Report not available or inaccessible data file information Report unrecoverable [database] 6. configure the primary database to the standby database connection 5. SQL> recover standby database. RMAN> REPORT SCHEMA AT SCN 1000. 3.

but to restore the directory using the following benefits have only been restored some order catalog support (for 9i.4 Delete command Delete command can be used to delete the backup. Remove the backup archive RMAN> DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 300. recovery catalog and target database do the same machine.2 recovery catalog management to support the following command to restore directory (CREATE | UPGRADE | DROP) CATALOG (CREATE | DELETE | REPLACE | PRINT) SCRIPT LIST INCARNATION REGISTER DATABASE REPORT SCHEMA AT TIME 58 . 7. and update the status of backup or copy. RMAN> DELETE OBSOLETE RECOVERY WINDOW OF 7 DAYS. RMAN> DELETE OBSOLETE REDUNDANCY = 3. and place the structure on De change. recovery catalog Oracle version 9. 7. this target database in the Zhongduo case.ctl'. RMAN> DROP CATALOG. or to remove abandoned or expired backup sets. SQL> grant recovery_catalog_owner to RMAN. lost control of files not restored directory will be hard to recover without recovery catalog. RMAN> DELETE CONTROLFILECOPY '/ tmp/control01. Remove outdated or obsolete backup RMAN> DELETE EXPIRED BACKUP.3 Crosscheck command checks the disk or tape backup or copy is correct. 7.6. SQL> create user RMAN identified by RMAN 2 temporary tablespace TEMP 3 default tablespace RCVCAT 4 quota unlimited on RCVCAT. 6. because the control files automatically backed up. if incorrect. Recovery catalog can be used to upgrade and delete the following command RMAN> UPGRADE CATALOG. but also relatively small size requirements. time of recovery requires careful operation can storage backup and recovery of the script can see. LIST EXPIRED BACKUP SUMMARY. you can become a great extent do not need to restore catalog. Crosscheck archivelog all. RMAN> create catalog RMAN> register database. RMAN> DELETE BACKUP OF TABLESPACE users DEVICE TYPE sbt. such as delete the specified backup sets and backup pieces RMAN> DELETE BACKUPPIECE 101.1 Creating restore directory attention. is mainly to retain more of Beifenxinxi Yu Fang Bian's Guanli multiple Mubiao database. is can be considered. will be marked as expired (expired) Crosscheck backup. the special operation is to restore directory statements only) * Be able to retain more historical backup information to manage a recovery catalog database. Delete [noprompt] expired backup command to delete expired backups can also be used to view the report of the List LIST EXPIRED BACKUP. RMAN> DELETE NOPROMPT OBSOLETE. if multiple targets with the backup in 9i ago.

ALLOCATE CHANNEL FOR DELETE Not available 59 ... .4 Storage store script script RMAN> creata script level0backp ( backup incremental level 0 format '/ u01/db01/backup /% U' filesperset 5 database plus archivelog delete input... ) Scripting RMAN> run (execute script Level0backup.2 REPLICATE RESTORE CONTROLFILE FROM . 7.. In the following circumstances need to synchronize changes in the physical structure of the database data file is to change the size of the increase or remove the rollback tablespace to create and delete the archive logs to generate 10 per 2. Reset command after the target database resetlogs need to reset the recovery catalog. SET AUTOLOCATE Now enabled by default. Section RMAN architecture and operating method RMAN for common backup methods Reduction and Recovery RMAN Management method and common RMAN recovery catalog and restore order to use the directory command in Appendix abandoned and replaced by a new version of the old command syntax of the command current 9. such as the restoration of directory-related view RC_DATABASE RC_DATAFILE RC_STORED_SCRIPT RC_STORED_SCRIPT_LINE RC_TABLESPACE By the following command to view information select * from rc_database. View Script RMAN> print script level0backup. ) Remove Script RMAN> delete script Level0backup.) Update script RMAN> replace script level0backup ( . rman can generally be automatically synchronized.RESET DATABASE RESYNC CATALOG 1. in practice. sql 'alter database archive log current'. 7.3 recovery catalog view to restore directory itself has a view of the target database for the storage and backup information.. Resync command Resync can be synchronized between the database and recovery catalog information. Reset command to reset the recovery catalog.

. ALLOCATE CHANNEL node_c2 DEVICE TYPE DISK CONNECT 'sys / pass @ db2in2'..bak' filesperset = 5.1 ALLOCATE CHANNEL . SETSIZE BACKUP .. ) list backup.zhs16gbk" export PATH = $ PATH: $ ORACLE_HOME / bin: / sbin: / usr / sbin echo "----------------------------. You can "easily" parallelize backup and much more importantly it can parallelize recovery. ARCHIVELOG . run ( ALLOCATE CHANNEL node_c1 DEVICE TYPE DISK CONNECT 'sys / pass @ db1in1'. It is much (MUCH) faster than OS file copies by a long shot... including the RAC database backup and archiving log shell script [Oracle @ db worksh] $ more rmanback.1 CHANGE .0. 3... I can fully backup small databases even on Windoze in a few minutes. AT SEQUENCE 9.901 ALLOCATE CHANNEL .1 CHANGE ...0.. MAXSETSIZE 9. 2..bak' filesperset = 2.. AT LOGSEQ REPORT .-----------". 60 ..0.. MAXPIECESIZE 901 ALLOCATE CHANNEL . DEVICE TYPE 9.1 SET AUXNAME CONFIGURE AUXNAME A practical script. CROSSCHECK CROSSCHECK 9.0... KBYTES CONFIGURE CHANNEL ... date # Backup start $ ORACLE_HOME / bin / rman <<EOF connect target delete noprompt obsolete.0... backup archivelog all delete input format '/ rmanback/db2 /% U_% s. TYPE CONFIGURE CHANNEL .1 BACKUP ..1 .0. LOGSEQ . date Why RMAN Backup On top of all of the good things you have said there are a couple of other very very good things about RMAN: 1. It deals with the backup process at the block level so it waits for each block to become consistent to back it up..1 REPORT ... therfore no "cracked blocks" like file copying.start -----------------.-------------". DELETE DELETE 9..sh #! / Bin / sh # Set env export ORACLE_HOME = / opt/oracle/product/9.. EOF echo "-----------------------------. sql 'ALTER SYSTEM ARCHIVE LOG CURRENT'. RATE 9. ARCHIVELOG . READRATE CONFIGURE CHANNEL ...2 export ORACLE_SID = db2in1 export NLS_LANG = "AMERICAN_AMERICA. SEQUENCE 9..0.end ----------------.. exit... backup database include current controlfile format '/ rmanback/db2 /% U_% s.

the following supported command can be used to flush the buffer cache: ALTER SYSTEM FLUSH BUFFER_CACHE. Unix.0. 10. 5.0. 9. In Oracle 9. No more putting tablespaces in backup mode and hammering the daylights out of the redo log system. Windoze who cares and it can do it concurrently because the Oracle database Server is doing the real work. Events Introduction Enabling Events Listing All Events Listing Enabled Events Event Reference 61 . It deals with cold backups (if anybody actually wants to do one anymore). Testing backups without restoral is built-in and that's nice as well. Flushing the shared pool To flush the shared pool use: ALTER SYSTEM FLUSH SHARED_POOL. the STATE column for all rows in X$BH will be zero unless the block is currently pinned In Oracle 9. Flushing the buffer cache In Oracle 10.2. it's part of your design and deployment process. 7. It can manage the archived redo log automatically for you (getting them off the system to somewhere safe is important) including deleting the old logs. 6. One RMAN catalog database can manage a complete enterprise. Backup retension scheduling is built-in.1 and above the following unsupported command can also be used to flush the buffer cache: ALTER SESSION SET EVENTS 'immediate trace name flush_cache'. no more do I delete this backup or not. Forcing a logfile switch To force a logfile switch use ALTER SYSTEM SWITCH LOGFILE.1 (Windows 2000) the equivalent ORADEBUG command fails with ORA-3113 Forcing a checkpoint To force a checkpoint use ALTER SYSTEM CHECKPOINT.1 and above. Making standby databases and cloning is way simpler under RMAN becuse it is designed to do that for you.4. After this command has been executed. 8.

Some testing events may cause the database to crash. 1=on identifier e.e.g. In addition.Use a colon to separate the event text e. level level'. level level'.g. 0=off. Enabling Events Events can be enabled at instance level in the init.ora file using event='event trace name context forever. level level'.g. memory address etc Note that events change from one release to another. never set an event on a development database without first making a backup. Events can be enabled in other sessions using ORADEBUG To enable an event in a process use 62 .List events on consecutive lines e. event = "10248 trace name context forever.g. the keyword "event" must be in the same case (i. object id.g. the event number is frequently reused for a new event. always uppercase or always lowercase). level 10" 2 . Multiple events can be enabled in one of two ways 1 . Never set an event on a production database without obtaining permission from Oracle support.g. level 10" Note that in some versions of Oracle.Introduction There are four types of numeric events • • • • Immediate dumps Conditional dumps Trace dumps Events that change database behaviour Every event has a number which is in the Oracle error message range e. Note also that the message file sometimes does not reflect the events in the current release. level 10" event = "10249 trace name context forever. Events can also be enabled at instance level using the ALTER SYSTEM command ALTER SYSTEM SET EVENTS 'event trace name context forever. Events are disabled at instance level using ALTER SYSTEM SET EVENTS 'event trace name context off'. event 10046 is ORA-10046 Each event has one or more levels which can be • • • • range e. Events are disabled at session level using ALTER SESSION SET EVENTS 'event trace name context off'.g. 0x01 0x02 0x04 0x08 0x10 flag e. level 10:10249 trace name context forever. As existing events become deprecated and then obsolete. event = "10248 trace name context forever. Events can also be enabled at session level using the ALTER SESSION command ALTER SESSION SET EVENTS 'event trace name context forever. 1 to 10 bitmask e. Many events change the behaviour of the database.

10046. FOR err_num IN 10000. END. LEVEL level For example to set event 10046.10999 LOOP err_msg := SQLERRM (-err_num).10046.put_line (err_msg).msg To print detailed event messages (Unix only) use the following script event=10000 while [ $event -ne 10999 ] do event=`expr $event + 1` oerr ora $event done Listing Enabled Events To check which events are enabled in the current session SET SERVEROUTPUT ON DECLARE l_level NUMBER.set_ev (9.SETEV The SID and the serial number of the target session must be obtained from V$SESSION.enable (1000000). BEGIN 63 .set_ev (9. END LOOP. LEVEL 12 To disable an event in a session use ORADEBUG SESSION_EVENT event TRACE NAME CONTEXT OFF Events can be also enabled in other sessions using DBMS_SYSTEM. IF err_msg NOT LIKE '%Message '||err_num||' not found%' THEN dbms_output.ORADEBUG EVENT event TRACE NAME CONTEXT FOREVER. BEGIN dbms_output. For example to enable event 10046 level 8 in a session with SID 9 and serial number 29 use EXECUTE dbms_system. END IF.29. level 12 in Oracle process 8 use ORADEBUG SETORAPID 8 ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER. LEVEL 12 To disable an event in a process use ORADEBUG EVENT event TRACE NAME CONTEXT OFF To enable an event in a session use ORADEBUG SESSION_EVENT event TRACE NAME CONTEXT FOREVER. To dump all event messages in this range use SET SERVEROUTPUT ON DECLARE err_msg VARCHAR2(120). To disable event 10046 in the same session use EXECUTE dbms_system.29. LEVEL level For example ORADEBUG SESSION_EVENT 10046 TRACE NAME CONTEXT FOREVER.8. / On Unix systems event messages are in the formatted text file $ORACLE_HOME/rdbms/mesg/oraus. Listing All Events Most events are numbered in the range 10000 to 10999.0.'').'')..

For single instance databases there is only one redo log thread at any time.FOR l_event IN 10000.ksbddidn / Redo All changes to the database are recorded by redo. ksbdd.read_ev (l_event.l_level). Redo Threads Each online redo log has a thread number and a sequence number. Redo Log Groups A redo thread consists of two or more redo log groups. In general redo logs written on one architecture cannot be read on another. IF l_level > 0 THEN dbms_output. The thread number is mainly relevant in RAC databases where there can be multiple threads. Possible status values include UNUSED.put_line ('Event '||TO_CHAR (l_event)|| ' is set at level '||TO_CHAR (l_level)). Only one redo log group can be CURRENT at any time. one for each instance. Multiple members are configured to provide protection against media failure (mirroring). Redo is initially written to online redo logs. END IF. Initially redo log groups are UNUSED. Alternatively log switches can be triggered externally by commands such as: ALTER SYSTEM SWITCH LOGFILE. CURRENT. Redo includes all changes to datafiles. 64 . but does not include changes to control files or the parameter file. ksmfsv. END LOOP.ksmfsnam. Each redo log group contains one or more physical redo log files known as members. All members within a redo log group should be identical at any time. Thereafter the redo log group becomes INACTIVE until it is reused by the LGWR background process. x$ksmfsv ksmfsv WHERE ksbdd. ACTIVE and INACTIVE.10999 LOOP dbms_system.indx = ksbdp.ksbdddsc FROM x$ksbdd ksbdd. in Oracle 10. redo log group continues to be ACTIVE until a checkpoint has completed. Log Switches Log switches occur when the online redo log becomes full. operating system and server architecture. There are a few exceptions to this rule. / -----------Check background process using command – SELECT ksbdd.. Each redo log group has a status. Following a log switch. x$ksbdp ksbdp.2 a redo log written in Linux can be read by a Windows database.ksbddidn. For example. The contents of a redo log file depend on a combination of Oracle version. END.ksmfsadr ORDER BY ksbdd. The thread number is not necessarily the same as the instance number.indx AND ksbdp.addr = ksmfsv.

When a log switch occurs. Each redo record has a header. If archive logging is enabled.<offset> LEN . The VLD field in the redo record header specifies the type of the redo record.address of redo record within redo log. Redo Log Files A redo log file consists of a number of fixed size blocks. The second block of the header contains a standard Oracle file header which includes the following information: • • • • • • • Database name Thread Compatibility Version Start Time End Time Start SCN End SCN Other data is stored in the header.0088 LEN: 0x0050 VLD: 0x01 SCN: 0x0000. Redo Blocks The body of the redo log file is used to store redo blocks.2). The upper size limit is probably 65536 bytes. For most platforms including Linux and Solaris the redo log block size is 512 bytes. Therefore on Linux/Solaris the header is 1024 bytes. Format is <sequence_number>. In Oracle 9.00000193.Thread:1 RBA: 0x000092.redo byte address . Each redo block has a 16 byte header (Oracle 9.<block_number>. then following a low switch the completed online redo log will be copied to the archive log destination(s) either by the ARCH background process or the LNSn background process depending on the configuration. In Oracle 10.2 the redo record header is normally 12 bytes.system change number of redo record 65 .length of redo record in bytes including header VLD . the sequence number is incremented and redo continues to be written to the next file in the sequence. Each redo log file has a fixed header.see below SCN .2: REDO RECORD . The remainder of each redo block is used to store redo records. Note that the End SCN is actually the Start SCN of the next redo log file.redo log thread number RBA . In recent versions of Oracle (8. Redo Records Redo records are a logical structure. The size of the redo record header varies depending on the type. On other platforms including HP/UX Itanium the redo log block size can be 1024 bytes.2 the redo record header is normally 24 bytes. A physical redo block can also contain multiple redo records.2 and 10. The following is an example of a redo record header from Oracle 10.00181068 SUBSCN: 1 05/07/2009 21:53:48 The header includes the following fields • • • • • Thread . though under some circumstances they can increase to 68 bytes. The overall size of the redo log file is specified when the log group is created. though they can occasionally increase in size to 28 bytes.0 and above) this header is two blocks. Redo records can therefore span multiple physical redo blocks.

2 and 10.• • SUBSCN: Unknown Timestamp e. Known values are shown in the following table.2 though the exact figure is not known. These values may vary from one release to another.2. SCN allocated at or before this point in the KCROMARK 16 redo. The major number describes the level in the kernel where the redo is generated.2 there were over 150 redo log operations.5). Each change vector consists of: • • • change header list of element lengths list of elements The size of the change header is 28 bytes in both Oracle 9. unique key or column values of the row. Mnemonic KCRVOID KCRVALID KCRDEPND KCRVOID Value Description 0 The contents are not valid 1 Includes change vectors 2 Includes commit SCN 4 Includes dependent SCN New SCN mark record. The following table shows common levels: Level 4 5 10 11 13 14 Description Block Cleanout Transaction Layer (Undo) Index Operation Table Operation (DML) Block Allocation Extent Allocation 66 . The list of elements consists of one or more elements aligned on a four byte boundary. additional elements are appended to the change vector containing the primary key. a further two byte field is appended. SCN allocated exactly at this point in the KCRNMARK 8 redo log by this instance Old SCN mark record. If supplemental logging is enabled then for update operations (11. The list of element lengths has a two byte header specifying the overall length of the element length list in bytes. Operation Codes Each change vector has an operation code. 05/07/2009 21:53:48 The VLD field determines the size of the redo record header. The length of each element is stored in a two byte field. The operation code consists of a major number and a minor number. Finally if the structure does not align on a four byte boundary. Element sizes can range from four bytes to at least 32K. this number has grown significantly in Oracle 10. May be allocated by another instance New SCN was allocated to ensure redo for some block would be KCRORDER 32 ordered by inc/seq# when redo sorted by SCN Change Vectors A redo record consists of one or more change records known as change vectors. In Oracle 9.g.

Transaction Layer (Undo) Level 10 .Backup Management Level 18 .Block Write (DBWR) Level 24 .Index Operation Level 11 .Transaction Metadata (LogMiner) Level 22 . Follow the hyperlinks for more details on individual operations: Level 4 . For online redo logs the filename of the current redo log can be obtained using the following SQL: SELECT member FROM v$logfile WHERE group# = ( SELECT group# FROM v$log WHERE status = 'CURRENT' ).Direct Load Level 20 .Extent Allocation Level 17 . 67 .Block Cleanout Level 5 .Online Backup Level 19 .DDL Statement Log File Dumps Symbolic dumps can be created for both online redo logs and archived redo logs using the following syntax: ALTER SYSTEM DUMP LOGFILE '<filename>'.Table Operation (DML) Level 13 .17 18 19 20 22 23 24 • • • • • • • • • • • • • Backup Management Online Backup Direct Load Transaction Metadata (LogMiner) Space Management (ASSM) Block Write (DBWR) DDL Statement For each level there is one or more subcode.Space Management (ASSM) Level 23 .Block Allocation Level 14 .

Sign up to vote on this title
UsefulNot useful