http://appsjagan.blogspot.in/search?

updated-min=2010-01-01T00:00:00%2B05:30&updatedmax=2011-01-01T00:00:00%2B05:30&max-results=50 http://oraclemamukutti.blogspot.in/2011/03/performance-tuning-part-1.html http://www.dba-oracle.com/oracle_tips_fix_corrupt_undo_segments.htm http://allthingsoracle.com/convert-single-instance-to-rac-part-2-manually-convert-to-rac/ http://oracledbascratchpad.blogspot.in/2009/10/tuning-scripts.html http://kumarmohitlal.blogspot.in/2012/01/oracle-real-time-interview-questions.html http://gavinsoorma.com/category/oracle-11g/ http://dbaadnanrafi.blogspot.in/2011_01_01_archive.html http://www.siue.edu/~dbock/cmis565/ http://oraclemamukutti.blogspot.in/2011/03/performance-tuning-part-1.html http://oraclemamukutti.blogspot.in/2011/03/performance-tuning-part-2.html http://satya-dba.blogspot.in/2010/04/rman-commands.html#catalog (IMP) http://docs.oracle.com/cd/E11882_01/server.112/e25494/dba006.htm#ADMIN11052 Primary database scn is 22 and standby SCN is 24 how you will resolve this issue In case of a dedicated server, a server process is associated with a single user process and serves it dedicatedly. In case of a shared server, a single server process can serve multiple user processes. This is achieved with the help of a dispatcher process, which places each user process in a single request queue. Server process picks up the user process whenever it is free. After that, the server process puts the result in the individual response queue associated with different dispatcher processes. How to increase SGA_MAX_SIZE
SQL> SHOW parameter spfile NAME TYPE VALUE ------------------------------------ ----------- -----------------------------spfile string /u01/app/oracle/product/10.2.0 /dbs/spfileDB1.ora SQL> CREATE pfile FROM spfile; File created. SQL> ALTER system SET sga_max_size=600M scope=spfile; System altered. SQL> shutdown immediate; DATABASE closed. DATABASE dismounted. ORACLE instance shut down. SQL> startup

Data Files: moving renaming deleting
SQL> SELECT name FROM v$datafile; NAME --------------------------------------------------------/u01/app/oracle/product/10.2.0/oradata/DBSID/SYSTEM01.DBF

/u01/app/oracle/product/10.2.0/oradata/DBSID/UNDOTBS01.DBF /u01/app/oracle/product/10.2.0/oradata/DBSID/SYSAUX01.DBF /u01/app/oracle/product/10.2.0/oradata/DBSID/USERS01.DBF /u01/app/oracle/product/10.2.0/oradata/DBSID/EXAMPLE01.DBF

Shutdown the database first:
SQL> SHUTDOWN IMMEDIATE;

Rename a datafile:

SQL> host mv -v /u01/app/oracle/product/10.2.0/oradata/DBSID/EXAMPLE01.DBF \ /u01/app/oracle/product/10.2.0/oradata/DBSID/EXAMPLE02.DBF

Move a datafile to the new location:
SQL> HOST mv -v /u01/app/oracle/product/10.2.0/oradata/DBSID/EXAMPLE01.DBF \ /u01/app/oracle/oradata/DBSID/EXAMPLE01.DBF

Move and rename a datafile to the new location:

SQL> HOST mv -v /u01/app/oracle/product/10.2.0/oradata/DBSID/EXAMPLE01.DBF \ /u01/app/oracle/oradata/DBSID/EXAMPLE02.DBF SQL> STARTUP MOUNT

Move and rename a datafile variant:
SQL> ALTER DATABASE RENAME FILE '/u01/app/oracle/product/10.2.0/oradata/DBSID/EXAMPLE01.DBF' TO '/u01/app/oracle/oradata/DBSID/EXAMPLE02.DBF'; SQL> ALTER DATABASE OPEN; SQL> SELECT name FROM v$datafile; NAME ---------------------------------------------------------------/u01/app/oracle/product/10.2.0/oradata/DBSID/SYSTEM01.DBF /u01/app/oracle/product/10.2.0/oradata/DBSID/UNDOTBS01.DBF /u01/app/oracle/product/10.2.0/oradata/DBSID/SYSAUX01.DBF /u01/app/oracle/product/10.2.0/oradata/DBSID/USERS01.DBF /u01/app/oracle/oradata/DBSID/EXAMPLE02.DBF

Database altered

Deleting dropping a datafile:

If a datafile you wish to drop is only datafile, present in the tablespace in which it resides, you can simply drop a tablespace:
SQL> SELECT file_name, tablespace_name FROM dba_data_files; FILE_NAME TABLESPACE_NAME ------------------------------------------------------------------- -----------------------------/u01/app/oracle/oradata/DBSID/EXAMPLE02.DBF EXAMPLE02 SQL>ALTER DATABASE DATAFILE /u01/app/oracle/oradata/DBSID/EXAMPLE02.DBF OFFLINE DROP

SQL>DROP TABLESPACE EXAMPLE02 INCLUDING CONTENTS; SQL> host rm -f /u01/app/oracle/oradata/DBSID/EXAMPLE02.DBF

OR

SQL>DROP TABLESPACE EXAMPLE02 INCLUDING CONTENTS AND DATAFILES;

Redo Online Logs: add clear move delete After default database 10g installation usually we‘ve got 2-3 redo log files in 2-3 groups:
SQL>select GROUP#, member from v$logfile; GROUP# MEMBER ---------------------------------------------1 /u01/app/oracle/oradata/DBSID/redo01.log 2 /u01/app/oracle/oradata/DBSID/redo02.log 3 /u01/app/oracle/oradata/DBSID/redo03.log

Let’s make some changes and create 3 additional members on a different mount point...

Adding new redo log members to an existing group:

NOTE: The database is up and running. First, create physical directories:
as a root user: #mkdir -p /u02/app ; chmod -R 775 /u02; chown -R root:oinstall /u02

And next:
as an oracle user: $ mkdir -p /u02/app/ oracle/oradata/DBSID/ SQL> ALTER DATABASE ADD LOGFILE MEMBER '/u02/app/oracle/oradata/DBSID/redo1b.log' TO GROUP 1, '/u02/app/oracle/oradata/DBSID/redo2b.log' TO GROUP 2, '/u02/app/oracle/oradata/DBSID/redo3b.log' TO GROUP 3; SQL>select GROUP# , member from v$logfile order by group#; GROUP# MEMBER ---------------------------------------------1 /u01/app/oracle/oradata/DBSID/redo01.log 1 /u01/app/oracle/oradata/DBSID/redo1b.log 2 /u01/app/oracle/oradata/DBSID/redo02.log 2 /u01/app/oracle/oradata/DBSID/redo2b.log 3 /u01/app/oracle/oradata/DBSID/redo03.log 3 /u01/app/oracle/oradata/DBSID/redo3b.log

Renaming, moving the redo log files

First shutdown the database:
SQL>shutdown immediate

Move, rename physical files on the OS
$mv –v /u01/app/oracle/oradata/DBSID/redo01.log \ /u01/app/oracle/oradata/DBSID/redo1a.log $mv –v /u01/app/oracle/oradata/DBSID/redo02.log \ /u01/app/oracle/oradata/DBSID/redo2a.log $mv –v /u01/app/oracle/oradata/DBSID/redo03.log \ /u01/app/oracle/oradata/DBSID/redo3a.log

Go back to SQLplus and startup database in mount mode:
SQL>STARTUP MOUNT SQL>ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/DBSID/redo01.log' TO '/u01/app/oracle/oradata/DBSID/redo1a.log'; SQL>ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/DBSID/redo02.log' TO '/u01/app/oracle/oradata/DBSID/redo2a.log'; SQL>ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/DBSID/redo03.log' TO '/u01/app/oracle/oradata/DBSID/redo3a.log'; SQL> ALTER DATABASE OPEN; SQL>select GROUP# , member from v$logfile order by group#; GROUP# MEMBER ---------------------------------------------1 /u01/app/oracle/oradata/DBSID/redo1a.log 1 /u02/app/oracle/oradata/DBSID/redo1b.log 2 /u01/app/oracle/oradata/DBSID/redo2a.log 2 /u02/app/oracle/oradata/DBSID/redo2b.log 3 /u01/app/oracle/oradata/DBSID/redo3a.log 3 /u02/app/oracle/oradata/DBSID/redo3b.log

Creating a new redo log file:

1 SQL>ALTER DATABASE ADD LOGFILE 2 '/u01/app/oracle/oradata/DBSID/redo4a.log' SIZE 10M

A new group is created automatically.
SQL>select GROUP# , member from v$logfile order by group#; GROUP# MEMBER ---------------------------------------------1 /u01/app/oracle/oradata/DBSID/redo1a.log 1 /u02/app/oracle/oradata/DBSID/redo1b.log 2 /u01/app/oracle/oradata/DBSID/redo2a.log 2 /u02/app/oracle/oradata/DBSID/redo2b.log 3 /u01/app/oracle/oradata/DBSID/redo3a.log 3 /u02/app/oracle/oradata/DBSID/redo3b.log 4 /u02/app/oracle/oradata/DBSID/redo4a.log

SQL>ALTER SYSTEM SWITCH LOGFILE.Only inactive group can be dropped. Managing Tablespaces and Datafiles Using multiple tablespaces provides several Advantages  Separate user data from data dictionary data to reduce contention among dictionary objects and schema objects for the same datafiles.  Dropping redo log group and redo log member: NOTE: There are some restrictions when dropping redo log groups or redo log files: . you need to force clear 1 SQL>ALTER DATABASE CLEAR UNARCHIVED LOGFILE 2 '/u02/app/oracle/oradata/DBSID/redo3a.log'. '/u02/app/oracle/oradata/DBSID/redo3b. When archive log mode is YES.Creating new multiple log files: 1 2 3 4 5 SQL>ALTER DATABASE ADD LOGFILE ('/u02/app/oracle/oradata/DBSID/redo3b.log') SIZE 10M.log '.log' .log'.log '.There must be at least two redo log groups and each redo log group must have at least one log member left. Clearing Log Files and Group 1 SQL>ALTER DATABASE CLEAR LOGFILE 2 '/u02/app/oracle/oradata/DBSID/redo3a. . . Switching redo log files group and force to create an archive log file arc. To drop a group: SQL>ALTER DATABASE DROP LOGFILE GROUP 4. '/u02/app/oracle/oradata/DBSID/redo3b. To drop a group member: 1 SQL>ALTER DATABASE DROP LOGFILE MEMBER 2 '/u02/app/oracle/oradata/DBSID/redo4A. SQL>ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2.

The advantages of locally managed tablespaces are Locally managed tablespaces track all extent information in the tablespace itself by using bitmaps. The alternative to AUTOALLOCATE is UNIFORM. Store different the datafiles of different tablespaces on different disk drives to reduce I/O contention. Take individual tablespaces offline while others remain online. because recursive operations that are sometimes required during dictionary-managed space allocation are eliminated To create a locally managed tablespace give the following command SQL> CREATE TABLESPACE ica_lmts DATAFILE '/u02/oracle/ica/ica01. providing better overall availability.   Separate data of one application from the data of another to prevent multiple applications from being affected if a tablespace must be taken offline. You can specify that size in the SIZE clause of UNIFORM. which specifies that the tablespace is managed with extents of uniform size. then the default size is 1M. because space allocations and deallocations modify locally managed resources (bitmaps stored in header files) rather than requiring centrally managed resources such as enqueues Performance is improved. In prior versions of Oracle only Dictionary managed Tablespaces were available but from Oracle ver. To Create Dictionary Managed Tablespace . If you omit SIZE. 8i you can also create Locally managed tablespaces. resulting in the following benefits:   Concurrency and speed of space operations is improved. AUTOALLOCATE causes the tablespace to be system managed with a minimum extent size of 64K. The following example creates a Locally managed tablespace with uniform extent size of 256K SQL> CREATE TABLESPACE ica_lmt DATAFILE '/u02/oracle/ica/ica01.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL AUTOALLOCATE. Creating New Tablespaces You can create Locally Managed or Dictionary Managed Tablespaces.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K.

in contrast. To create a bigfile tablespace give the following command SQL> CREATE BIGFILE TABLESPACE ica_bigtbs DATAFILE '/u02/oracle/ica/bigtbs01.dbf' SIZE 50G. Traditional smallfile tablespaces.SQL> CREATE TABLESPACE ica_lmt DATAFILE '/u02/oracle/ica/ica01.dbf' SIZE 50M EXTENT MANAGEMENT DICTIONARY. Option 3 You can also use auto extend feature of datafile. can contain multiple datafiles. Oracle will automatically increase the size of a datafile whenever space is required.dbf’ resize 100M. SQL> alter tablespace add datafile ‘/u02/oracle/ica/icatbs02. Bigfile Tablespaces (Introduced in Oracle Ver. To Extend the Size of a tablespace Option 1 You can extend the size of a tablespace by increasing the size of an existing datafile by typing the following command SQL> alter database ica datafile ‘/u01/oracle/data/icatbs01. In this. but very large (up to 4G blocks) datafile. Bigfile tablespaces can reduce the number of datafiles needed for a database. . To add a new datafile to an existing tablespace give the following command. 10g) A bigfile tablespace is a tablespace with a single. You can specify by how much size the file should increase and Maximum size to which it should extend. but the files cannot be as large.dbf’ size 50M. This is useful if the size of existing datafile is reached o/s file size limit or the drive where the file is existing does not have free space. This will increase the size from 50M to 100M Option 2 You can also extend the size of a tablespace by adding a new datafile to a tablespace.

. To Coalesce a tablespace give the following command SQL> alter tablespace ica coalesce. You decrease a datafile only up to size of empty space in it. but adjacent free extents are not immediately recombined into larger free extents. You should often use the ALTER TABLESPACE .. To decrease the size of a datafile give the following command SQL> alter database datafile ‘/u01/oracle/ica/icatbs01. When allocating new extents to a tablespace segment. Coalescing Tablespaces A free extent in a dictionary-managed tablespace is made up of a collection of contiguous free blocks. COALESCE statement to manually coalesce any adjacent free extents. when segments are dropped. the database uses the free extent closest in size to the required extent.. their extents are deallocated and marked as free. To decrease the size of a tablespace You can decrease the size of tablespace by decreasing the datafile associated with it.dbf’ size 50M auto extend ON next 5M maxsize 500M. The result is fragmentation that makes allocation of larger extents more difficult.To make a existing datafile auto extendable give the following command SQL> alter database datafile ‘/u01/oracle/ica/icatbs01. SQL> create tablespace ica datafile ‘/u01/oracle/ica/icatbs01. You can also make a datafile auto extendable while creating a new tablespace itself by giving the following command. In some cases.dbf’ resize 30M.dbf’ auto extend ON next 5M maxsize 500M.

. Again to bring it back online give the following command SQL> alter database datafile ‘/u01/oracle/ica/ica_tbs01.dbf’ offline for drop. you can bring an offline tablespace online to make the schema objects within the tablespace available to database users. To again bring it back online give the following command.dbf’ offline. SQL>alter tablespace ica online. You must have the ALTER TABLESPACE or MANAGE TABLESPACE system privilege. The database must be open to alter the availability of a tablespace. static portions of a database. Conversely. Note: You can‘t take individual datafiles offline it the database is running in NOARCHIVELOG mode. Making a Tablespace Read only. Making a tablespace read-only prevents updates on all tables in the tablespace. The rest of the database remains open and available for users to access data.dbf’ online. The primary purpose of read-only tablespaces is to eliminate the need to perform backup and recovery of large. Read-only tablespaces also provide a way to protecting historical data so that users cannot modify it. To alter the availability of a tablespace. To Take a Tablespace Offline give the following command SQL>alter tablespace ica offline. If the datafile has become corrupt or missing when the database is running in NOARCHIVELOG mode then you can only drop it by giving the following command SQL>alter database datafile ‘/u01/oracle/ica/ica_tbs01. use the ALTER TABLESPACE statement. regardless of a user's update privilege level. To take individual datafile offline type the following command SQL>alter database datafile ‘/u01/oracle/ica/ica_tbs01. Making a tablespace read-only prevents write operations on the datafiles in the tablespace.Taking tablespaces Offline or Online You can take an online tablespace offline so that it is temporarily unavailable for general use.

make sure that all data contained in a tablespace to be dropped will not be required in the future. This will drop the tablespace only if it is empty. Caution: Once a tablespace has been dropped. If any datafile in the tablespace is offline. you can rename a permanent or temporary tablespace. the data in the tablespace is not recoverable. For example. Therefore. back up the database completely To drop a tablespace give the following command. then it will not be renamed and an error is raised. SQL> drop tablespace ica. This will drop the tablespace even if it is not empty. If it is not empty and if you want to drop it anyhow then add the following keyword SQL>drop tablespace ica including contents. If the tablespace being renamed is the SYSTEM tablespace or the SYSAUX tablespace. Renaming Tablespaces Using the RENAME TO clause of the ALTER TABLESPACE. But the datafiles will not be deleted you have to use operating system command to delete the files. Dropping Tablespaces You can drop a tablespace and its contents (the segments contained in the tablespace) from the database if the tablespace and its contents are no longer required. immediately before and after dropping a tablespace from a database. . then the tablespace is not renamed and an error is raised. Also. or if the tablespace is offline.To make a tablespace read only SQL>alter tablespace ica read only Again to make it read write SQL>alter tablespace ica read write. You must have the DROP TABLESPACE system privilege to drop a tablespace. the following statement renames the users tablespace: ALTER TABLESPACE users RENAME TO usersts. The following affect the operation of this statement:    The COMPATIBLE parameter must be set to 10.0 or higher.

Tablespace Groups A tablespace group enables a user to consume temporary space from multiple tablespaces. The following statement resizes a temporary file: SQL>ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02. The following statement drops a temporary file and deletes the operating system file: SQL> ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02. The AUTOALLOCATE clause is not allowed for temporary tablespaces. You can specify a tablespace group name wherever a tablespace name would appear when you assign a default temporary tablespace for the database or a temporary tablespace for a user. The extent management clause is optional for temporary tablespaces because all temporary tablespaces are created with locally managed extents of a uniform size.dbf' DROP INCLUDING DATAFILES. Increasing or Decreasing the size of a Temporary Tablespace You can use the resize clause to increase or decrease the size of a temporary tablespace. so its name cannot be the same as any tablespace.dbf’ size 100M extent management local uniform size 5M. SQL>drop tablespace ica including contents and datafiles. SQL>create temporary tablespace temp tempfile ‘/u01/oracle/data/ica_temp. It shares the namespace of tablespaces. . There is no explicit limit on the maximum number of tablespaces that are contained in a group. To create temporary tablespace give the following command.But If you include datafiles keyword then. A tablespace group has the following characteristics:    It contains at least one tablespace.dbf' RESIZE 18M. Every database should have one temporary tablespace. Temporary Tablespace Temporary tablespace is used for sorting large tables. the associated datafiles will also be deleted from the disk.

can alleviate problems caused where one tablespace is inadequate to hold the results of a sort. Creating a Temporary Tablespace Group You create a tablespace group implicitly when you include the TABLESPACE GROUP clause in the CREATE TEMPORARY TABLESPACE or ALTER TABLESPACE statement and the specified tablespace group does not currently exist. Rather. The view DBA_TABLESPACE_GROUPS lists tablespace groups and their member tablespaces. A tablespace group enables parallel execution servers in a single parallel operation to use multiple temporary tablespaces. For example: ALTER DATABASE sample DEFAULT TEMPORARY TABLESPACE group2.DEFAULT TEMPORARY TABLESPACE statement to assign a tablespace group as the default temporary tablespace for the database.. rather than a single temporary tablespace. Using a tablespace group. This package has many procedures described below: Procedure Description . For example.You do not explicitly create a tablespace group. it is created implicitly when you assign the first temporary tablespace to the group. particularly on a table that has many partitions.. The group is deleted when the last temporary tablespace it contains is removed from it. then the following statements create those groups. each of which has only the specified tablespace as a member: CREATE TEMPORARY TABLESPACE ica_temp2 TEMPFILE '/u02/oracle/ica/ica_temp.dbf' SIZE 50M TABLESPACE GROUP group1. Diagnosing and Repairing Locally Managed Tablespace Problems To diagnose and repair corruptions in Locally Managed Tablespaces Oracle has supplied a package called DBMS_SPACE_ADMIN. Assigning a Tablespace Group as the Default Temporary Tablespace Use the ALTER DATABASE . if neither group1 nor group2 exists. ALTER TABLESPACE ica_temp2 TABLESPACE GROUP group2.

Cannot be used for a locally managed system tablespace. Fixes the state of the segments in a tablespace in which SEGMENT_DROP_CORRUPT SEGMENT_DUMP TABLESPACE_VERIFY TABLESPACE_REBUILD_BITMAPS TABLESPACE_FIX_BITMAPS TABLESPACE_REBUILD_QUOTAS TABLESPACE_MIGRATE_FROM_LOCAL TABLESPACE_MIGRATE_TO_LOCAL TABLESPACE_RELOCATE_BITMAPS TABLESPACE_FIX_SEGMENT_STATES . Rebuilds quotas for given tablespace. Verifies that the bitmaps and extent maps for the segments in the tablespace are in sync. Drops a segment currently marked corrupt (without reclaiming space). Marks the appropriate data block address range (extent) as free or used in bitmap. Relocates the bitmaps to the destination specified. Cannot be used to migrate a locally managed SYSTEM tablespace to a dictionary-managed SYSTEM tablespace. Rebuilds the appropriate bitmap. Cannot be used for a locally managed SYSTEM tablespace. Cannot be used for a locally managed SYSTEM tablespace. Migrates a tablespace from dictionary-managed format to locally managed format.Procedure SEGMENT_VERIFY SEGMENT_CORRUPT Description Verifies the consistency of the extent map of the segment. Cannot be used for a locally managed SYSTEM tablespace. Marks the segment corrupt or valid so that appropriate error recovery can be done. Dumps the segment header and extent map of a given segment. Cannot be used for a locally managed SYSTEM tablespace. Migrates a locally managed tablespace to dictionarymanaged tablespace.

Call the SEGMENT_DUMP procedure to dump the DBA ranges allocated to the segment. then proceed with steps 2 through 5. Be careful using the above procedures if not used properly you will corrupt your database.Procedure Description migration was aborted. Call TABLESPACE_REBUILD_QUOTAS to fix up quotas. 2. 4. 2. For each range. For each range. Call the SEGMENT_VERIFY procedure with the SEGMENT_VERIFY_EXTENTS_GLOBAL option. 3. The system has automatically marked the segment corrupted. Contact Oracle Support before using these procedures. Scenario 2: Dropping a Corrupted Segment You cannot drop a segment because the bitmap has segment blocks marked "free". perform the following tasks: 1. If no overlaps are reported. Call TABLESPACE_REBUILD_QUOTAS to fix up quotas. but no overlap between segments is reported. perform the following tasks: 1. Following are some of the Scenarios where you can use the above procedures Scenario 1: Fixing Bitmap When Allocated Blocks are Marked Free (No Overlap) The TABLESPACE_VERIFY procedure discovers that a segment has allocated blocks that are marked free in the bitmap. 5. In this scenario. 3. In this scenario. Call SEGMENT_DROP_CORRUPT to drop the SEG$ entry. Scenario 3: Fixing Bitmap Where Overlap is Reported . call the TABLESPACE_FIX_BITMAPS procedure with the TABLESPACE_EXTENT_MAKE_USED option to mark the space as used. Call the SEGMENT_DUMP procedure to dump the ranges that the administrator allocated to the segment. call TABLESPACE_FIX_BITMAPS with the TABLESPACE_EXTENT_MAKE_FREE option to mark the space as free.

Call the TABLESPACE_REBUILD_QUOTAS procedure to rebuild quotas. The tablespaces being transported can be either dictionary managed or locally managed. Scenario 5: Migrating from a Dictionary-Managed to a Locally Managed Tablespace To migrate a dictionary-managed tablespace to a locally managed tablespace. Drop table t1. Rerun the TABLESPACE_VERIFY procedure to verify the problem is resolved. After choosing the object to be sacrificed. You use the TABLESPACE_MIGRATE_TO_LOCAL procedure.The TABLESPACE_VERIFY procedure reports some overlapping. perform the following tasks: 1. table t1. Transporting Tablespaces You can use the transportable tablespaces feature to move a subset of an Oracle Database and "plug" it in to another Oracle Database. essentially moving tablespaces between the databases. follow up by calling the SEGMENT_DROP_CORRUPT procedure. 3. If necessary. Starting with Oracle9i. Make a list of all objects that t1 overlaps. Call the TABLESPACE_VERIFY procedure to verify that the bitmaps are consistent. 2. Call the SEGMENT_VERIFY procedure on all objects that t1 overlapped. or on a single block if only one is corrupt. 4. Scenario 4: Correcting Media Corruption of Bitmap Blocks A set of bitmap blocks has media corruption. Some of the real data must be sacrificed based on previous internal errors. perform the following tasks: 1. In this scenario. EXEC DBMS_SPACE_ADMIN. . If necessary. 3. the transported tablespaces are not required to be of the same block size as the target database standard block size. in this case say. either on all bitmap blocks. 2. call the TABLESPACE_FIX_BITMAPS procedure to mark appropriate bitmap blocks as used. Call the TABLESPACE_REBUILD_BITMAPS procedure. For example if you want to migrate a dictionary managed tablespace ICA2 to Locally managed then give the following command.TABLESPACE_MIGRATE_TO_LOCAL ('ica2').

In an Oracle Database with compatibility set to 10. the datafile header must identify the platform to which it belongs.-----------------------------. PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT ----------. Important: Before a tablespace can be transported to a different platform. . This functionality can be used to Allow a database to be migrated from one platform to another. and you use an import utility to transfer only the metadata of the tablespace objects to the new database.Moving data using transportable tablespaces is much faster than performing either an export/import or unload/load of the same data. However not all platforms are supported. Starting with Oracle Database 10g. SQL> COLUMN PLATFORM_NAME FORMAT A30 SQL> SELECT * FROM V$TRANSPORTABLE_PLATFORM. you can accomplish this by making the datafile read/write at least once. This is because the datafiles containing all of the actual data are simply copied to the destination location. To see which platforms are supported give the following query. Big Big Little Little Big Big Little Big Little Little If the source platform and the target platform are of different endianness.0 or higher.0.-------------1 Solaris[tm] OE (32-bit) 2 Solaris[tm] OE (64-bit) 7 Microsoft Windows NT 10 Linux IA (32-bit) 6 AIX-Based Systems (64-bit) 3 HP-UX (64-bit) 5 HP Tru64 UNIX 4 HP-UX IA (64-bit) 11 Linux IA (64-bit) 15 HP Open VMS 10 rows selected. you can transport tablespaces across platforms. then no conversion is necessary and tablespaces can be transported as if they were on the same platform. then an additional step must be done on either the source or target platform to convert the tablespace being transported to the target format. If they are of the same endianness.

check the endian format of both platforms by querying the V$TRANSPORTABLE_PLATFORM view. Otherwise you must do a conversion of the tablespace set either at the source or target database. an operating system copy utility. and you have not performed a source-side conversion to the endianness of the target platform. you should perform a target-side conversion now. Procedure for transporting tablespaces To move or copy a set of tablespaces. no conversion is necessary. then determine if the source and target platforms are supported and their endianness. Generate a transportable tablespace set. 2. A transportable tablespace set consists of datafiles for the set of tablespaces being transported and an export file containing structural information for the set of tablespaces. You can perform a source-side conversion at this step in the procedure. 3. If you are transporting the tablespace set to a platform different from the source platform. perform the following steps. ftp. Plug in the tablespace. Then. or you can perform a target-side conversion as part of step 4. or publishing on CDs).SQL> alter tablespace ica read only. For cross-platform transport. Transport the tablespace set. . If you have transported the tablespace set to a platform with different endianness from the source platform. Ignore this step if you are transporting your tablespace set to the same platform. Copy the datafiles and the export file to the target database. If both platforms have the same endianness. You can do this using any facility for copying flat files (for example. 5. you must convert the tablespace set to the endianness of the target platform. the DBMS_FILE_COPY package. If you are transporting the tablespace set to a platform with different endianness from the source platform. 4. Pick a self-contained set of tablespaces. 1. SQL> alter tablespace ica read write.

You can only transport a set of tablespaces that is self-contained. you can execute the following query on both platforms to determine if the platforms are supported and their endian formats: SELECT d.PLATFORM_NAME = d.PLATFORM_NAME. V$DATABASE d WHERE tp.Invoke the Export utility to plug the set of tablespaces into the target database. That is it should not have tables with foreign keys referring to primary key of tables which are in other .PLATFORM_NAME. Transporting Tablespace Example These steps are illustrated more fully in the example that follows.dbf /u01/oracle/oradata/ica_salesdb/ica_sales_201. where it is assumed the following datafiles and tablespaces exist: Tablespace ica_sales_1 ica_sales_2 Datafile: /u01/oracle/oradata/ica_salesdb/ica_sales_101. ENDIAN_FORMAT FROM V$TRANSPORTABLE_PLATFORM tp. The following is the query result from the source platform: PLATFORM_NAME ENDIAN_FORMAT ------------------------.-------------Solaris[tm] OE (32-bit) Big The following is the result from the target platform: PLATFORM_NAME ENDIAN_FORMAT ------------------------. Step 2: Pick a Self-Contained Set of Tablespaces There may be logical or physical dependencies between objects in the transportable set and those outside of the set. If ica_sales_1 and ica_sales_2 were being transported to a different platform.-------------Microsoft Windows NT Little You can see that the endian formats are different and thus a conversion is necessary for transporting the tablespace set.dbf Step 1: Determine if Platforms are Supported and Endianness This step is only necessary if you are transporting the tablespace set to a platform different from the source platform.

Tablespace altered. Invoke the Export utility on the host system and specify which tablespaces are in the transportable set. VIOLATIONS --------------------------------------------------------------------------Constraint DEPT_FK between table SAMI. After executing the above give the following query to see whether any violations are there.TRANSPORT_SET_CHECK('ica_sales_1. SQL> ALTER TABLESPACE ica_sales_2 READ ONLY. Tablespace altered.EMP in tablespace ICA_SALES_1 and table SAMI.SALES is partially contained in the transportable set These violations must be resolved before ica_sales_1 and ica_sales_2 are transportable Step 3: Generate a Transportable Tablespace Set After ensuring you have a self-contained set of tablespaces that you want to transport. and the endianness of the platforms is different. TRUE).ica_sales_2'.DEPT in tablespace OTHER Partitioned table SAMI. SQL> HOST $ exp system/password FILE=/u01/oracle/expdat. generate a transportable tablespace set by performing the following actions: Make all tablespaces in the set you are copying read-only.dmp TRANSPORT_TABLESPACES = ica_sales_1. and if you want to convert before transporting the . SQL> ALTER TABLESPACE ica_sales_1 READ ONLY. SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS. It should not have tables with some partitions in other tablespaces.ica_sales_2 If ica_sales_1 and ica_sales_2 are being transported to a different platform. To find out whether the tablespace is self contained do the following EXECUTE DBMS_TTS.tablespaces.

dbf converted datafile=/temp/data_D-10_I-3295731590_TS-EXAMPLE_FNO4_06ek24vl channel ORA_DISK_1: datafile conversion complete. Oracle Corporation. an operating system copy utility. You can use any facility for copying flat files (for example. You have to use RMAN utility to convert datafiles $ RMAN TARGET / Recovery Manager: Release 10.tablespace set. Starting backup at 08-APR-03 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=11 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00005 name=/u01/oracle/oradata/ica_salesdb/ica_sales_101.0. elapsed time: 00:00:45 Finished backup at 08-APR-07 Step 4: Transport the Tablespace Set Transport both the datafiles and the export file of the tablespaces to a place accessible to the target database. In this example. then convert the datafiles composing the ica_sales_1 and ica_sales_2 tablespaces. connected to target database: ica_salesdb (DBID=3295731590) Convert the datafiles into a temporary location on the source platform. directory /temp.ica_sales_2 TO PLATFORM 'Microsoft Windows NT' FORMAT '/temp/%U'. The converted datafiles are assigned names by the system. elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile conversion input datafile fno=00004 name=/u01/oracle/oradata/ica_salesdb/ica_sales_101.1. RMAN> CONVERT TABLESPACE ica_sales_1. assume that the temporary location. has already been created.0. 2003.0 Copyright (c) 1995. ftp. the DBMS_FILE_TRANSFER package. All rights reserved.dbf converted datafile=/temp/data_D-10_I-3295731590_TS-ADMIN_TBS_FNO5_05ek24v5 channel ORA_DISK_1: datafile conversion complete. . or publishing on CDs).

In this example. ALTER TABLESPACE ica_sales_2 READ WRITE. Similarly. put the tablespaces into read/write mode as follows: ALTER TABLESPACE ica_sales_1 READ WRITE. then the import utility returns an error. but must have users sami and john. all tablespaces in the set being copied remain in readonly mode. After this statement executes successfully. Now. Some of them are: To view information about Tablespaces in a database give the following query SQL>select * from dba_tablespaces SQL>select * from v$tablespace. To view information about Datafiles SQL>select * from dba_data_files. all database objects (such as tables and indexes) are created in the same user schema as in the source database. Viewing Information about Tablespaces and Datafiles Oracle has provided many Data dictionaries to view information about tablespaces and datafiles. Check the import logs to ensure that no error has occurred. In this case.Step 5: Plug In the Tablespace Set Plug in the tablespaces and integrate the structural information using the Import utility. the target database is not required to have users smith and williams.dbf REMAP_SCHEMA=(smith:sami) REMAP_SCHEMA=(williams:john) The REMAP_SCHEMA parameter changes the ownership of database objects. SQL>select * from v$datafile. objects in the tablespace set owned by smith in the source database will be owned by sami in the target database after the tablespace set is plugged in. objects owned by williams in the source database will be owned by john in the target database. and those users must already exist in the target database./ica_salesdb/ica_sales_201. imp: IMP system/password FILE=expdat.dmp DATAFILES=/ica_salesdb/ica_sales_101. If they do not exist. If you do not specify REMAP_SCHEMA.dbf. To view information about Tempfiles .

dbf’ then follow the given the steps 1. For Example suppose you have a tablespace users with the following datafiles /u01/oracle/ica/usr01.dbf’ and want to rename ‘/u01/oracle/ica/usr02. 3.dbf’ Now you want to relocate /u01/oracle/ica/usr01. $cp /u01/oracle/ica/usr01.dbf’ /u01/oracle/ica/usr02. 2. 2. 1. Relocating or Renaming Datafiles You can rename datafiles to either change their names or relocate them.dbf /u02/oracle/ica/usr01. To view information about free space in datafiles SQL>select * from dba_free_space. Renaming or Relocating Datafiles belonging to a Single Tablespace To rename or relocate datafiles belonging to a Single Tablespace do the following.dbf’ to ‘/u01/oracle/ica/users02. Bring the tablespace offline SQL> alter tablespace users offline.SQL>select * from dba_temp_files.dbf’ to ‘/u02/oracle/ica/usr01. SQL>select * from v$tempfile.dbf’ . Bring the tablespace Online 4. To view information about free space in tempfiles SQL>select * from V$TEMP_SPACE_HEADER. Take the tablespace offline Rename or Relocate the datafiles using operating system command Give the ALTER TABLESPACE with RENAME DATAFILE option to change the filenames within the Database. Copy the file to new location using o/s command.

2. 1. This method is the only choice if you want to rename or relocate datafiles of several tablespaces in one operation.dbf’. '/u02/oracle/rbdb1/user3. specify the old datafile names exactly as they appear in the DBA_DATA_FILES view. /u01/oracle/ica/usr02.dbf to /u02/oracle/rbdb1/temp01. Use ALTER DATABASE to rename the file pointers in the database control file.dbf’.dbf'.dbf and /u02/oracle/rbdb1/user3.dbf Now start SQLPLUS and type the following command to rename and relocate these files SQL> alter tablespace users rename file ‘/u01/oracle/ica/usr01. 4. follow these steps.dbf.dbf' TO '/u02/oracle/rbdb1/temp01. ‘/u01/oracle/ica/usr02. using the operating system. Always provide complete filenames (including their paths) to properly identify the old and new datafiles.Rename the file ‘/u01/oracle/ica/usr02. the following statement renames the datafiles/u02/oracle/rbdb1/sort01. Now bring the tablespace Online SQL> alter tablespace users online. You must have the ALTER DATABASE system privilege To rename datafiles in multiple tablespaces. Copy the datafiles to be renamed to their new locations and new names.dbf and /u02/oracle/rbdb1/users03. $mv 3.dbf.dbf /u01/oracle/ica/users02. For example.dbf’. In particular.. Procedure for Renaming and Relocating Datafiles in Multiple Tablespaces You can rename and relocate datafiles in one or more tablespaces using the ALTER DATABASE RENAME FILE statement. .dbf'.dbf’ to ‘/u02/oracle/ica/usr01. Ensure that the database is mounted but closed.dbf’ using o/s command. respectively: ALTER DATABASE RENAME FILE '/u02/oracle/rbdb1/sort01.’/u01/oracle/ica/users02. 3. '/u02/oracle/rbdb1/users03.dbf’ to ‘/u01/oracle/ica/users02.

ora’ to group 1. . always perform an immediate and complete backup. Note: You can add members to a group up to the MAXLOGMEMBERS setting you have specified at the time of creating the database. Start the Database Managing REDO LOGFILES Every Oracle database must have at least 2 redo logfile groups.e. 5. Since Oracle defers writing to the datafile there is chance of power failure or system crash before the row is written to the disk. After 3 seconds the row is actually written to the datafile.e. one member in one disk and another in second disk. Back up the database.ora’ size 10M. After making any structural changes to a database. in a database. Adding a New Redo Logfile Group To add a new Redo Logfile group to the database give the following command SQL>alter database add logfile group 3 ‘/u01/oracle/ica/log3. Oracle writes all statements except. Actually the row is not yet written back to the datafile but still it give the message to the user that row is updated. If you want to change MAXLOGMEMBERS setting you have create a new controlfile Important: Is it strongly recommended that you multiplex logfiles i. it does write changes to disk per statement instead it performs write in batches. Adding Members to an existing group To add new member to an existing group give the following command SQL>alter database add logfile member ‘/u01/oracle/ica/log11. This is done because Oracle performs deferred batch writes i. If you want to change MAXLOGFILE setting you have to create a new controlfile. Note: You can add groups to a database up to the MAXLOGFILES setting you have specified at the time of creating the database. to the logfiles. That‘s why Oracle writes the statement in redo logfile so that in case of power failure or system crash oracle can re-execute the statements next time when you open the database.4. have at least two log members. Oracle will change the row in db_buffer_cache and records the statement in the logfile and give the message to the user that row is updated. So in this case if a user updates a row. SELECT statement. This is known as deferred batch writes.

Dropping Logfile Group Similarly. force a log switch or wait so that log switch occurs and another group becomes current. you can also drop logfile group only if the database is having more than two groups and if it is not the current group. The following command can be used to drop a logfile member SQL>alter database drop logfile member ‘/u01/oracle/ica/log11. suppose you want to move a logfile from ‘/u01/oracle/ica/log1. You have to use O/S command to delete the files from disk. If you want to drop members from the current group. If you want to resize a logfile create a new logfile group with the new size and subsequently drop the old logfile group. Shutdown the database .ora’ to ‘/u02/oracle/ica/log1. You have to use O/S command to delete the files from disk. Note: When you drop logfiles the files are not deleted from the disk.ora’.ora’. Renaming or Relocating Logfiles To Rename or Relocate Logfiles perform the following steps For Example. Resizing Logfiles You cannot resize logfiles. SQL>alter database drop logfile group 3. To force a log switch give the following command SQL>alter system switch logfile. Note: When you drop logfiles the files are not deleted from the disk.Dropping Members from a group You can drop member from a log group only if the group is having more than one member and if it is not the current group. then do the following Steps 1.

ora’ to ‘/u02/oracle/ica/log2. 5. Open the database SQL>alter database open. ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3.SQL>shutdown immediate. The database writes a message in the alert log describing the backups from which you cannot recover . 2. This statement overcomes two situations where dropping redo logs is not possible:   If there are only two log groups The corrupt redo log file belongs to the current group If the corrupt redo log file has not been archived.ora’. If you clear a log file that is needed for recovery of a backup. Move the logfile from Old location to new location using operating system command $mv /u01/oracle/ica/log1.ora Clearing REDO LOGFILES A redo log file might become corrupted while the database is open. In this situation the ALTER DATABASE CLEAR LOGFILE statement can be used reinitialize the file without shutting down the database. This statement clears the corrupted redo logs and avoids archiving them. Now give the following command to change the location in controlfile SQL>alter database rename file ‘/u01/oracle/ica/log1. /u02/oracle/ica/log1. then you can no longer recover from that backup. Start and mount the database SQL>startup mount 4. The cleared redo logs are available for use even though they were not archived. and ultimately stop database activity because archiving cannot continue. The following statement clears the log files in redo log group number 3: ALTER DATABASE CLEAR LOGFILE GROUP 3.ora 3. use the UNARCHIVED keyword in the statement.

. The control file includes:      The database name Names and locations of associated datafiles and redo log files The timestamp of the database creation The current log sequence number Checkpoint information It is strongly recommended that you multiplex control files i. Have at least two control files one in one hard disk and another one located in another disk. In this way if control file becomes corrupt in one disk the another copy will be available and you don‘t have to do recovery of control file. You can multiplex control file at the time of creating a database and later on also.ORA Managing Control Files Every Oracle Database has a control file.------.e.----. which is a small binary file that records the physical structure of the database.ORA /U01/ORACLE/ICA/LOG2.Viewing Information About Logfiles To See how many logfile groups are there and their status type the following query. If you have not multiplexed control file at the time of creating a database you can do it now by following given procedure. GROUP# -----1 2 STATUS ------MEMBER ---------------------------------/U01/ORACLE/ICA/LOG1. SQL>SELECT * FROM V$LOG. in a database. GROUP# THREAD# SEQ BYTES -----.------1 1 20605 1048576 2 1 20606 1048576 3 1 20603 1048576 4 1 20604 1048576 MEMBERS ------1 1 1 1 ARC --YES NO YES YES STATUS --------ACTIVE CURRENT INACTIVE INACTIVE FIRST_CHANGE# ------------61515628 41517595 31511666 21513647 FIRST_TIM --------21-JUN-07 21-JUN-07 21-JUN-07 21-JUN-07 To See how many members are there and where they are located give the following query SQL>SELECT * FROM V$LOGFILE.

ora 3. Start the Database Now Oracle will start updating both the control files and.Multiplexing Control File Steps: 1. For example.ora /u02/oracle/ica/control. MAXLOGMEMBERS then you have to create a new control file. Now open the parameter file and specify the new location like this CONTROL_FILES=/u01/oracle/ica/control. if one control file is lost you can copy it from another location.ora Change it to CONTROL_FILES=/u01/oracle/ica/control./u02/oracle/ica/contro l. MAXLOGFILES. Changing the Name of a Database If you ever want to change the name of database or want to change the setting of MAXDATAFILES. SQl>SHUTDOWN IMMEDIATE.ora. Creating a New Control File Follow the given steps to create a new controlfile Steps 1. $cp /u01/oracle/ica/control. Copy the control file from old location to new location using operating system command.ora 4. . 2. Shutdown the Database. First generate the create controlfile statement SQL>alter database backup controlfile to trace.

'/u01/oracle/ica/rbs01. '/u01/oracle/ica/users01.TRC and it is created in USER_DUMP_DEST directory.log') RESETLOGS DATAFILE '/u01/oracle/ica/system01.log'.After giving this statement oracle will write the CREATE CONTROLFILE statement in a trace file. Now these . This file will contain the CREATE CONTROLFILE statement. '/u01/oracle/ica/redo02_02. Since we are changing the name of the Database we have to use RESETLOGS option of CREATE CONTROLFILE statement. Go to the USER_DUMP_DEST directory and open the latest trace file in text editor. '/u01/oracle/ica/redo03_02. 2.dbf' SIZE 3M. Start and do not mount the database.dbs' SIZE 5M.sql 6. '/u01/oracle/ica/redo01_02.log').log'. Cloning an Oracle Database. 5.dbs' SIZE 5M MAXLOGFILES 50 MAXLOGMEMBERS 3 MAXLOGHISTORY 400 MAXDATAFILES 200 MAXINSTANCES 6 ARCHIVELOG.sql file in text editor and set the database name from ica to prod shown in an example below CREATE CONTROLFILE SET DATABASE prod LOGFILE GROUP 1 ('/u01/oracle/ica/redo01_01.sql 3. Now copy and paste the statement in a file. It will have two sets of statement one with RESETLOGS and another without RESETLOGS. 4. The company management wants to develop some new modules and they have hired some programmers to do that. Let it be c. Now open the c. SQL>STARTUP NOMOUNT. GROUP 2 ('/u01/oracle/ica/redo02_01. The trace file will be randomly named something like ORA23212.sql script SQL> @/u01/oracle/c. '/u01/oracle/ica/temp01. Now execute c. Now open the database with RESETLOGS SQL>ALTER DATABASE OPEN RESETLOGS.log'. GROUP 3 ('/u01/oracle/ica/redo03_01.dbs' SIZE 5M. You have a Production database running in one server.log').

dbf /u01/oracle/ica/sysaux. This file will contain steps and as well as CREATE CONTROLFILE statement.programmers require access to the Production database and they want to make changes to it.ora' .dbf /u01/oracle/ica/usr. Now. Let the filename be cr.dbf /u01/oracle/ica/rbs. In SERVER 1 generate CREATE CONTROLFILE statement by typing the following command SQL>alter database backup controlfile to trace.ora CONTROL FILES=/u01/oracle/ica/control. In SERVER 2 install the same version of o/s and same version Oracle as in SERVER 1. Copy the CREATE CONTROLFILE statement and paste in a file. To Clone this Database on SERVER 2 do the following. Let us see an example of cloning a database We have a database running the production server with the following files PARAMETER FILE located in /u01/oracle/ica/initica.ora BACKGROUND_DUMP_DEST=/u01/oracle/ica/bdump USER_DUMP_DEST=/u01/oracle/ica/udump CORE_DUMP_DEST=/u01/oracle/ica/cdump LOG_ARCHIVE_DEST_1=”location=/u01/oracle/ica/arc1” DATAFILES = /u01/oracle/ica/sys.ora /u01/oracle/ica/log2. Steps :1. go to the USER_DUMP_DEST directory and open the latest trace file.ora Now you want to copy this database to SERVER 2 and in SERVER 2 you don‘t have /u01 filesystem.dbf LOGFILE= /u01/oracle/ica/log1.sql The CREATE CONTROLFILE Statement will look like this. In SERVER 2 you have /d01 filesystem. You as a DBA can‘t give direct access to Production database so you want to create a copy of this database on another server and wants to give developers access to it. CREATE CONTROLFILE SET DATABASE prod LOGFILE GROUP 1 ('/u01/oracle/ica/log1. 2.dbf /u01/oracle/ica/tmp.

ora' GROUP 2 ('//d01/oracle/ica/log2.ora' DATAFILE '//d01/oracle/ica/sys. '/u01/oracle/ica/tmp.sql script file to /d01/oracle/ica directory.dbf' SIZE 50M. . ‘/u01/oracle/ica/sysaux. Copy the cr. '/u01/oracle/ica/usr.GROUP 2 ('/u01/oracle/ica/log2. 4.dbf' SIZE 300M. logfiles and control file to SERVER 2 in /d01/oracle/ica directory.ora BACKGROUND_DUMP_DEST=//d01/oracle/ica/bdump USER_DUMP_DEST=//d01/oracle/ica/udump CORE_DUMP_DEST=//d01/oracle/ica/cdump LOG_ARCHIVE_DEST_1=”location=//d01/oracle/ica/arc1” 5. 3.dbf' SIZE 50M.dbf’ size 100M. MAXLOGFILES 50 MAXLOGMEMBERS 3 MAXLOGHISTORY 400 MAXDATAFILES 200 MAXINSTANCES 6 ARCHIVELOG. Now.dbf' SIZE 50M. '/u01/oracle/ica/rbs.dbf' SIZE 300M. In SERVER 2 create the following directories $cd /d01/oracle $mkdir ica $mkdir arc1 $cd ica $mkdir bdump udump cdump Shutdown the database on SERVER 1 and transfer all datafiles.sql file in text editor and change the locations like this CREATE CONTROLFILE SET DATABASE prod LOGFILE GROUP 1 ('//d01/oracle/ica/log1. Copy parameter file to SERVER 2 in /d01/oracle/dbs directory and copy all archive log files to SERVER 2 in /d01/oracle/ica/arc1 directory. Open the parameter file SERVER 2 and change the following parameters CONTROL FILES=//d01/oracle/ica/control.ora' DATAFILE '/u01/oracle/ica/sys. open the cr. '//d01/oracle/ica/rbs.dbf' SIZE 50M.

These records are collectively referred to as undo.sql script to create the controlfile SQL>@/d01/oracle/ica/cr. Such information consists of records of the actions of transactions.sql 7. or undo. changes to the database. ‘//d01/oracle/ica/sysaux. Undo records are used to:      Roll back transactions when a ROLLBACK statement is issued Recover the database Provide read consistency Analyze data as of an earlier point in time by using Flashback Query Recover from logical corruptions using Flashback features Earlier releases of Oracle Database used rollback segments to store undo. MAXLOGFILES 50 MAXLOGMEMBERS 3 MAXLOGHISTORY 400 MAXDATAFILES 200 MAXINSTANCES 6 ARCHIVELOG. Open the database SQL>alter database open. Run cr.dbf' SIZE 50M. In SERVER 2 export ORACLE_SID environment variable and start the instance $export ORACLE_SID=ica $sqlplus Enter User:/ as sysdba SQL> startup nomount.dbf’ size 100M. '//d01/oracle/ica/tmp. 6. Managing the UNDO TABLESPACE Every Oracle Database must have a method of maintaining information that is used to roll back. Oracle9i introduced automatic undo management.'//d01/oracle/ica/usr.dbf' SIZE 50M. which simplifies undo space management by eliminating the complexities associated with rollback segment management. Oracle strongly recommends that . primarily before they are committed.

UNDO_MANAGEMENT=AUTO UNDO_TABLESPACE=myundo 3.you use undo tablespace to manage undo rather than rollback segments. if UNDO_RETENTION is set to 3 hours. Now Oracle Database will use Automatic Undo Space Management. Shutdown the Database and set the following parameters in parameter file.dbf’ size 500M autoextend ON next 5M . When the system is first running in the production environment. create an undo tablespace by typing the following command SQL>create undo tablespace myundo datafile ‘/u01/oracle/ica/undo_tbs. Switching to Automatic Management of Undo Space To go for automatic management of undo space set the following parameter. with a 8K block size. the required undo space is computed as follows: . Calculating the Space Requirements For Undo Retention You can calculate space requirements manually using the following formula: UndoSpace = UR * UPS + overhead where:     UndoSpace is the number of undo blocks UR is UNDO_RETENTION in seconds. In this case. bitmaps. This value should take into consideration longrunning queries and any flashback requirements. Steps:1. If you have not created an undo tablespace at the time of creating a database then. Start the Database. UPS is undo blocks for each second overhead is the small overhead for metadata (transaction tables. you may be unsure of the space requirements of the undo tablespace. you can enable automatic extension for datafiles of the undo tablespace so that they automatically increase in size when more space is needed 2. and the transaction rate (UPS) is 100 undo blocks for each second. and so forth) As an example.

24GBs To get the values for UPS.dbf' SIZE 200M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED. An undo tablespace can only be dropped if it is not currently used by any instance. By giving the following statement SQL> Select * from V$UNDOSTAT. the ALTER SYSTEM SET statement can be used to assign a new undo tablespace. after this command successfully executes. Overhead query the V$UNDOSTAT view. Dropping an Undo Tablespace Use the DROP TABLESPACE statement to drop an undo tablespace. a transaction died but has not yet been recovered). Altering UNDO Tablespace If the Undo tablespace is full. The following statement switches to a new undo tablespace: ALTER SYSTEM SET UNDO_TABLESPACE = myundo2. Assuming myundo is the current undo tablespace. The following example drops the undo tablespace undotbs_01: SQL> DROP TABLESPACE myundo. Viewing Information about Undo Tablespace . the instance uses myundo2 in place of myundo as its undo tablespace. you can resize existing datafiles or add new datafiles to it The following example extends an existing datafile SQL> alter database datafile ‘/u01/oracle/ica/undo_tbs. Because the UNDO_TABLESPACE initialization parameter is a dynamic parameter. If the undo tablespace contains any outstanding transactions (for example. the DROP TABLESPACE statement fails. Switching Undo Tablespaces You can switch from using one undo tablespace to another.dbf’ resize 700M The following example adds a new datafile to undo tablespace SQL> ALTER TABLESPACE myundo ADD DATAFILE '/u01/oracle/ica/undo02.(3 * 3600 * 100 * 8K) = 8.

4. data is imported and indexes are built. 5. procedures. This sequence prevents data from being rejected due to the order in which tables are imported. To see the sizes of extents in the undo tablespace give the following query SQL>select * from DBA_UNDO_EXTENTS. The export dump file contains objects in the following order: 1. This sequence also prevents redundant triggers from firing twice on the same data Invoking Export and Import . integrity constraints are enabled on the new tables. and domain indexes When you import the tables the import tool will perform the actions in the following order. 2. At the target database the Import tool will copy the data from dump file to the target database. views. When you export tables from source database export tool will extracts the tables and puts it into the dump file. 3. This dump file is transferred to the target database. Type definitions Table definitions Table data Table indexes Integrity constraints. To see how many active Transactions are there and to see undo segment information give the following command SQL>select * from v$transaction. which are enhanced versions of original Export and Import tools. and/or domain indexes are built. and Import tool to load data into the target database. function-based. and any bitmap. You Export tool to export data from source database. new tables are created. and triggers Bitmap.To view statistics for tuning undo tablespace query the following dictionary SQL>select * from v$undostat. function-based. Export and Import These tools are used to transfer data from one oracle database to another oracle database. 10g Oracle is recommending to use Data Pump Export and Import tools. From Ver. 6. triggers are imported.

If you supply command line arguments when calling exp or imp then it will run in command line mode Command Line Parameters of Export tool You can control how Export runs by entering the EXP command followed by various arguments. you use keywords: Format: EXP KEYWORD=value or KEYWORD=(value1.. these tools will prompt you for all the necessary input.valueN) Example: EXP SCOTT/TIGER GRANTS=Y TABLES=(EMP..DEPT.value2..MGR) or TABLES=(T1:P1. if T1 is partitioned table Keyword Description (Default) -------------------------------------------------------------USERID BUFFER FILE COMPRESS GRANTS INDEXES DIRECT LOG ROWS CONSISTENT FULL username/password size of data buffer output files (EXPDAT. To specify parameters.DMP) import into one extent (Y) export grants (Y) export indexes (Y) direct path (N) log file of screen output export data rows (Y) cross-table consistency(N) export entire file (N) .T1:P2).e.You can run Export and Import tool in two modes Command Line Mode Interactive Mode When you just type exp or imp at o/s prompt it will run in interactive mode i..

export (Y) export triggers (Y) analyze objects (ESTIMATE) parameter filename export constraints (Y) transaction set to read only during object export (N) CONSTRAINTS OBJECT_CONSISTENT FEEDBACK FILESIZE FLASHBACK_SCN FLASHBACK_TIME QUERY RESUMABLE RESUMABLE_NAME display progress every x rows (0) maximum size of each dump file SCN used to set session snapshot back to time used to get the SCN closest to the specified time select clause used to export a subset of a table suspend when a space related error is encountered(N) text string used to identify resumable statement RESUMABLE_TIMEOUT wait time for RESUMABLE TTS_FULL_CHECK TABLESPACES perform full or partial dependency check for TTS list of tablespaces to export export transportable tablespace metadata (N) TRANSPORT_TABLESPACE TEMPLATE template name which invokes iAS mode export The Export and Import tools support four modes of operation .OWNER TABLES list of owner usernames list of table names RECORDLENGTH length of IO record INCTYPE RECORD TRIGGERS STATISTICS PARFILE incremental export type track incr.

to perform full export the user should have DBA or EXP_FULL_DATABASE privilege. USERID option specifies the user account to connect to the database.scott. Exporting Consistent Image of the tables If you include CONSISTENT=Y option in export command argument then.sales) FILE=exp_tab. Example of Exporting Schemas To export Objects stored in a particular schemas you can run export utility with the following arguments $exp USERID=scott/tiger OWNER=(SCOTT. FILE option specifies the name of the dump file. Import utility can run in Interactive mode or command line mode. .ALI) FILE=exp_own.e. Export utility will export a consistent image of the table i.dmp In the above command. the changes which are done to the table during export operation will not be exported. Example of Exporting Full Database The following example shows how to export full database $exp USERID=scott/tiger FULL=y FILE=myfull. FULL option specifies that you want to export the full database. Note.dmp This will export scott‘s emp and sales tables.dmp The above command will export all the objects stored in SCOTT and ALI‘s schema.emp. Using Import Utility Objects exported by export utility can only be imported by Import utility.FULL :Exports all the objects in all schemas OWNER :Exports objects only belonging to the given OWNER TABLES :Exports Individual Tables TABLESPACE :Export all objects located in a given TABLESPACE. Exporting Individual Tables To export individual tables give the following command $exp USERID=scott/tiger TABLES=(scott.

You can let Import prompt you for parameters by entering the IMP command followed by your username/password: Example: IMP SCOTT/TIGER Or.valueN) Example: IMP SCOTT/TIGER IGNORE=Y TABLES=(EMP. if T1 is partitioned table USERID must be the first parameter on the command line...T1:P2).value2. To specify parameters. you use keywords: Format: IMP KEYWORD=value or KEYWORD=(value1.DEPT) FULL=N or TABLES=(T1:P1. Keyword USERID BUFFER FILE SHOW IGNORE GRANTS INDEXES ROWS LOG FULL FROMUSER TOUSER TABLES RECORDLENGTH INCTYPE COMMIT PARFILE CONSTRAINTS DESTROY INDEXFILE SKIP_UNUSABLE_INDEXES FEEDBACK TOID_NOVALIDATE FILESIZE STATISTICS Description (Default) username/password size of data buffer input files (EXPDAT. you can control how Import runs by entering the IMP command followed by various arguments...DMP) just list file contents (N) ignore create errors (N) import grants (Y) import indexes (Y) import data rows (Y) log file of screen output import entire file (N) list of owner usernames list of usernames list of table names length of IO record incremental import type commit array insert (N) parameter filename import constraints (Y) overwrite tablespace data file (N) write table/index info to specified file skip maintenance of unusable indexes (N) display progress every x rows(0) skip validation of specified type ids maximum size of each dump file import precomputed statistics (always) .

dmp.dmp FROMUSER=ali TOUSER=scott Then import utility will give a warning that tables in the dump file was exported by user Ali and not you and then proceed.dmp FROMUSER=scott TABLES=(emp. . suppose Ali has exported tables into a dump file mytables. importing SCOTT's objects into SCOTT . and functions (Y) import streams general metadata (Y) import streams instantiation metadata (N) Example Importing Individual Tables To import individual tables from a full database export dump file give the following command $imp scott/tiger FILE=myfullexp.00 via conventional path import done in WE8DEC character set and AL16UTF16 NCHAR character set .00. . dept tables into Scott user and you will get a output similar to as shown below Export file created by EXPORT:V10.dmp FROMUSER=scott . To do so.dept) This command will import only emp. importing table "DEPT" "EMP" 4 rows imported 14 rows imported Import terminated successfully without warnings. For example. use ―%‖ wild character in TABLES option. Now Scott wants to import these tables. Importing Tables of One User account into another User account For example. importing table . Example. packages. the following command will import all tables whose names starts with alphabet ―e‖ and those tables whose name contains alphabet ―d‖ $imp scott/tiger FILE=myfullexp.RESUMABLE RESUMABLE_NAME RESUMABLE_TIMEOUT COMPILE STREAMS_CONFIGURATION STREAMS_INSTANITATION suspend when a space related error is encountered(N) text string used to identify resumable statement wait time for RESUMABLE compile procedures. Example Importing Tables Using Pattern Matching Suppose you want to import all tables from a dump file whose name matches a particular pattern. To achieve this Scott will give the following import command $imp scott/tiger FILE=mytables.

issue the following SQL query to get the exact name of all tablespaces. Move the dump file to the target database server. 6. 2. 4. using the information obtained in Step 1. for example: > exp system/manager FULL=y FILE=myfullexp. which may not be compatible with the file structure on the target system. Create a database on the target server.%d%) Migrating a Database across platforms. If you use FTP. Before importing the dump file. The following steps present a general overview of how to move a database between platforms.dmp Using IGNORE=y instructs Oracle to ignore any creation errors during the import and permit the import to complete. As a DBA user. the import will create the corresponding datafiles in the same file structure as at the source database.dmp 3. Perform a full backup of your new database . perform a full import with the IGNORE parameter enabled: > imp system/manager FULL=y IGNORE=y FILE=myfullexp. 7. you must first create your tablespaces. Otherwise. 5. This includes moving between UNIX and NT systems and also moving between two NT systems running on different platforms. As a DBA user. be sure to copy it in binary format (by entering binary at the FTP prompt) to avoid file corruption.TABLES=(a%. The Export and Import utilities are the only method that Oracle supports for moving an existing Oracle database from one hardware platform to another. You will need this information later in the process. 1. perform a full export from the source database. SQL> SELECT tablespace_name FROM dba_tablespaces. As a DBA user.

Data Pump is similar to EXPORT and IMPORT utility but it has many advantages. all the dump files are created in the server even if you run the Data Pump utility from client machine. Now grant access on this directory object to SCOTT user SQL> grant read. Oracle has introduced an enhanced version of EXPORT and IMPORT utility known as DATA PUMP. i.write on directory data_pump_dir to scott. The following example creates a directory in the filesystem and creates a directory object in the database and grants privileges on the Directory Object to the SCOTT user. DBA has to create a directory in Server Machine and create a Directory Object in the database mapping to the directory created in the file system.e. This results in increased performance because data is not transferred through network. without actually performing the export Support for an interactive-command mode that allows monitoring of and interaction with ongoing jobs     Using Data Pump Export Utility To Use Data Pump. . The ability to detach from and reattach to long-running jobs without affecting the job itself. This allows DBAs and other operations personnel to monitor jobs from multiple locations. Some of the advantages are:  Most Data Pump export and import operations occur on the Oracle database server. You can Stop and Re-Start export and import jobs. $mkdir my_dump_dir $sqlplus Enter User:/ as sysdba SQL>create directory data_pump_dir as ‘/u01/oracle/my_dump_dir’.DATA PUMP Utility Starting with Oracle 10g. The ability to estimate how much space an export job would consume. This is particularly useful if you have started an export or import job and after some time you want to do some other urgent work.

ALI Exporting Individual Tables using Data Pump Export You can use Data Pump Export utility to export individual tables.dmp FILESIZE=5G LOGFILE=myfullexp. The following example shows the syntax to export tables $expdp hr/hr DIRECTORY=dpump_dir1 DUMPFILE=tables.log JOB_NAME=myfullJob This will create multiple dump files named full01.Example of Exporting a Full Database To Export Full Database.dmp.dmp . and hence export will fail. In this situation you can create multiple dump files by typing the following command $expdp scott/tiger FULL=y DIRECTORY=data_pump_dir DUMPFILE=full%U. Example of Exporting a Schema To export all the objects of SCOTT‘S schema you can run the following export data pump command. If you want to export objects of multiple schemas you can specify the following command $expdp scott/tiger DIRECTORY=data_pump_dir DUMPFILE=scott_schema. full03.dmp. $expdp scott/tiger DIRECTORY=data_pump_dir DUMPFILE=scott_schema.HR.dmp SCHEMAS=SCOTT You can omit SCHEMAS since the default mode of Data Pump export is SCHEMAS only. The FILESIZE parameter specifies how much larger the dump file should be.dmp SCHEMAS=SCOTT.dmp in the directory on the server /u01/oracle/my_dump_dir In some cases where the Database is in Terabytes the above command will not feasible since the dump file size will be larger than the operating system limit.dmp LOGFILE=myfullexp. full02.log JOB_NAME=myfullJob The above command will export the full database and it will create the dump file full.dmp and so on. give the following command $expdp scott/tiger FULL=y DIRECTORY=data_pump_dir DUMPFILE=full.

For example you are exporting a schema and don‘t want to export tables whose name starts with ―A‖ then you can type the following command $expdp scott/tiger DIRECTORY=data_pump_dir DUMPFILE=scott_schema. GRANTS.dmp TABLESPACES=tbs_4. CONSTRAINTS. SCHEMA Using Query to Filter Rows during Export You can use QUERY option to export only required rows. For Example. tbs_6 The above will export all the objects located in tbs_4.tbs_5. expdp hr/hr QUERY=emp:'"WHERE dept_id > 10 AND sal > 10000"' NOLOGFILE=y DIRECTORY=dpump_dir1 DUMPFILE=exp1.departments Exporting Tables located in a Tablespace If you want to export tables located in a particular tablespace you can type the following command $expdp hr/hr DIRECTORY=dpump_dir1 DUMPFILE=tbs.e. Similarly you can also INCLUDE option to only export certain objects like this $expdp scott/tiger DIRECTORY=data_pump_dir DUMPFILE=scott_schema. tbs_5.dmp .jobs.dmp SCHEMAS=SCOTT EXCLUDE=TABLE:”like ‘A%’” Then all tables in Scott‘s Schema whose name starts with ―A ― will not be exported. USER.tbs_6 Excluding and Including Objects during Export You can exclude objects while performing a export by using EXCLUDE option of Data Pump utility.dmp SCHEMAS=SCOTT INCLUDE=TABLE:”like ‘A%’” This is opposite of EXCLUDE option i.TABLES=employees. it will export only those tables of Scott‘s schema whose name starts with ―A‖ Similarly you can also exclude INDEXES. the following will export only those rows of employees tables whose salary is above 10000 and whose dept id is 10.

After finishing his other work. you can suspend it. .log JOB_NAME=myfullJob After some time. or you can restart the job from another client machine. Export> CONTINUE_CLIENT A message is displayed that the job has been reopened.dmp LOGFILE=myfullexp. if because of some work. So now the DBA will go to another client machine and he reattach to the job by typing the following command $expdp hr/hr@mydb ATTACH=myfulljob After the job status is displayed. the user has locked his/her cabin. For Example. where you stopped the job. Then he presses CTRL+C to enter into interactive mode. the DBA wants to resume the export job and the client machine from where he actually started the job is locked because. You can start a job in one client machine and then. the DBA wants to stop this job temporarily. if he doesn‘t want to continue with the export job. suppose a DBA starts a full database export by typing the following command at one client machine CLNT1 by typing the following command $expdp scott/tiger@mydb FULL=y DIRECTORY=data_pump_dir DUMPFILE=full. he can issue the CONTINUE_CLIENT command to resume logging mode and restart the myfulljob job. Note: After reattaching to the Job a DBA can also kill the job by typing KILL_JOB. Afterwards when your work has been finished you can continue the job from the same client.Suspending and Resuming Export Jobs (Attaching and Re-Attaching to the Jobs) You can suspend running export jobs and later on resume these jobs or kill these jobs using Data Pump Export. and processing status is output to the client. Then he will get the Export> prompt where he can type interactive commands Now he wants to stop this export job so he will type the following command Export> STOP_JOB=IMMEDIATE Are you sure you wish to stop this job ([y]/n): y The job is placed in a stopped state and exits the client.

The pseudocolumns available are VERSIONS_XID VERSIONS_OPERATION VERSIONS_STARTSCN created VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME :Identifier of the transaction that created the row version :Operation Performed. The Flashback Version Query returns a table with a row for each version of the row that existed at any time during the time interval you specify.Flash Back Features From Oracle Ver. :Timestamp when the row version expired . After 1 hour he realizes that delete statement is mistakenly performed. Flashback feature depends upon on how much undo retention time you have specified. 9i Oracle has introduced Flashback Query feature. I for Insert. D for Delete :Starting System Change Number when the row version was :Starting System Change Time when the row version was created :SCN when the row version expired. Flashback Query SQL>select * from emp as of timestamp sysdate-1/24. A new row version is created whenever a COMMIT statement is executed. Oracle will not overwrite the data in undo tablespace even after committing until 2 Hours have passed. Users can recover from their mistakes made since last 2 hours only. For example. Or SQL> SELECT * FROM emp AS OF TIMESTAMP TO_TIMESTAMP('2007-06-07 10:00:00'. For example. suppose a user accidently deletes rows from a table and commits it also then. 'YYYY-MM-DD HH:MI:SS') To insert the accidently deleted rows again in the table he can type SQL> insert into emp (select * from emp as of timestamp sysdate1/24) Using Flashback Version Query You use a Flashback Version Query to retrieve the different versions of specific rows that existed during a given time interval. OF query to get back the deleted rows like this.. U for Update. Now he can give a flashback AS. It is useful to recover from accidental statement failures. Each row in the table includes pseudocolumns of metadata about the row version. using flash back query he can get back the rows. If you have set the UNDO_RETENTION parameter to 2 hours then. suppose John gives a delete statement at 10 AM and commits it.

The DBA issues the following query to retrieve versions of the rows in the emp table that correspond to empno 101. At this time emp table has one version of one row.’Sami’.sal from emp versions between timestamp to_timestamp(‘2007-06-19 20:30:00’.’yyyy-mm-dd hh:mi:ss’) . Subsequently.2)).name varchar2(20).’YYYY-MM-DD HH:MI:SS’) from dual. SQL> Create table emp (empno number(5). The query uses Flashback Version Query pseudocolumns SQL> SQL> SQL> SQL> Connect / as sysdba column versions_starttime format a16 column versions_endtime format a16 set linesize 120. Now a user sitting at another machine erroneously changes the Salary from 5000 to 2000 using Update statement SQL> update emp set sal=sal-3000 where empno=101.5000).To understand let‘s see the following example Before Starting this example let‘s us collect the Timestamp SQL> select to_char(SYSTIMESTAMP. SQL>commit. SQL> commit.versions_endtime. versions_operation. the DBA detects the application error and needs to diagnose the problem. SQL>update emp set name=’Smith’ where empno=101.’YYYYY --------------------------2007-06-19 20:30:43 Suppose a user creates a emp table and inserts a row into it and commits the row.empno. SQL> select versions_xid. SQL> commit. At this point.sal number(10. TO_CHAR(SYSTIMESTAMP.versions_starttime. SQL> insert into emp values (101. a new transaction updates the name of the employee from Sami to Smith.name.

---SMITH 2000 SAMI 2000 SAMI 5000 The Output should be read from bottom to top.---------. You can only flash back tables up to the retention time you specified. easily.’yyyy-mm-dd hh:mi:ss’).and to_timestamp(‘2007-06-19 21:00:00’. Flashback Table uses information in the undo tablespace to restore the table. OPERATION LOGON_USER UNDO_SQL --------. from the output we can see that an Insert has taken place and then erroneous update has taken place and then again update has taken place to change the name. In many cases. Oracle Flashback Table provides the DBA the ability to recover a table or set of tables to a specified point in time in the past very quickly. and without taking any part of the database offline. Flashback Table eliminates the need to perform more complicated point-in-time recovery operations. Therefore. . VERSION_XID ----------0200100020D 02001003C02 0002302C03A V U U I STARTSCN -------11323 11345 12320 ENDSCN -----EMPNO ----101 101 101 NAME SAL -------.logon_user.undo_sql from flashback_transaction_query where xid=HEXTORAW(’02001003C02’).--------------------------------------U SCOTT update emp set sal=5000 where ROWID = 'AAAKD2AABAAAJ29AAA' Now DBA can execute the command to undo the changes made by the user SQL> update emp set sal=5000 where ROWID ='AAAKD2AABAAAJ29AAA' 1 row updated Using Flashback Table to return Table to Past States. The DBA identifies the transaction 02001003C02 as erroneous and issues the following query to get the SQL command to undo the change SQL> select operation. UNDO_RETENTION parameter is significant in Flashing Back Tables to a past state.

'YYYY-MM-DD HH:MI:SS') ENABLE TRIGGERS. by default all database triggers on the table will be disabled. She uses Flashback Table to return the table to its state at 14:00. `YYYY-MM-DD HH24:MI:SS'). Someone accidentally deleted the record for "JOHN" between 14:00 and the present time. Recovering Drop Tables (Undo Drop Table) In Oracle Ver.Row movement must be enabled on the table for which you are issuing the FLASHBACK TABLE statement. This employee was present at 14:00. whatever tables you drop the database does not immediately remove the space used by table. Table Dropped . as shown in this example: FLASHBACK TABLE EMPLOYEES TO TIMESTAMP TO_TIMESTAMP('2007-06-21 14:00:00'. the table is renamed and placed in Recycle Bin. 10g Oracle introduced the concept of Recycle Bin i. You have to give ENABLE TRIGGERS option otherwise. suppose a user accidently drops emp table SQL>drop table emp. the last time she ran a report. Example:At 17:00 an HR administrator discovers that an employee "JOHN" is missing from the EMPLOYEE table. The FLASHBACK TABLE…BEFORE DROP command will restore the table. The emp table is restored to its state when the database was at the time specified by the timestamp. You can enable row movement with the following SQL statement: ALTER TABLE table ENABLE ROW MOVEMENT.e. This feature is not dependent on UNDO TABLESPACE so UNDO_RETENTION parameter has no impact on this feature. For Example. The following example performs a FLASHBACK TABLE operation the table emp FLASHBACK TABLE emp TO TIMESTAMP TO_TIMESTAMP('2007-06-19 09:30:00'. Instead.

Purging Objects from Recycle Bin If you want to recover the space used by a dropped table give the following command SQL> purge table emp.Now for user it appears that table is dropped but it is actually renamed and placed in Recycle Bin. . regardless of which user owns the objects. Permanently Dropping Tables If you want to permanently drop tables without putting it into Recycle Bin drop tables with purge command like this SQL> drop table emp purge. You can also restore the dropped table by giving it a different name like this SQL> Flashback table emp to before drop rename to emp2. You can also purge only objects from a tablespace belonging to a specific user. To recover this dropped table a user can type the command SQL> Flashback table emp to before drop. To view the contents of Recycle Bin give the following command SQL> show recycle bin. using this command: SQL>PURGE DBA_RECYCLEBIN. then you can purge all objects from the recycle bin. If you have the SYSDBA privilege. using the following form of the command: SQL>PURGE TABLESPACE hr USER scott. If you want to recover space for dropped object of a particular tablespace give the command SQL> purge tablespace hr. This will drop the table permanently and it cannot be restored. If you want to purge objects of logon user give the following command SQL> purge recycle bin.

FLASHBACK TABLE EMP TO BEFORE DROP RENAME TO EMP_VER_1. a dropped object may remain in the recycle bin for seconds. # EMP version 3 DROP TABLE EMP. each table EMP is assigned a unique name in the recycle bin when it is dropped. or for months.columns ).. Oracle might empty recycle bin whenever Space Pressure occurs i. A table and all of its dependent objects (indexes. when you drop the table.. oracle will delete objects from recycle bin 2. Likewise. For example. # EMP version 2 DROP TABLE EMP. TO BEFORE DROP statement with the original name of the table.. as shown in this example: FLASHBACK TABLE EMP TO BEFORE DROP. and no guarantee as to how long dropped objects remain in the recycle bin. triggers. There is no fixed amount of space allocated to the recycle bin. and they will all be stored in the recycle bin. 3. the objects are generally all retrieved together. You can use a FLASHBACK TABLE. consider these SQL statements: CREATE TABLE EMP ( .. whenever tablespace becomes full and transaction requires new extents then. nested tables.columns ). CREATE TABLE EMP ( . The most recently dropped table with that original name is retrieved from the recycle bin. LOB segments. with each assigned a new name: FLASHBACK TABLE EMP TO BEFORE DROP RENAME TO EMP_VER_3. . and then drop. CREATE TABLE EMP ( .. constraints and so on) go into the recycle bin together. Depending upon system activity.. when you perform Flashback Drop. There is no guarantee that objects will remain in Recycle Bin.e. In such a case. with its original name... Important Points: 1. You can retrieve it and assign it a new name using a RENAME TO clause.columns ). # EMP version 1 DROP TABLE EMP. FLASHBACK TABLE EMP TO BEFORE DROP RENAME TO EMP_VER_2.Flashback Drop of Multiple Objects With the Same Original Name You can create. The following example shows the retrieval from the recycle bin of all three dropped EMP tables from the previous example. several objects with the same original name.

To determine the earliest SCN and earliest Time you can Flashback your database. Now enable the flashback database by giving the following command SQL>alter database flashback on. to specify how far back into the past you want to be able to restore your database with Flashback Database. How far you can flashback database. Once you set these parameters. After you have enabled the Flashback Database feature and allowed the database to generate some flashback logs. you set up a flash recovery area. Step 3. lets you quickly recover the entire database from logical data corruptions or user errors. Shutdown the database if it is already running and set the following parameters DB_RECOVERY_FILE_DEST=/d01/ica/flasharea DB_RECOVERY_FILE_DEST_SIZE=10G DB_FLASHBACK_RETENTION_TARGET=4320 (Note: the db_flashback_retention_target is specified in minutes here we have specified 3 days i. Now Oracle start writing Flashback logs to recovery area. Start the instance and mount the Database. To how much size we should set the flash recovery area. Enabling Flash Back Database Step 1. and set a flashback retention target. at regular intervals. This will show how much size the recovery area should be set to. the database copies images of each altered block in every datafile into flashback logs stored in the flash recovery area.Flashback Database: Alternative to Point-In-Time Recovery Oracle Flashback Database. From that time on. SQL>startup mount. run the following query: SQL> SELECT ESTIMATED_FLASHBACK_SIZE FROM V$FLASHBACK_DATABASE_LOG. 3x24x60=4320) Step 2.e. give the following query: . To enable Flashback Database. These Flashback logs are use to flashback database to a point in time.

When the Flashback Database operation completes. or perform FLASHBACK DATABASE again with an SCN further in the past. RMAN> SQL 'ALTER DATABASE OPEN READ ONLY'. or. Example: Flashing Back Database to a point in time Suppose. Run the FLASHBACK DATABASE command to return the database to 9:59AM by typing the following command RMAN> FLASHBACK DATABASE TO TIME timestamp('2007-06-21 09:59:00'). you can also type this command.SELECT OLDEST_FLASHBACK_SCN. Option 2:If you discover that you have chosen the wrong target time for your Flashback Database operation. Start RMAN $rman target / 2. You can completely undo the effects of your flashback operation by performing complete recovery of the database: RMAN> RECOVER DATABASE. You as a DBA came to know of this at 5PM. you can evaluate the results by opening the database read-only and run some queries to check whether your Flashback Database has returned the database to the desired state. At this time. you can use RECOVER DATABASE UNTIL to bring the database forward. you have several options Option 1:If you are content with your result you can open the database by performing ALTER DATABASE OPEN RESETLOGS SQL>ALTER DATABASE OPEN RESETLOGS. 3. you can flashback the database to 9:50AM by following the given procedure 1. . RMAN> FLASHBACK DATABASE TO TIME (SYSDATE-8/24). a user erroneously drops a schema at 10:00AM. Now since you have configured the flashback area and set up the flashback retention time to 3 Days. OLDEST_FLASHBACK_TIME FROM V$FLASHBACK_DATABASE_LOG.

LogMiner uses the dictionary to translate internal object identifiers and datatypes to object names and external data formats. 6. the LogMiner dictionary. LogMiner returns internal object IDs and presents data as binary data. Because LogMiner provides a well-defined. then perform a logical export of the data using an Oracle export utility. then run RECOVER DATABASE to return the database to the present time and re-import the data using the Oracle import utility 4. After database is recovered shutdown and restart the database in normal mode and import the schema by running IMPORT utility $imp userid=system/manager file=scott. Since in our example only a schema is dropped and the rest of database is good. Now Start RMAN and recover database to the present time $rman target / RMAN> RECOVER DATABASE. come out of RMAN and run EXPORT utility to export the whole schema $exp userid=system/manager file=scott. and the redo log files containing the data of interest:   The source database is the database that produces all the redo log files that you want LogMiner to analyze. Without a dictionary. Now. you can query the contents of online redo log files and archived log files.dmp Log Miner Using Log Miner utility. The LogMiner dictionary allows LogMiner to provide table and column names. LogMiner Configuration There are three basic objects in a LogMiner configuration that you should be familiar with: the source database. when it presents the redo log data that you request. it can be used as a powerful data audit tool. easy-to-use.Option 3:If you only want to retrieve some lost data from the past time. third option is relevant for us. you can open the database read-only. instead of internal object IDs.dmp owner=SCOTT 5. and comprehensive relational interface to redo log files. as well as a tool for sophisticated data analysis. .

LogMiner will display: insert into "UNKNOWN". MIN_SALARY. MAX_SALARY) VALUES('IT_WT'. consider the following the SQL statement: INSERT INTO HR. Oracle recommends that you use either the online catalog or extract the dictionary from redo log files instead. Using the Online Catalog To direct LogMiner to use the dictionary currently in use for the database.HEXTORAW('c3020b')). Without the dictionary.'Technical Writer'.  Extracting the LogMiner Dictionary to a Flat File This option is maintained for backward compatibility with previous releases."OBJ# 45522"("COL 1". specify the online catalog as your dictionary source when you start LogMiner. 11000).HEXTORAW('546563686e6963616c20577269746572').  The redo log files contain the changes made to the database or database dictionary. This is the most efficient and easy-to-use option."COL 4") values (HEXTORAW('45465f4748'). LogMiner gives you three options for supplying the dictionary:  Using the Online Catalog Oracle recommends that you use this option when you will have access to the source database from which the redo log files were created and when no changes to the column definitions in the tables of interest are anticipated."COL 2". as follows: SQL> EXECUTE DBMS_LOGMNR. HEXTORAW('c229').For example. 4000. or if you anticipate that changes will be made to the column definitions in the tables of interest."COL 3".JOBS(JOB_ID. LogMiner Dictionary Options LogMiner requires a dictionary to translate object IDs into object names when it returns redo data to you. JOB_TITLE. This option does not guarantee transactional consistency.START_LOGMNR(- .  Extracting a LogMiner Dictionary to the Redo Log Files Oracle recommends that you use this option when you do not expect to have access to the source database from which the redo log files were created.

STORE_IN_REDO_LOGS).BUILD procedure with the STORE_IN_REDO_LOGS option. 1. To extract dictionary information to the redo log files. enter the following in the initialization parameter file: UTL_FILE_DIR = /oracle/database 2.ora in /oracle/database: SQL> EXECUTE DBMS_LOGMNR_D. .DICT_FROM_ONLINE_CATALOG).STORE_IN_FLAT_FILE).BUILD. no DDL statements can be executed. For example. in the initialization parameter file. Execute the PL/SQL procedure DBMS_LOGMNR_D. This procedure creates the dictionary file. Start the Database SQL> startup 3. DBMS_LOGMNR_D. Extracting the LogMiner Dictionary to a Flat File When the LogMiner dictionary is in a flat file. use the DBMS_LOGMNR_D. Do not specify a filename or location.BUILD('dictionary. UTL_FILE_DIR. For example. While the dictionary is being extracted to the redo log stream. the dictionary extracted to the redo log files is guaranteed to be consistent (whereas the dictionary extracted to a flat file is not).BUILD(OPTIONS=> DBMS_LOGMNR_D. Oracle recommends that you regularly back up the dictionary extract to ensure correct analysis of older redo log files. SQL> EXECUTE DBMS_LOGMNR_D. Redo Log File Options To mine data in the redo log files. fewer system resources are used than when it is contained in the redo log files.OPTIONS => DBMS_LOGMNR.'/oracle/database/'. Extracting a LogMiner Dictionary to the Redo Log Files To extract a LogMiner dictionary to the redo log files. Set the initialization parameter. Therefore. LogMiner needs information about which redo log files to mine. Specify a filename for the dictionary and a directory path name for the file. enter the following to create the file dictionary.ora'. the database must be open and in ARCHIVELOG mode and archiving must be enabled. to set UTL_FILE_DIR to use /oracle/database as the directory where the dictionary file is placed.

ora'. This example shows how to do the simplest analysis using LogMiner.ADD_LOGFILE procedure to manually create a list of redo log files before you start LogMiner. SQL> EXECUTE DBMS_LOGMNR. as follows: Automatically If LogMiner is being used on the source database. When using this method. OPTIONS => DBMS_LOGMNR. OPTIONS => DBMS_LOGMNR. LogMiner need not be connected to the source database.START_LOGMNR( .You can direct LogMiner to automatically and dynamically create a list of redo log files to analyze. then you can direct LogMiner to find and create a list of redo log files for analysis automatically. Step 2 Start LogMiner. Use the CONTINUOUS_MINE option when you start LogMiner. Example: Finding All Modifications in the Current Redo Log File The easiest way to examine the modification history of a database is to mine at the source database and use the online catalog to translate the redo log files.NEW). SQL> EXECUTE DBMS_LOGMNR. Specify the redo log files which you want to analyze. Start LogMiner and specify the dictionary to use. SQL> EXECUTE DBMS_LOGMNR.ADDFILE). Manually Use the DBMS_LOGMNR. or you can explicitly specify a list of redo log files for LogMiner to analyze. After the first redo log file has been added to the list. each subsequently added redo log file must be from the same database and associated with the same database RESETLOGS SCN.ADD_LOGFILE( LOGFILENAME => '/u01/oracle/ica/log2.ora'.ADD_LOGFILE( LOGFILENAME => '/usr/oracle/ica/log1. Step 1 Specify the list of redo log files to be analyzed.

'1234567890'."SALARY". "PHONE_NUMBER". update "OE".11.1476 1. 'dd-mon-yyyy hh24:mi:ss') and "JOB_ID" ='105' and "DEPARTMENT_ID" = '50' and ROWID = 'AAAHSkAABAAAY6rAAP'.05'.1484 OE 1."PRODUCT_INFORMATION" set "WARRANTY_PERIOD" = TO_YMINTERVAL('+01-00') where "PRODUCT_ID" = '1799' and "WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00') and ROWID = 'AAAHTKAABAAAY9mAAB'."MANAGER_ID"."EMAIL". TO_DATE('10-jan-2003 13:41:03'."EMAIL".11. "LAST_NAME". "DEPARTMENT_ID") values ('307'.05' and "DEPARTMENT_ID" = '10' and ROWID = 'AAAHSkAABAAAY6rAAO'.1484 HR 1.1.1. SQL> SELECT username AS USR.1484 1. update "OE". "LAST_NAME".1. set transaction read write.'Mohammed'.1476 . update "OE". (XIDUSN || '."PRODUCT_INFORMATION" set "WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00') where "PRODUCT_ID" = '1801' and "WARRANTY_PERIOD" = TO_YMINTERVAL('+01-00') and ROWID = 'AAAHTKAABAAAY9mAAC'.1. "JOB_ID". '. OE OE 1."FIRST_NAME".1484 commit. "COMMISSION_PCT". 'JSILVER'.'Silver'.DICT_FROM_ONLINE_CATALOG).' || XIDSQN) AS XID. "JOB_ID"."EMPLOYEES"( "EMPLOYEE_ID".'50').' || XIDSLT || '. USR ---HR HR XID --------1."PRODUCT_INFORMATION" set "WARRANTY_PERIOD" = TO_YMINTERVAL('+01-00') where "PRODUCT_ID" = '1801' and "WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00') and ROWID ='AAAHTKAABAAAY9mAAC'. '105'. insert into "HR". 'dd-mon-yyyy hh24:mi:ss') and "JOB_ID" = 'HR_REP' and "SALARY" = '120000' and "COMMISSION_PCT" = '.SQL_REDO."HIRE_DATE". '105'. 'dd-mon-yyyy hh24:mi:ss')."MANAGER_ID". delete from "HR".'120000'. "DEPARTMENT_ID") values ('306'. delete from "HR". Note that there are four transactions (two of them were committed within the redo log file being analyzed. 'HR_REP'."FIRST_NAME".'Sami'. insert into "HR".'10').11.OPTIONS => DBMS_LOGMNR. 'MDSAMI'. and two were not). 'SH_CLERK'. 'OE'). Step 3 Query the V$LOGMNR_CONTENTS view.'John'."SALARY". TO_DATE('10-jan-2003 13:34:43'.1476 SQL_REDO SQL_UNDO ---------------------------------------------------set transaction read write. update "OE"."EMPLOYEES" "EMPLOYEE_ID" = '307' and "FIRST_NAME" = 'John' and "LAST_NAME" = 'Silver' and "EMAIL" = 'JSILVER' and "PHONE_NUMBER" = '5551112222' and "HIRE_DATE" = TO_DATE('10-jan2003 13:41:03'. SQL_UNDO FROM V$LOGMNR_CONTENTS WHERE username IN ('HR'.05'. "PHONE_NUMBER". '. 'dd-mon-yyyy hh24:mi:ss').'110000'."PRODUCT_INFORMATION" set "WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00') where "PRODUCT_ID" = '1799' and "WARRANTY_PERIOD" = TO_YMINTERVAL('+01-00') and ROWID = 'AAAHTKAABAAAY9mAAB'."EMPLOYEES"( "EMPLOYEE_ID". '5551112222'. "COMMISSION_PCT"."HIRE_DATE". The output shows the DML statements in the order in which they were executed. thus transactions interleave among themselves."EMPLOYEES" where "EMPLOYEE_ID" = '306' and "FIRST_NAME" = 'Mohammed' and "LAST_NAME" = 'Sami' and "EMAIL" = 'MDSAMI' and "PHONE_NUMBER" = '1234567890' and "HIRE_DATE" = TO_DATE('10-JAN-2003 13:34:43'. OE 1.

123.11.15."EMAIL". FIRST_TIME FROM V$ARCHIVED_LOG WHERE SEQUENCE# = (SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG . use the DBMS_LOGMNR. insert into "HR".'12000'.NULL.CONTINUOUS_MINE option to the DBMS_LOGMNR.8080'. set transaction read write.1481 set transaction read write. 'dd-mon-yyyy hh24:mi:ss').123. "COMMISSION_PCT".8.'Shelley'. Example of Mining Without Specifying the List of Redo Log Files Explicitly The previous example explicitly specified the redo log file or files to be mined. To mine a set of redo log files without explicitly specifying them.1484 1. if you are mining in the same database that generated the redo log files."MANAGER_ID". Example : Mining Redo Log Files in a Given Time Range This example assumes that you want to use the data dictionary extracted to the redo log files. SQL> EXECUTE DBMS_LOGMNR.'Higgins'."FIRST_NAME". 'dd-mon-yyyy hh24:mi:ss') and "JOB_ID" = 'AC_MGR' and "SALARY"= '12000' and "COMMISSION_PCT" IS NULL and "MANAGER_ID" = '101' and "DEPARTMENT_ID" = '110' and ROWID = 'AAAHSkAABAAAY6rAAM'. then you can mine the appropriate list of redo log files by just specifying the time (or SCN) range of interest. Step 1 Determine the timestamp of the redo log file that contains the start of the data dictionary. commit.15.'101'. update "OE". and specify either a time range or an SCN range of interest. update "OE".8080' and "HIRE_DATE" = TO_DATE( '07-jun-1994 10:05:01'."SALARY"."EMPLOYEES" where "EMPLOYEE_ID" = '205' and "FIRST_NAME" = 'Shelley' and "LAST_NAME" = 'Higgins' and "EMAIL" = 'SHIGGINS' and "PHONE_NUMBER" = '515.END_LOGMNR().8. TO_DATE('07-jun-1994 10:05:01'.'110').1484 HR 1.1476 Step 4 End the LogMiner session. "HIRE_DATE". OE OE 1. delete from "HR".HR HR 1. "DEPARTMENT_ID") values ('205'.'515. 'AC_MGR'."PRODUCT_INFORMATION" set "WARRANTY_PERIOD" = TO_YMINTERVAL('+12-06') where "PRODUCT_ID" = '2350' and "WARRANTY_PERIOD" = TO_YMINTERVAL('+20-00') and ROWID = 'AAAHTKAABAAAY9tAAD'.START_LOGMNR procedure. SQL> SELECT NAME."EMPLOYEES"( "EMPLOYEE_ID". However. "JOB_ID"."PRODUCT_INFORMATION" set "WARRANTY_PERIOD" = TO_YMINTERVAL('+20-00') where "PRODUCT_ID" = '2350' and "WARRANTY_PERIOD" = TO_YMINTERVAL('+20-00') and ROWID ='AAAHTKAABAAAY9tAAD'.1481 1. "LAST_NAME"."PHONE_NUMBER". and 'SHIGGINS'.

PRINT_PRETTY_SQL. . ENDTIME => SYSDATE.dbf /usr/oracle/data/db1arch_1_208_482701534. and CONTINUOUS_MINE options.COMMITTED_DATA_ONLY + DBMS_LOGMNR.dbf Step 3 Start LogMiner.WHERE DICTIONARY_BEGIN = 'YES').dbf FIRST_TIME -------------------10-jan-2003 12:01:34 Step 2 Display all the redo log files that have been generated so far.CONTINUOUS_MINE).DICT_FROM_REDO_LOGS + DBMS_LOGMNR. SQL> EXECUTE DBMS_LOGMNR. as will be shown in Step 4. NAME -------------------------------------------/usr/oracle/data/db1arch_1_207_482701534.dbf /usr/oracle/data/db1arch_1_209_482701534. but is included to demonstrate that the CONTINUOUS_MINE option works as expected.START_LOGMNR(STARTTIME => '10-jan-2003 12:01:34'.PRINT_PRETTY_SQL + DBMS_LOGMNR. This step is not required. Start LogMiner by specifying the dictionary to use and the COMMITTED_DATA_ONLY. OPTIONS => DBMS_LOGMNR.dbf /usr/oracle/data/db1arch_1_210_482701534. SQL> SELECT FILENAME name FROM V$LOGMNR_LOGS WHERE LOW_TIME > '10-jan-2003 12:01:34' NAME ---------------------------------------------/usr/oracle/data/db1arch_1_207_482701534.

dbf Step 5 Query the V$LOGMNR_CONTENTS view. SQL_REDO FROM V$LOGMNR_CONTENTS WHERE SEG_OWNER IS NULL OR SEG_OWNER NOT IN ('SYS'.(XIDUSN || '.2.1594 1.) Note that all reconstructed SQL statements returned by the query are correctly translated. modified_time date.2. create table oe. SQL> SELECT USERNAME AS usr.' || XIDSLT || '.dbf /usr/oracle/data/db1arch_1_210_482701534.1594 SQL_REDO ----------------------------------set transaction read write. USR ----------SYS SYS XID -------1. (Compare the output in this step to the output in Step 2. This step shows that the DBMS_LOGMNR. NAME -----------------------------------------------------/usr/oracle/data/db1arch_1_207_482701534.dbf /usr/oracle/data/db1arch_1_209_482701534. exclude all DML statements done in the sys or system schema.dbf /usr/oracle/data/db1arch_1_208_482701534. 'SYSTEM') AND TIMESTAMP > '10-jan-2003 15:59:53'. old_warranty_period interval year(2) to month).START_LOGMNR procedure with the CONTINUOUS_MINE option includes all of the redo log files that have been generated so far. (This query specifies a timestamp to exclude transactions that were involved in the dictionary extraction. To reduce the number of rows returned by the query.product_tracking (product_id number not null.' || XIDSQN) as XID.) SQL> SELECT FILENAME name FROM V$LOGMNR_LOGS. as expected. .2). old_list_price number(8.Step 4 Query the V$LOGMNR_LOGS view.

1594 1.SYS SYS SYS 1. end.9. update "OE".product_id.product_tracking_trigger before update on oe.warranty_period).18.1602 1.18.warranty_period <> old.product_information for each row when (new. sysdate. :old.1602 commit.1598 insert into "OE".list_price <> old. :old.warranty_period) declare begin insert into oe. "MODIFIED_TIME" = TO_DATE('13-jan-2003 16:07:03'.list_price. create or replace trigger oe.list_price or new. SYS OE 1.product_tracking values (:old. 'dd-mon-yyyy hh24:mi:ss'). "LIST_PRICE" = 100 where "PRODUCT_ID" = 1729 and "WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00') and "LIST_PRICE" = 80 and ROWID = 'AAAHTKAABAAAY9yAAA'."PRODUCT_TRACKING" values "PRODUCT_ID" = 1729. .1598 commit.1602 1. set transaction read write."PRODUCT_INFORMATION" set "WARRANTY_PERIOD" = TO_YMINTERVAL('+08-00'). OE 1.2.18.9.

."OLD_LIST_PRICE" = 80. "OLD_WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00'). "LIST_PRICE" = 92 where "PRODUCT_ID" = 2340 and "WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00') and "LIST_PRICE" = 72 and ROWID = 'AAAHTKAABAAAY9zAAA'. Step 6 End the LogMiner session. 'dd-mon-yyyy hh24:mi:ss'). OE 1.9."PRODUCT_INFORMATION" set "WARRANTY_PERIOD" = TO_YMINTERVAL('+08-00'). OE 1.9.1598 commit.9. OE 1."PRODUCT_TRACKING" values "PRODUCT_ID" = 2340. "MODIFIED_TIME" = TO_DATE('13-jan-2003 16:07:07'.1598 update "OE".END_LOGMNR(). "OLD_LIST_PRICE" = 72.1598 insert into "OE". "OLD_WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00'). SQL> EXECUTE DBMS_LOGMNR.

SQL> STARTUP MOUNT STEP 4: Give the following command SQL> ALTER DATABASE ARCHIVELOG. Follow these steps: STEP 1: Shutdown the database if it is running. To open the database in Archive log mode. Follow these steps: STEP 1: Shutdown the database if it is running. STEP 2: Take a full offline backup.%t. STEP 2: Comment the following parameters in parameter file by putting " # " . LOG_ARCHIVE_FORMAT=ica%s. STEP 5: Then type the following to confirm. Step 7: It is recommended that you take a full backup after you brought the database in archive log mode. To again bring back the database in NOARCHIVELOG mode. SQL> ARCHIVE LOG LIST. STEP 6: Now open the database SQL>alter database open.%r. .BACKUP AND RECOVERY Opening or Bringing the database in Archivelog mode.arc LOG_ARCHIVE_DEST_1=”location=/u02/ica/arc1” If you want you can specify second destination also LOG_ARCHIVE_DEST_2=”location=/u02/ica/arc1” Step 3: Start and mount the database. STEP 3: Set the following parameters in parameter file.

SQL> STARTUP MOUNT. You can create text file and put the destinations of each file for future use. Lets suppose all the files are in "/u01/ica" directory. TIP: To identify the datafiles.arc STEP 3: Startup and mount the database. parameter file and password file to your backup destination.# LOG_ARCHIVE_DEST_1=”location=/u02/ica/arc1” # LOG_ARCHIVE_DEST_2=”location=/u02/ica/arc2” # LOG_ARCHIVE_FORMAT=ica%s. . $cd /u01/ica $cp * /u02/backup/ Be sure to remember the destination of each file. ( UNIX ) Shutdown the database if it is running.%t. Then start SQL Plus and connect as SYSDBA. STEP 4: Give the following Commands SQL> ALTER DATABASE NOARCHIVELOG. Logfiles query the data dictionary tables V$DATAFILE and V$LOGFILE before shutting down. Then the following command copies all the files to the backup destination /u02/backup. Copy all the datafiles.%r. $sqlplus SQL> connect / as sysdba SQL> Shutdown immediate SQL> Exit After Shutting down the database. TAKING OFFLINE BACKUPS. controlfiles. STEP 5: Shutdown the database and take full offline backup. This will be useful when restoring from this backup. Now you can open the database. logfiles.

Start sqlplus and then connect as SYSDBA.dbf ".TAKING ONLINE (HOT) BACKUPS. If you have lost one datafile and if you don't have any backup and if the datafile does not contain important objects then. You will loose all information contained in the damaged datafile. SQL> host cp /u01/ica/usr1. Lets suppose the file is "/u01/ica/usr1. Option 1: When you don’t have a backup. You can query the V$DATAFILE view to find out the name of datafiles associated with this tablespace. After connecting give the command "archive log list" this will show you the status of archiving. SQL> exit. you can drop the damaged datafile and open the database.(UNIX) To take online backups the database should be running in Archivelog mode. $sqlplus Enter User:/ as sysdba SQL> ARCHIVE LOG LIST If the database is running in archive log mode then you can take online backups. $sqlplus Enter User:/ as sysdba SQL> alter tablespace users begin backup.dbf /u02/backup SQL> alter tablespace users end backup. RECOVERING THE DATABASE IF IT IS RUNNING IN NOARCHIVELOG MODE. Let us suppose we want to take online backup of "USERS" tablespace. To check whether the database is running in Archivelog mode or Noarchivelog mode.(UNIX) . Give the following series of commands to take online backup of USERS tablespace. The following are the steps to drop a damaged datafile and open the database.

To drop the damaged datafile follow the steps shown previously. Also remember to copy the control files to all the mirrored locations. RECOVERING FROM LOST OF CONTROL FILE. You will loose all the changes made to the database since last full backup. $cp /u02/backup/* /u01/ica This will copy all the files from backup directory to original destination. Or you can restore from full backup. STEP 2: Start the sqlplus and give the following commands. Then do the following. If you have lost the control file and if it is mirrored.dbf' offline drop. STEP 2: Restore from full database backup i. copy all the files from backup to their original locations(UNIX) Suppose the backup is in "/u2/oracle/backup" directory. If the database is running in Noarchivelog mode and if you have a full backup. STEP 1: Take a full backup of current database.STEP 1: First take full backup of database for safety. Do the following. ii . To restore from full database backup. Either you can drop the damaged datafile. Option 2:When you have the Backup. Then simply copy the control file from mirrored location to the damaged location and open the database . Then there are two options for you. $sqlplus Enter User:/ as sysdba SQL> STARTUP MOUNT SQL> ALTER DATABASE DATAFILE SQL>alter database open. if it does not contain important information which you can afford to loose. '/u01/ica/usr1.e. i .

Recovering Database when the database is running in ARCHIVELOG Mode. If your script file containing the control file creation statement is "CR. You have to write the file names and sizes of all the datafiles. SQL>alter database mount. " and if you have not added any tablespace since then. SQL>alter database open.If you have lost all the mirrored control files and all the datafiles and logfiles are intact. Then follow the steps shown below. Recovering from the lost of Damaged Datafile. STEP 5: Mount and Open the database. You will lose any datafiles which you do not include. STEP 1: Start sqlplus STEP 2: connect / as sysdba STEP 3: Start and do not mount a database like this. SQL> STARTUP NOMOUNT STEP 4: Run the "CR. STEP 2.SQL" Then just do the following. . Restore the datafile from most recent backup. Shutdown the Database if it is running.SQL" script file. Then you can recreate a control file. If you have lost one datafile. If you have already taken the backup of control file creation statement by giving this command. " ALTER DATABASE BACKUP CONTROLFILE TO TRACE. Then you have to manually give the CREATE CONTROL FILE statement. just create the controlfile by executing the statement Buf If you have added any new tablespace after generating create controlfile statement. STEP 1. Then you have to alter the script and include the filename and size of the file in script file. Refer to "Managing Control File" topic for the CREATE CONTROL FILE statement. If you do not have a backup of Control file creation statement.

Now to recover the table follow these steps. $sqlplus Enter User:/ as sysdba SQL>Startup mount.STEP 3. SQL>alter database recover. Go on to next step. Start SQLPLUS and start and mount the database. Shutdown the database and take a full offline backup. SQL> recover database until time '2007:08:16:13:55:00' . Restore all the datafiles. After you get the "Media Recovery Completely" statement. Time Based Recovery (INCOMPLETE RECOVERY). Recovering from the Lost Archived Files: If you have lost the archived files. STEP 4. Then give the following command to recover database until specified time. If all archive log files are available then recovery should go on smoothly. Suppose a user has a dropped a crucial table accidentally and you have to recover the dropped table. Then Immediately shutdown the database and take a full offline backup. Now open the database SQL>alter database open. STEP 4. STEP 1. Then Start sqlplus and connect as SYSDBA. STEP 3. logfiles and control file from the full offline backup which was taken on Monday. SQL>Set autorecovery on. Some user accidently drop the table on Thursday 16-Aug-2007 and nobody notice this until Saturday. STEP 2. You have taken a full backup of the database on Monday 13-Aug-2007 and the table was created on Tuesday 14-Aug-2007 and thousands of rows were inserted into it.

like this SQL> alter database open resetlogs.Check storage .Check configured metrics .Check CPU contention .Cleaning of alert logs . STEP 5.Verify instance status . STEP 6.Check network load .Check memory usage .Fragmentation .Tunning: indexes and execution plans .Check waiting times . Export the table to a dump file using Export Utility. After database is open.Review I/O . Open the database and Import the table.Check alerts .Invalid objects . Restore from the full database backup which you have taken on Saturday. STEP 8.Tunning .Trends and peaks . Because you have performed a Incomplete Recovery.Analyze the data increment trend .Recovery tests .Environments consistence . Open the database and reset the logs. STEP 7.Review of ressource policy .Check RMAN backups .Top SQL .using backup controlfile. Note: In Oracle 10g you can easily recover drop tables by using Flashback feature.Check iostat Weekly .Review of RMAN Monthly . For further information please refer to Flashback Features Topic in this book Daily .

They should never be modified by any user or database administrator. select tablespace_name. DBA .Schedule monthly downtime SYS: automatically created when Oracle database is installed automatically granted the DBA role has a default password: CHANGE_ON_INSTALL (make sure you change it) owns the base tables and views for the database data dictionary the default schema when you connect as SYSDBA Tables in the SYS schema are manipulated only by the database. SYS user account .High Availability Analysis . SYSTEM: automatically created when Oracle database is installed automatically granted the DBA role has a default password: MANAGER (make sure you change it) used to create additional tables and views that display administrative information used to create internal tables and views used by various Oracle database options and tools Never use the SYSTEM schema to store tables of interest to non-administrative users.TS# order by rtime desc.tablespace_id = b. tablespace_usedsize*8192/(1024*1024*1024) .Row chaining ..The DBA role will be assigned to this account. rtime from DBA_HIST_TBSPC_SPACE_USAGE a . Tablespace administration sql statements Finding out the historical tablespace usage select name .role Contains all database system privileges. and no one should create any tables in the schema of user SYS. Database users should not connect to the Oracle database using the SYS account. .It has all the system privileges for the database and additional tables and views that display administrative information and internal tables and views used by oracle tools are created using this username. tablespace_size*8192/(1024*1024*1024) . All of the base tables and views for the database's dictionary are store in this schema and are manipulated only by ORACLE. v$tablespace b where tablespace_id = 175 and a. tablespace_maxsize*8192/(1024*1024*1024) .Scalability . SYSTEM user account . sum(bytes)/1024/1024 from dba_free_space group by tablespace_name. find out free space on the mentioned tablespace.

tablespace_name = d. d.autoextensible autoextend .dbf‘ SIZE 20000M REUSE EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M. .dbf‘ .tablespace_name group by d. sum(bytes/1024/1024) from dba_data_files d.tablespace_name and t. dba_tablespaces t where t.tablespace_name and bytes/1024/1024 > 3000 .status. dba_tablespaces t where t. select t.tablespace_name creating a temporary tablespace CREATE TEMPORARY TABLESPACE TS_TEMP TEMPFILE ‗/global/reuterdb1/oracle/reutertp/data1/reutertp_temp01. select file_name.tablespace_name tablespace. dba_tablespaces t where t.tablespace_name = ‗TS_GFD_DATA‘ group by t.tablespace_name like ‗UN%‘ . d. select d. bytes from dba_data_files d.tablespace_name and d. d.tablespace_name = d.tablespace_name find out the tablespaces whose size is greater than 3 GB select file_name.increment_by. dba_tablespaces t where t.select tablespace_name.tablespace_name tablespace.tablespace_name group by t.This is normally used when you previously copied the datafile from one location to another location and you want to now update the control file . t. sum(bytes)/1024/1024 from dba_free_space where tablespace_name = ‗TS_RBS‘ group by tablespace_name.tablespace_name = ‗TS_TRAINENGINE_FACT_DATA‘ select t.tablespace_name = d. sum(bytes/1024/1024) from dba_data_files d.tablespace_name and d. bytes/1024/1024 . dba_tablespaces t where t. find out existing size of the tablespaces by using the following command select file_name. sum(bytes/1024/1024)/count(*) from dba_data_files d. dba_tablespaces t where t. Command to rename a datafile name.status. t.maxbytes from dba_data_files d. bytes/1024/1024 from dba_data_files d. dba_tablespaces t where t.tablespace_name = d.tablespace_name = d.tablespace_name = d.tablespace_name tablespace. bytes from dba_data_files d. alter database rename file ‗/global/reuterdb1/oracle/reutertp/data6/reutertp_GFD_data11. select file_name.Be careful that you have to move the datafiles only when the database is completely shutdown.tablespace_name tablespace.tablespace_name and bytes/1024/1024 > 3000 .dbf‘ to ‗/global/reuterdb1/oracle/reutertp/data3/reutertp_GFD_data11.tablespace_name = d.

but does not describe .tablespace_name = d. dba_tablespaces t where t.dbf‘ SIZE 2048M AUTOEXTEND ON NEXT 1024M MAXSIZE 32000M.tablespace_name like ‗BRAINLOBZIP‘. bytes from dba_data_files d. DBA_USERS Describes all users of the database ALL_USERS Lists users visible to the current user. changing a users quota on a tablespace to unlimited alter user ims quota unlimited on ts_data_1. find out datafile path and name for the specified tablespace select file_name. Resize the data file with the following command alter database datafile ‗/u10/oradata/RSOD/RSODundo_02_02.dbf‘ size 1000M.dbf‘ AUTOEXTEND ON NEXT 10M MAXSIZE 2000M. select file_name.tablespace_name and d. to change the maxbytes of a datafile do the below command ALTER DATABASE DATAFILE ‗ /global/riskeb/oracle/redb/data2/redb_TRAINENGINE_interm_data01.if problem with tablespace size then increase the tablespace size.dbf‘ resize 1000M.tablespace_name tablespace. Adding datafile to a tablespace alter tablespace ts_GFD_indx add datafile ‗/global/reuterdb1/oracle/reutertp/data6/reutertp_GFD_indx25.tablespace_name from dba_data_files. resizing a datafile alter database datafile ‗ /global/mrt-db/oracle/mrt/data1/ppmrtint_tools01.dbf ‗ resize 680M adding datafile to a tablespace alter tablespace INDEX_MED_OPG ADD DATAFILE ‗/var/opt/oracle/DSS1/data04/INMED_OPGDSS105. t.

TABLESPACE_NAME USERNAME BYTES —————————— —————————— ———- . Defining user quotas on tablespaces Alter user listmgmt quota 1024M on ts_data01 quota 1024M on ts_index01 Finding out tablespace quotas for an user.them USER_USERS Describes only the current user DBA_TS_QUOTAS Describes tablespace quotas for all users USER_TS_QUOTAS Describes tablespace quotas for current user USER_PASSWORD_LIMITS Describes the password profile parameters that are assigned to the user USER_RESOURCE_LIMITS Displays the resource limits for the current user DBA_PROFILES Displays all profiles and their limits RESOURCE_COST Lists the cost for each resource Syntax for creating a user ALTER USER avyrros IDENTIFIED by ‗password‘ DEFAULT TABLESPACE data_ts TEMPORARY TABLESPACE temp_ts QUOTA 100M ON data_ts QUOTA 0 ON test_ts PROFILE clerk. SQL> select * from dba_ts_quotas where username like ‗%LISTMGMT%‘.

the exact number is indicated in the MAX_BYTES column.——.———USERS JFEE 0 512000 0 250 USERS DCRANNEY 0 -1 0 -1 When specific quotas are assigned. The following query lists all tablespace quotas specifically assigned to each user: SELECT * FROM DBA_TS_QUOTAS. V$SESSION Lists session information for each current session. User altered.———. then it is rounded up accordingly. so if you specify a tablespace quota that is not a multiple of the database block size. which holds resource privilege information only at the tablespace level. A user can have an overriding database resource privilege that can be seen by querying DBA_USERS.— TS_DATA01 1048576000 TS_INDEX01 1048576000 128000 80768 LISTMGMT 128000 NO LISTMGMT 128000 NO 1048576000 661651456 SQL> Alter user listmgmt quota 1024M on ts_data01 quota 1024M on ts_index01.MAX_BYTES BLOCKS MAX_BLOCKS DRO ———.——— ——– ———. TFSTSUSR reports on DBA_TS_QUOTAS. Unlimited quotas are indicated by -1 Users having both zero quota and zero bytes used in a tablespace are not listed in the report. includes user name V$SESSTAT Lists user session statistics . TABLESPACE USERNAME BYTES MAX_BYTES BLOCKS MAX_BLOCKS ———.———. Note that this number is always a multiple of the database block size.

and we know that we dont have 100 users at the moment on dev. a change in the processes parameter from 75 to 150 will not have much of an impact on the system‘s oracle-dedicated memory (the SGA).net or whatever and then not closed.V$STATNAME Displays decoded statistic names for the statistics shown in the V$SESSTAT view PROXY_USERS Describes users who can assume the identity of other users See Also: Oracle Database SQL Reference for complete descriptions of the preceding data dictionary and dynamic performance views 2)WHEN MAX ERRORS REACHED OCCURS the error ORA-00020: maximum number of processes (%s) exceeded is because of the following reasons.ora file and increase the default max no. so the only reason could be that somebody has opened a connection in front end and then not closing it.ora file. Generally. If you are using web-application. So. There is also some SGA space for all processes (active or not – but it is small). One day we got the above error on our development server. Edit the init<sid>. it is not using any resources to maintain a ―place‖ for that process. Be careful to take memory availabily into account. of processes form 50 to 200 or 300. which is not part of the shared memory parameters. 1)when the number of processes accessing oracle database exceeds specified limit. This will give you a temporary solution only. if a process is not active. On our development server the processes parameter is set to 100. So asked the app team to check their front end code. . oracle error no of sessions exceeded reason is the processes are created from asp. Restart the application on the MMS – console.oracle has a limit on no of processes specified in the init. or they might have a loop and then opening the connection. The processes that are active take up some of the system memory in what is called the PGA.

it can‘t be used for tablespaces that contain active rollback segments or temporary segments. substr( SID||‘. instr( PROGRAM . 10) ―USERNAME‖ .OBJECT_ID and a. select substr( b.owner||‘. substr( lower(USERNAME). select username. Rename and/or move the datafile using operating . all_objects b.SID. but it only works with non-SYSTEM tablespaces. substr( PROGRAM . name from v$parameter where name=‘processes‘. COUNT(*) from v$session GROUP BY TERMINAL. This method has the advantage that it doesn‘t require shutting down the instance. COUNT(*) from v$session where schemaname = ‗KEYSTONE‘ GROUP BY TERMINAL select TERMINAL. 2. COUNT(*) from v$session GROUP BY TERMINAL select * from v$session where schemaname = ‗KEYSTONE‘ and terminal = ‗SPL1W082‘ GROUP BY TERMINAL when filesystem is 100% full.username. 1. 1. select TERMINAL. Take the tablespace offline. 30) ―TABLE‖ .SESSION_ID = c. lower(TERMINAL) ―TERMINAL‖ .non system datafiles can be moved by the following way.select value. 1. sometimes we need to move the datafiles to another filesystem temporarily so the filesstem can be extended by the unix team. v$session c where a.OBJECT_ID = b. Further.TERMINAL. -1)+ 1) ―PROGRAM‖ from V$LOCKED_OBJECT a.object_name. ‗\‘. lower(OSUSER) ―OSUSER‖ . 1. 10) ―SESSION_ID‖ .‘||SERIAL#.‘||b.

system commands. 3.dbf ‗ TO ‗/u02/oracle/U1/data04. How to find pending transactions in the database? set lines 250 column start_time format a20 column sid format 999 column serial# format 999999 column username format a10 column status format a10 column schemaname format a10 column osuser format a10 column process format a10 column machine format a15 . Use the alter tablespace command to rename the file in the database. sql> connect sys/oracle as sysdba sql> alter tablespace app_data offline.dbf ‗ . 4. sql> alter tablespace app_data online. sql> alter tablespace app_date rename datafile ‗/u01/oracle/U1/data01. Bring the tablespace back online. The tablespace will be back online using the new name and/or location of the datafile.

s.serial#. v$session s where s.‘DD/MON/YY HH24:MI:SS‘) logon_time from v$transaction t.schemaname.s.s.machine. select value from v$parameter where name = ‗spfile‘. spfile is used otherwise pfile.to_char(s.username.saddr = t.s.osuser.start_time.terminal. and startup open spfile=‘/path/to/spfile‘..s.sid.logon_time. if this comes back with a value other than null.s. what about if i just want to use pfile.s.ora‘ then you can delete the spfile . How to find if spfile is used? this is the correct way: select distinct isspecified from v$spparameter if you see ‗TRUE‘ there.s. you can shutdown the database. you are using an spfile.process.program.s.column terminal format a10 column program format a25 column module format a10 column logon format a20 prompt #################################################### prompt # current transactions: prompt #################################################### select t.s. if you are using a pfile.ses_addr order by start_time. should i just delete the spfile? you will need to shutdown and startup open pfile=‘/path/to/initSID.s.module.status.

last_analyzed FROM user_tables ORDERBY last_analyzed DESC select table_name. password from dba_users. Find last analyzed time for the schema.—This is to update statistics. access to dba_users and other dba_ views) 1. then restore the original password (either connected as user1 or through your own user).s suppose there is an user by name user1 and you want to log into his schema. 5. How to find users passwords in the database? yeah you can connect to the user schema without knowing the user‘s actual password.last_analyzed from dba_tables where owner like ‗SUP%‘ and rownum < 4. now you can connect as user1 by using the new password. tables etc . 10)9i how to delete and compute statistics Analyze table test compute statistics. dba_tablespaces t where t. SELECT table_name.Find size of table space select file_name. here are the steps (It will work only if you have DBA privilege ie.tablespace_name tablespace. save the value in the password column for this user retrieved from query in step 1 (say the encrypted value is abcdefgh1234) change the password of the user alter user user1 indetified by temppass. alter user user1 identified by values ‗abcdefgh1234‘. t. .tablespace_name = d.tablespace_name Find free space in tablespace select tablespace_name. select username. sum(bytes)/1024/1024 from dba_free_space group by tablespace_name. — this will analyze the indexes as well. bytes from dba_data_files d. 4.

terminal. get sql info for a session SELECT sql_text . terminal. osuser. schemaname. If you are using 10g then don‘t use compute statistics. program FROM v$session ORDER BY schemaname. column_position from all_ind_cols where owner = ‗SCOTT‘ and table_name = ‗TEST‘. Use dbms_stats. — compute new stats The above commands are 9i . — delete the existing stats first and then analyze table test compute statistics. column_name. — this is to find the indexes for a particular table find all indexed columns select index_name. osuser.or analyze table test delete statistics. program.gather_table_stats procedure. — this is to help you find any columns being not added in the multi column index get all session info Detailed sessions informations are returned by : SELECT sid. find all indexes on a table select index_name from all_indexes where owner = ‗SCOTT‘ and table_name = ‗TEST‘.

―Daily Reports‖.FROM v$sqltext WHERE concat(hash_value. privilege from dba_tab_privs where owner = ‗SIEBEL‘ and table_name= ‘S_SRC‘ select * from user_sys_privs where username=user. select * from dba_sys_privs where grantee=‘KEYSTONE‘.constraints. they could use this to set the identifier differently for different application modules ―New Client Entry‖. Be very careful. etc.privilege from dba_tab_privs where owner in (‗SYS‘. address)=(SELECT concat(sql_hash_value. select ‗grant ‗ || privilege || ‗ to keystone ‗ from dba_sys_privs where grantee=‘KEYSTONE‘ . DBMS_SESSION. Other ways will take more work. 15) setting identifiers for different application modules There is a way for programs to ―identify themselves‖. drop tablespace data_med_lcp including contents and datafiles cascade constraints describe the different user privileges views here granting privileges to users -> some examples grant CREATE SYNONYM to price_dev grant CREATE SESSION to price_dev select grantor. sql_address) FROM v$session WHERE sid=?????) ORDER BY piece. this drops the whole tablespace.datafiles .SET_IDENTIFIER (client_id VARCHAR2) If you are working with Application Developers. Then v$session would show this information for the session running the SQL in question in the CLIENT_IDENTIFIER field. ‗SYSTEM‘) You can query the user_tab_privs_recd and the user_sys_privs: Select grantee. ―Invoicing‖. drop tablespaces incuding objects. That would be the easiest way.

If possible. not anything else. Some of them are DBA. and CONNECT. has the CREATE TABLE/SEQUENCE/SYNONYM and a few more options. Did you know that it has UNLIMITED TABLESPACE system privilege. by default. Let‘s examine RESOURCE.? (A) select * from dba_sys_privs where GRANTEE=<ROLE_NAME> (3) How can I see all the ‘grants’ that have been assigned to a user…. select * from role_role_privs. role_sys_privs role_tab_privs (1) How can I select the role(s) that a user has been assigned…. select * from user_tab_privs_recd . Create your own roles. this is not what you want. it is not prudent to use built-in roles.select * from dba_role_privs where grantee=‘SUPPDB‘. Rather. making it able to create any table anywhere in the database – including the SYSTEM tablespace? Obviously. identify the privileges users will need. Another privilege. You would want to restrict the tablespaces to specific users only. This can have far reaching consequences. This is generally given to schema owners. the ability is much more than that. select * from user_tab_privs_recd where owner in (‗SYS‘. try not to use the Oracle built-in roles like RESOURCE and CONNECT. but each of them is a security nightmare.? (A) select * from dba_role_privs where GRANTEE=‘RKSREPGEN‘ (2) How can I see all the ‘grants’ that have been assigned to a role…. Similarly the role CONNECT. and use them to control authorization. ALTER SESSION system privilege. The name CONNECT somehow conveys the impression of the ability to connect only. select ‗grant ‗ || granted_role || ‗ to keystone ‗ from dba_role_privs where grantee = ‗KEYSTONE‘.? (A) select * from dba_sys_privs where grantee = ‗RKSREPGEN‘ Oracle provides several roles that are built into the database. allows the grantee to issue sql_trace = TRUE in their session. select * from dba_role_privs where grantee = [user]. put them in the appropriate roles which you have created. however. Therefore. ‗SYSTEM‘). RESOURCE. . As you can see. Most DBAs use them to make their tasks easier and simpler.

. CREATE TABLE.com/docs/cd/B10501_01/server. CREATE PROCEDURE.920/a96540/statements_912a. CREATE OPERATOR. CREATE INDEXTYPE. CREATE TRIGGER and CREATE TYPE Resize datafiles alter database datafile ‗/var/opt/oracle/DSS1/data04/INDEX_MED_OPGDSS102.com/docs/cd/B10501_01/server. CREATE SYNONYM.oracle. Rather a scary lot for a role called ‗connect‘ RESOURCE has CREATE CLUSTER. CREATE INDEXTYPE. CREATE SEQUENCE. CREATE TABLE.oracle.htm#2063331 For object privileges http://downloadwest. CREATE OPERATOR. CREATE SESSION. CREATE SEQUENCE.920/a96540/statements_912a.920/a96540/statements_912a.htm#2073689 For role privileges http://downloadwest. CREATE TABLE and CREATE VIEW. CREATE SEQUENCE. CREATE PROCEDURE.com/docs/cd/B10501_01/server. CREATE TRIGGER and CREATE TYPE In Oracle 9iR2 things get a little scary: CONNECT has ALTER SESSION.dbf‘ resize 2000M Kill session The SQL*Plus Approach Sessions can be killed from within oracle using the ALTER SYSTEM KILL SESSION syntax. CREATE CLUSTER.Try these For system privileges http://downloadwest. CREATE DATABASE LINK.htm#2063440 In Oracle 10gR2 things are fairly sane: CONNECT role has only CREATE SESSION RESOURCE has CREATE CLUSTER.oracle.

s.EXE ORACLE.EXE DBSNMP. In some situations the Oracle.program FROM v$session s.EXE The SID and SERIAL# values of the relevant session can then be substituted into the following statement: SQL> ALTER SYSTEM KILL SESSION ‗sid. It will then be killed as soon as possible.EXE ORACLE. If the marked session persists for some time you may consider killing the process at the operating system level. SID SERIAL# OSUSER PROGRAM ———. so do this at your own peril.osuser. Issuing the ALTER SYSTEM KILL SESSION command is the only safe way to kill an Oracle session.First identify the offending session as follows: SELECT s.serial#.sid.EXE ORACLE.serial#‘. .EXE ORACLE.—————————— ————— 1 2 3 4 5 6 20 43 33 1 SYSTEM 1 SYSTEM 1 SYSTEM 1 SYSTEM 1 SYSTEM 1 SYSTEM 60 SYSTEM 11215 USER1 5337 USER2 ORACLE.EXE ORACLE. In these cases the session will be ―marked for kill‖.EXE SQLPLUSW. s.———.exe is not able to kill the session immediately. Killing OS processes is dangerous and can lead to instance failures.EXE SQLPLUSW. s. as explained below.

exe in Windows. REMOTE_LOGIN_PASSWORDFILE Parameter type = String Syntax REMOTE_LOGIN_PASSWORDFILE= {NONE | SHARED | EXCLUSIVE} Default value NONE REMOTE_LOGIN_PASSWORDFILE specifies whether Oracle checks for a password file and how many databases can use the password file. So. usernames and passwords in Oracle not case-sensitive. privileged users must be authenticated by the operating system.It is possible to force the kill by adding the IMMEDIATE keyword: SQL> ALTER SYSTEM KILL SESSION ‗sid. like: SYSTEM) if you want to.so be careful. Therefore.serial#‘ IMMEDIATE. just enter this: alter user system identified by secret. The syntax is simply: alter user [username] identified by [new_password]. or the kill command in UNIX/Linux change sys password There is no difference. so this also works: alter user SYSTEM identified by SECRET But in 11g passwords are case-sensitive. you can then change the password for SYS (and any other user also. to change the password for SYSTEM to be ―‖secret‖. NONE >> Oracle ignores any password file. No. But if your server and database are set up to allow you to connect as SYS without explicitly entering a password. more info on orapwd file. . This should prevent you ever needing to use the orakill.

EXCLUSIVE >> The password file can be used by only one database and the password file can contain names other than SYS. Connect to the database as user SYS (or as another user with the administrative privilege). Preparing to Use Password File Authentication To enable authentication of an administrative user using password file authentication you must do the following: Create an operating system account for the user. . Grant the SYSDBA or SYSOPER system privilege to the user: GRANT SYSDBA to scott. If the user does not already exist in the database. Using Password File Authentication This section describes how to authenticate an administrative user using password file authentication. to get listing of user enabled to connect to the database using ORAPWD file. This statement adds the user to the password file. Give it a try with a username you know doesn‘t exist: conn fred/flintstone as sysdba.SHARED >>More than one database can use a password file. If not already created. you can query view sql> select * from V$PWFILE_USERS. Only user recognized by the password file is SYS. create the user. Create the password file using the ORAPWD utility: ORAPWD FILE=filename PASSWORD=password ENTRIES=max_users Set the REMOTE_LOGIN_PASSWORDFILE initialization parameter to EXCLUSIVE. If you are. It doesn‘t make any difference what username and password is used. you are connected as the SYS user. thereby enabling connection AS SYSDBA As soon as Oracle sees ‗as sysdba‘ it checks to see if you‘re allowed to connect.

find out whether datafiles are online select FILE#. select server.STATUS from v$datafile. Otherwise. you can use lsnrctl status or lsnrctl services to see if your doing shared or dedicated (or just query SERVER from v$session) I ran the select… SQL> set echo on SQL> select server from v$session where sid=(select sid from v$mystat where rownum=1). count(*) from v$session group by server.be careful about including the dot before the character set. the password for sys is sepcified when you create the password file: orapwd file=orapw<sid> password=<sys‘s password> entries=<max # user‘s> with REMOTE_LOGIN_PASSWORDFILE=exclusive in the init<SID>. when you have conversion errors in toad Change the nls_lang in the registry editor of the client to . find out whether a server is dedicated or shared. DEDICATED SQL> spool off that shows a single dedicated server session.UTF8 or whichever character set you want.Unless you create the password file. Maximum cursors . the default password of SYS and SYSTEM is ―change_on_install‖ and ―system‖ respectively when you create a new database.ora Logging as sysdba to the database sqlplus ‗/as sysdba‘ This will let you login to Oracle as sys using OS authentication (must be login as Oracle user in Unix/Windows).

RECEIVING_CENTER_MATRIX ADD CONSTRAINT pk_RECEIVING_CENTER_MATRIX1 PRIMARY KEY (PDA_TYPE_ID.machine .value as numopencursors . ALTER TABLE TAB_PK DROP PRIMARY KEY CASCADE.RECEIVING_CENTER_ID) USING INDEX TABLESPACE CLM_DATA.CONSTRAINT_NAME = ‗PK_RECEIVING_CENTER_MATRIX‘.BUSINESS_UNIT. V$SESSION s WHERE v. After spooling above information and after confirmation from application team use below command to drop primary key and cascade all constraints. So In toad I had to manually drop the index.s.CONSTRAINT_NAME = B.sid = s.osuser.TABLE_NAME CHILD. observed that the index was not dropped. B. Dropped the primary key using alter table surveyor.CONSTRAINT_NAME FROM USER_CONSTRAINTS A.username FROM V$SESSTAT v.sid Modify primary key columns If foreign key constraints are referencing this primary key then find them by using query SELECT A.s.To check how many cursors are in use run this sql statement: SELECT v.CONSTRAINT_NAME.statistic# = 3 and v.RECEIVING_CENTER_MATRIX drop primary key .s. Then I recreated primary key with ALTER TABLE surveyor. USER_CONSTRAINTS B WHERE A. CASCADE option drops the foreign key constraints on any table referencing the PK being dropped. A. B.ISO_COUNTRY_CODE.R_CONSTRAINT_NAME AND A. .TABLE_NAME PARENT.

INI_TRANS.. TABLE_NAME. TABLE_OWNER. MAX_EXTENTS. INDEX_TYPE. INITIAL_EXTENT. MAX_TRANS.. NEXT_EXTENT. PCT_USED. TABLE_TYPE. INI_TRANS. INDEX_NAME.‘ feature. optionally in a different tablespace. MAX_EXTENTS. NEXT_EXTENT. MIN_EXTENTS. MAX_TRANS. and optionally modify any of its storage attributes. MIN_EXTENTS. FREELIST_GROUPS. storage. TABLESPACE_NAME. FREELIST_GROUPS from dba_tables where owner = ‗SURVEYOR‘ and table_name = ‗RECEIVING_CENTER_MATRIX‘ select OWNER.find table and index storage parameters select OWNER. TABLE_NAME. INCLUDE_COLUMN.TABLESPACE_NAME. PCT_INCREASE. FREELISTS. PCT_THRESHOLD. The move_table_clause lets you relocate data of a nonpartitioned table into a new segment. INITIAL_EXTENT. I recommend that you take an export for safety)… . FREELISTS.PCT_FREE. PCT_FREE from dba_indexes where owner = ‗SURVEYOR‘ and index_name = ‗PK_RECEIVING_CENTER_MATRIX‘ change initial extent of table or any storage parameters 1) Pre-Oracle 8i – drop an recreate the table and then reload (probably best done with export/import) 2) 8i and beyond – use the new ―alter table …. there is a new function under the alter tablecommand called MOVE TABLE clause. move tablespace …. This can be done without taking down the database (however. PCT_INCREASE.

get table_size 1 select a.owner=b.table_name =‘EMP‘ alter table scott.initial_extent. 2 3 4 a. One restriction.NUM_ROWS. There was .owner. a.The syntax is: alter table <TABLE_NAME> move tablespace <NEW_TBSP> storage( <STORAGE_CLAUSE>).next_extent.TABLESPACE_NAME.MIN_EXTENTS. alter index <INDEX_NAME> rebuild tablespace <NEW_TBSP> storage( <STORAGE_CLAUSE>). dba_segments b 6 where a. You rebuild indexes with the following command.owner=‘SCOTT‘ 7 8 and a. you must rebuild all associated indexes after moving a table because the move invalidates them. b.a. a.extents NUM_EXTENTS 5 from dba_tables a.emp 2 move tablespace DATA 3 storage (initial 200K next 200K minextents 1 maxextents 299) 4 / Note: there is one catch—the table cannot contain a column of the long datatype 3) Random advice: Don‘t go crazy about compressing tables into a single extent (or just a few extents). a.table_name =b.segment_name 9* and a.MAX_EXTENTS. a.table_name. a.owner and a.

Dave Ensor…). such as one of mine is to size growth rates for apx 1 extent per month When allocating storage for an Object (table or index). you do not want to be babysitting extent managment all the time—takes away from the really challenging DBA tasks! There are two good papers to read about extent sizing and fragmentation & Storage Management. Follow the traditional rules.com . you must should know you database & data Thus plan in advance—do calculations of the growth and set storage sizes appropriately – while the new tools allow you to do storage management on the fly.According to presentations at IOUG2000 — from Oracle‘s Performance Group. I have tested this in Oracle 8 and have confirmed this. So. In theory I shouldn‘t have to touch them for a long period of time. the number of outstanding extents that a table has DOES NOT IMPACT performance until a high number is reached — they have noticed performance slowdowns after 1000 extents—even with Locally managed Tablespaces. I like to set the initial extent size = next extent size. And while extents do grow. 1) ―How to Stop Defragmenting and Start Living: The Definitive Word on Fragmentation‖ from Oracle presented at OracleWorld 1999 2) I cannot remember the name—but the is a great paper on www. plus I place objects of the same extent sizes in the same tablespace: Why? This reduces the fragmentation of the extents and makes maximum efficient use of the tablespace‘s space (even with tables that grow and shrink dynamically) while reducing the possibility of creating dead space fragments.orapub. TUSC. & others (Mike Ault.

sum(bytes)/1024/1024 from dba_segments where owner = ‗SURVEYOR‘ group by owner. Recreate your repository find out export size before exporting. shutdown immediate.no backup files available. here is the chance to make your first consistent cold backup 7.sql script to recompile invalid database objects: .handle database recovery when datafile gets corrupted. 5. in 10g you can use expdp and find out the expected size of the export dump without the above sql queres.sql SQL script that is supplied with Oracle. 6. This script is maintained in the $ORACLE_HOME/rdbms/admin directory on your database server. startup mount.dbf‘ offline drop. startup 8.sum(bytes)/1024/1024 from dba_segments where owner = ‗DSADM‘ group by owner. compiling packages in sys schema This script will give you a list of invalid objects.segment_type. Here is an example of calling the utlrp.segment_type. alter database datafile ‗D:\oracle\oradata\ABCDev\OEM_Repository. select owner. alter database open. You can recompile invalid packages with the utlrp.segment_type . Copy all files. select owner. 3.dbf‘ with explorer 9. Delete ‗D:\oracle\oradata\ABCDev\OEM_Repository. non system datafile shutdown the database and Copy all the database files into some safe place !! 2. 4.segment_type . select owner. select owner.sum(bytes)/1024/1024 from dba_segments where owner = ‗SURVEYOR‘ group by owner .sum(bytes) from dba_segments group by owner order by owner. You can also manually recompile packages if you prefer.

Else. ORA-00376: file %s cannot be read at this time There was a problem accessing the datafile. . alter database datafile ‗C:\ORACLE\ORADATA\OFFLINE. SQL> select file#. The datafile or tablespace the datafile belongs to is either offline or the datafile is gone. If the status says ‗recover‘ then media recovery must be done by bringing the datafile online. alter tablespace offline_ts online. SQL> alter database datafile <full_path_datafile_name> online.status.status from dba_tablespaces. eg: SQL> select name. ORA-00376: file 40 cannot be read at this time . If the tablespace datafiles exist and are online and checked three times! check the following: Find the status of the tablespaces: SQL> select tablespace_name.@?/rdbms/admin/utlrp.name. status from v$datafile where status not in (‗ONLINE‘. To recovery the datafile try using the command: SQL> recover datafile ‗<full_path_of_datafile>‘.Oracle will automatically suggest the required file names and you just have to type enter if you agree.DBF‘ online. ORA-1113 will be encountered: Make sure that the archived log destination has all required archived files because when you execute recover command it will prompt you for exact archived log files that are required.sql 31)find deprecated parameters in 10g select name from V$PARAMETER where ISDEPRECATED = ‗TRUE‘. ‗SYSTEM‘) .enabled from v$datafile. Use the following query to find out the status of the datafiles.

Non Oracle Database Systems using plugins (from 10gR2). Listeners. To monitor more than one database. You need an additional license from that of the Database Server for Grid Control How to get a formatted explain plan? select plan_table_output from table(dbms_xplan. Then you have to set more oracle environment variables. OEM Database Control comes with Oracle Enterprise Edition and does 10g Grid control is a separate software or added with Oracle Enterprise Edition . So export ORACLE_HOME=/opt/oracle/product/10.null. they are replaced with Database Control (Java and HTML versions) and Grid Control respectively. To administer multiple database 10g grid control is better.‘ALL‘)).display(‗PLAN_TABLE‘. Either set the tablespace or datafile back online or – if the datafile is gone – restore the datafile. So. These include Application Servers. That‘s correct.0 . 10g Grid Control is the Enterprise version in that you can monitor different Target from different operationg systems at the same time. Among the both which will be good in terms of functionality. syntax for doing secure copy to different server scp filename oracleuser@servername:path difference between oracle 10g db control and grid control Database Control is the HTTP Management environment and comes installed with the 10g Database. It can be used to manage one database (one target) at a time (standalone).select * from v$recover_file. You go to OTN to download it or edelivery. It‘s not free whereas DB Console is. you must create a new console on a different port for each database. You will need a license for GC. Operation Systems. In 10g. for someone who was using OEM 9i. there was connection in to Standalone Console (Java) and Oracle Management Server (Java and HTML). find out oracle version on the server using unix commands sqlplus –version but this command may not tell you the correct version when there are multiple oracle homes.2.

all the dependent objects get invalid also. SOFAR. and if it‘s ok. if the compilation fails. 4. it will work. SQL> SELECT distinct object_name FROM dba_objects WHERE status=‘INVALID‘ when an object in oracle get‘s invalid. TOTALWORK. SELECT SID. unless you get anything in the view DBA_ERRORS which will contain the compilation errors.0/lib:$LD_LIBRARY_PATH Then sqlplus –version gives the right version all faqs about sqlplus errors can be found here http://www.oracle. @?/rdbms/admin/utlrp.And then Export LD_LIBRARY_PATH=/opt/oracle/product/10. Verify that all expected packages and classes are valid: SQL> SELECT count(*) FROM dba_objects WHERE status=‘INVALID‘. this is not a problem usually. the application running the sql with the invalid object will then get the relevant error message. ROUND(SOFAR/TOTALWORK*100. you don‘t need to worry. CONTEXT.sql 3. SERIAL#. oracle will try to compile it first. because when you try to use an objects that is marked invalid.com/technology/support/tech/sql_plus/htdocs/faq101.2) ―%_COMPLETE‖ FROM V$SESSION_LONGOPS WHERE OPNAME NOT LIKE ‗%aggregate%‘ AND TOTALWORK != 0 AND SOFAR <> TOTALWORK  invalid objects 1. .2.html#A4828 find out long running job processes and the work progress.

.ini step 3 after opening the iSQL*Plus page on Expolorer.ora) parameters Basic..... Type the address for ISQL*PLUS http://PC-NAME:5560/isqlplus/ Syntax http:// host_name:portnumber/isqlplus Check Computer Name à Right click on my computer Then properties Than click computer name to check Port number: oracle_home=where oracle software installed... oracle_home\install\portlist.Configure iSQL*PLUS STEP 1 goto dos prompt. start.. STEP 2 Open Any compatible Internet Browser.Cmd on command prompt type: isqlplusctl start after issuing the above command following prompt will displayed Starting iSQL*Plus .Run. advanced. Oracle 10g Database New Features Oracle 10g Database New Features Simplicity vs Flexibility • • • • – • – – – Automatic statistics gathering Advisories Automatic tuning Less than 30 basic (init. hidden parameters Easier operations alter tablespace rename flashback queries ―undrop‖ table Manageability .... iSQL*Plus started. LOGIN SCREEN ENTER username and password Now isqlplus started..

Can‘t rename SYSTEM or SYSAUX . Large Pool. bitmap_merge_area_size – Contents automatically managed Basic Parameters COMPATIBLE CONTROL_FILES DB_BLOCK_SIZE DB_CREATE_FILE_DEST DB_CREATE_ONLINE_LOG_DEST DB_DOMAIN DB_NAME DB_RECOVERY_FILE_DEST DB_RECOVERY_FILE_DEST_SIZE INSTANCE_NUMBER JOB_QUEUE_PROCESSES LOG_ARCHIVE_DEST_n LOG_ARCHIVE_DEST_STATE_n NLS_LANGUAGE NLS_TERRITORY OPEN_CURSORS PROCESSES REMOTE_LISTENER REMOTE_LOGIN_PASSWORDFILE ROLLBACK_SEGMENTS SESSIONS SHARED_SERVERS STAR_TRANSFORMATION_ENABLED UNDO_MANAGEMENT UNDO_TABLESPACE Rename Tablespace • • – Useful in Transportable Tablespace scenarios ALTER TABLESPACE prod RENAME to arc1. hash_area_size. Shared Pool.• – – – – • – – – SGA_TARGET Sets total size for all SGA components Buffer Cache. Java Pool Dynamically and automatically adjustable Automatic changes persist in SPFILE PGA_AGGREGATE_TARGET Available since 9i Sets total size target for all server processes sort_area_size. sort_area_retained_size.

– – Tablespace and all datafiles must be online Can also rename READ ONLY tablespaces Bigfile Tablespaces • – – – Support for sizes up to 8 Exabytes! 8 000 000 Terabytes Max 65535 files in database SYSTEM & SYSAUX can’t be bigfile tablespaces Crossplatform Transportable TS RMAN> CONVERT TABLESPACE sales_1. elapsed time: 00:00:45 Data Pump • • • • – • • • • • – – • • – – – – – – • A server-managed data transportation tool Direct load/extract capabilities Very high performance/efficient with large data sets Replacement for exp/imp old exp/imp remain supported Commands expdp/impdp Can use files or direct network transfer Dynamic configuration. DDL extract .. Transporting Tablespaces Between Databases input datafile fno=00004 name=/u01/oracle/oradata/salesdb/sales_101..dbf converted datafile=/temp/data_D-10_I-3295731590_TS-EXAMPLE_FNO-4_06ek24vl channel ORA_DISK_1: datafile conversion complete. .sales_2 2> TO PLATFORM ’Microsoft Windows NT’ 3> FORMAT ’/temp/%U’. resumable operations Client can detach and reconnect Can be parallelized using PARALLEL Even loads to/from external text files Parallelization level can be changed on the fly for long running jobs Monitored through DBA_DATAPUMP_JOBS Fine-Grained Object Selection exclude=function exclude=procedure exclude=package:‖like ‗PAYROLL%‘ ‖ include=table content=metadata_only | data_only | both query=―modify_date > sysdate-1‖ DDL Transformations.

FlashBack Database • – – – Flash Recovery Area must be configured Flashback logs are stored there Consisting of old database block images Fast ―rollback‖ of database. commit_scn. ALTER DATABASE FLASHBACK OFF."SALARY") values ('111'.--------. versions_startscn START_SCN.'Mike'. ALTER TABLESPACE test1 FLASHBACK OFF. empname. no redologs required FlashBack Database • • • • • • • Configuration parameters: DB_RECOVERY_FILE_DEST DB_RECOVERY_FILE_DEST_SIZE DB_FLASHBACK_RETENTION_TARGET Commands: ALTER DATABASE FLASHBACK ON. operation. table_name from dba_transaction_query where xid = ‘000200030000002D‘.---------. versions_operation OPERATION. XID START_SCN COMMIT_SCN OPERATION UNDO_SQL --."EMPNAME"."EMP" ("EMPNO".------.--------. start_scn.'655') 000200030000002D 112670 113565 I delete from "SCOTT".--------.employees_demo VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE where empno = 111. Flashback Row History SELECT versions_xid XID. XID START_SCN END_SCN OPERATION EMPNAME SALARY --.--------. undo_sql.------------------------000200030000002D 112670 113565 D insert into "SCOTT". salary FROM hr.------. ALTER TABLESPACE test1 FLASHBACK ON.-----0004000700000058 113855 I Tom 927 000200030000002D 113564 D Mike 555 000200030000002E 112670 113564 I Mike 555 3 rows selected • Useful for auditing Flashback Transaction History select xid."DEPT" . versions_endscn END_SCN.

. not dropped Indexes & other structures remain Table is purged when out of free space or quota SELECT * FROM RECYCLEBIN. Table is renamed internally. Systemwide recyclebin DBA_RECYCLEBIN Or show recyclebin command in sqlplus FLASHBACK TABLE RB$$3560$TABLE$1 TO BEFORE DROP RENAME TO scott. • DROP TABLE X PURGE. RBO is gone nowhere.gather_system_statistics(…) OPTIMIZER_DYNAMIC_SAMPLING (default: 2) Multiple Advisors SQL Access & Tuning Advisor Memory Advisors (SGA. it‘s available Optimizer able to use run-time statistics exec dbms_stats.where "DEPTNO" = '20' and "DEPTNAME" = 'Finance' 000200030000002D 112670 113565 D update ―SCOTT‖. etc.. Shared Pool. long live the CBO! Even data dictionary. etc. SYS tables using CBO However.) Segment Advisor (Fragmentation.emp.‖EMP‖ set ―SALARY‖ = ‗555‘ where ―EMPNO‖ = ‗111‘ and ‖EMPNAME‖ = ‗Mike‘ and ―SALARY‖ = ‗655‘ 3 rows selected Table Recovery using Flashback • – – – • – – • DROP TABLE X. Performance Tuning • – – • – – • – – – – RBO is dead. • PURGE RECYCLEBIN.) Undo Advisor Performance Troubleshooting • – – • – – – – Automatic Workload Repository Runtime execution statistics are gathered in memory MMON background process flushes stats to disk V$SQL_BIND_CAPTURE Samples bind variables for all sessions Faster than sql_trace (10046 trace on level 4) But doesn‘t capture all variable types And doesn‘t capture occurences of bindings .

sql scripts are executed also on CONNECT Other • – • • – – – • – dbms_scheduler calendar Expressions: Yearly. Weekly. UPDATE. 2010 Database Normalization explained. December 5. The Database Normalization eBook shows you . similar to default temporary tablespace in 9i * NYOUG General Meeting March 2004 Sunday. without using a lot of procedural coding (PL/SQL in Oracle. database must be closed mounted exclusively restricted default user tablespace specifies default tablespace for new users.sql and login. INSERT or DELETE) is difficult. If your design doesn't conform to (at least) the Third Normal Form (3NF). VB/C# in Microsoft products). Monthly. chances are high that you will find it hard to achieve the performance needed for a successful application. drop database. Understanding and mastering database normalization techniques is essential in order to achieve a high performance database design for your system.• – _cursor_bind_capture_interval defaults to 900 seconds Good for getting samples of database operations SQLPLUS Changes • – • • – • Improvements SPOOL CREATE | REPLACE | APPEND also works for SAVE command SHOW RECYCLE BIN SQLPROMPT runtime variable substitution SET SQLPROMPT "_USER'@'_CONNECT_IDENTIFIER >" glogin. you're well off. you will find that writing good DML-statements (SELECT. Hourly. Minutely. Secondely alter system flush buffer_cache. Many "experts" will tell you that if you do database normalization up to (and including) the Third Normal Form. Daily. and sometimes actually impossible. Furthermore.

2.props -jar %oracle_home%\oc4j\j2ee\home\jazn.0\db_1 D:\>set java_home=%oracle_home%\jdk D:\>set oracle_home oracle_home=d:\oracle\product\10. C:\Documents and Settings\orasoft>d: D:\>set oracle_home=d:\oracle\product\10.jar -user "iSQL *Plus DBA/admin" -password welcome -shell JAZN:> adduser "iSQL*Plus DBA" orasoft orasoft JAZN:> grantrole webDba "iSQL*Plus DBA" orasoft JAZN:> exit JAZN:> D:\oracle\product\10. 2010 Setting Up iSQL*Plus for SYSDBA Access Microsoft Windows XP [Version 5.2.security.2600] (C) Copyright 1985-2001 Microsoft Corp.2.security. for more Detail Click Here! Thursday.that this a far too easy approach.1. December 2. and it is richly documented with graphical Entity Relationship and Server Diagram examples.0\db_1\oc4j\j2ee\isqlplus\application-deployments\isqlplu s> %java_home%\bin\java -Djava.0\db_1 D:\>set java_home java_home=d:\oracle\product\10.0\db_1\jdk D:\>cd %oracle_home%\oc4j\j2ee\isqlplus\application-deployments\isqlplus D:\oracle\product\10.2.2.properties=%oracle_home%\oc4j\j2ee\home\c onfig\jazn.0\db_1\oc4j\j2ee\isqlplus\application-deployments\isqlplu s>exit now type following URL or your browser http://pc-name:port_number/isqlplus/dba to get your host name type following query on SQL Prompt .

select host_name from v$instance. to get Port number check in file . Managing Database Structure CHAPTER # 5 Managing Database Storage Structures LOGICAL AND PHYSICAL STRUCTURE OF DATABASE .

Logically. It is called row piece because under some circumstances the entire row may not be place in one place. A row is ultimately stored in a database block in the form of row piece. Each tablespace has many logical oracle data blocks. A set of extents that are allocated for a certain logical structure form one segment. A specific number of contiguous logical blocks form an extent. An oracle data block is the smallest unit of logical I/O.STORAGE STRUCTURES Page # 5-3 A database is divided into logical storage unit called tablespaces. a table contains rows of column values. A tablespace contains a collection of segments. This is happens when an inserted row is too large to fit into a single block or when an update causes an existing row to out groom its current space. The default size is 8 KB. HOW DATA IS STORED Page # 5-4 When a table is created. ANATOMY OF A DATABLOCK (CONTENT OF DB) Page # 5-5 . A logical block can range from 2KB to 32KB in size. The DB_BLOCK_SIZE parameter specifies how large a logical block is. a segment is created to hold its data.

Row data takes up free space as new rows are inserted or column of existing rows are updated with larger values. Index. The examples of events that cause header growth are when the row directory needs more row entries or more transaction slots are required. Table partition. This enables the (1) Header and the (2) Row Data space to grow when necessary. TABLESPACES AND DATA FILES Oracle stores data logically in tablespaces and physically in data files. The block header grows downward from the top ROW DATA: This is actual data for the rows in the block. Index Partition. which are used are used when modification are made to row s in the block. Cluster etc). Data Block Address. Row data space grows upward from the bottom.Oracles Data block contain the following: 123Block Header Row Data Free Space BLOCK HEADER: The block header contains The segment type (such as Table. Table Directory. Initially the free space in a block is contiguous.  Page # 5-6 TABLESPACES: . Row Directory and Transaction slots of size 23 bytes each. FREE SPACE: Free space is the middle of the block. However deletions and updates may fragment the free space in the block.

. Another database can have three tablespaces. Non-system Tablespaces SYSTEM TABLESPACES:  Created with the database . TYPES OF TABLESPACES There are two types of table spaces 1.Can belongs to only one tablespace and one database .Are further divided into logical storage of unit  DATA FILES: . System Tablespaces 2. each consisting of two data files (for a total of six data files) A single database can potentially have as many as 65534 datafiles. DATABASE.Can belongs to only one database at a time .Are repository (where information is stored) for schema object data. which are physical structures that conform to the operating system in which oracle is running. which collectively store all of the database‘s data. A database‘s data is collectively stored in the DATA FILES that constitute each tablespace of the database For example The simplest oracle database would have two table spaces (the required SYSTEM ams SYSAUX tablespaces) each with one data file. TABLESPACES AND DATAFILES Are closely related. but they have important differences. Each TABLESPACE in an oracle database consists of one or more files called data files.    An ORACLE DATABASE consists of one or more logical storage unit called tablespaces.Consist of one or more data files .

Tablespace can be created to use one of the following two different methods of keeping track of free and used space.    Required in all database Contains the data dictionary. Separate data by backup requirements Separate dynamic and statistics data Control the amount of space allocated to the user‘s objects. including stored program units. TEMPORARY. APPLICATION DATA.   Locally managed tablespaces Dictionary managed tablespaces LOCALLY MANAGED TABLESPACES: The extents are managed within the tablespace via bitmaps. Locally managed is the default beginning with ORACLE9i In locally managed tablespace Reduce contention on data dictionary tables . When an extent is allocated or freed for reuse. the oracle manages the bitmap values to show the new status of the blocks. & APPLICATION INDEX segments. SPACE MANGEMENT IN TABLESPACES Tablespaces allocate space in extents. Contains the SYSTEM undo segment Should not contain user data. Each bit in the bitmap corresponds to a block or a group of blocks. although it is allowed NON-SYSTEM TABLESPACES:      Enable more flexibility in database administration Separate UNDO.

CREATE TABLESPACE ON OEM SESSION Page # 5-10 Go to ORACLE ENTERPRISE MANAGER. Click on Administration Page Click tablespaces on STORAGE TAB Click on create button Enter the name of the table space Extend management LOCALLY Type PERMANENT Status READ WRITE  e.g: ABC  auto fixed  auto fixed  auto fixed . We can easily view the logical structure of our database through OEM. VIEW STORAGE STRUCTURE IN OEM Page # 5-9 Logical data structures are stored in the physical files of the database.No undo generated when space allocation or deallocation occurs No coalescing required The local option of the EXTENT MANAGEMENT clause specifies that a tablespace is to be locally managed. it is recommended that we use locally managed tablespaces. The oracle server update data dictionary whenever extent allocated or unallocated. This is the backward capability. Detailed information about each structure can be obtained by clicking the links in the Storage Region of the Administration Page. DICTIONARY MANAGED TABLESPACES: The extents are managed by the data dictionary. By default a tablespace is locally managed.

To see the information of the tablespace we create above perform the query SELECT TABLESPACE_NAME.dbf Enter the size of datafile Goto Storage Tab Check on AUTOMATICALLY EXTENT And give the size of increment in KB. Tablespace created.DBF' SIZE 50M.0\ORADATA\ORCL2\ CREATE TABLESPACE ON SQL*PLUS SESSION FOR DATABASE 10g RELEASE 1 & 2 (same path) CREATE TABLESPACE AAAA DATAFILE 'E:\ORACLE\PRODUCT\10. .g: 10 MB by default 100 MB size is given Now table space has been created in the location of E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\AAAA01.Go Datafile Section Click on add datafile Enter the name of datafile  e.1.g: 100KB Maximum size check unlimited  means file grow to unlimited size  e.  e.g: abc01.

STATUS.------------------.-----------LOGGING PERMAN LOCAL SYSTEM AUTO In The Above Tablespace We Give Tablespace Name and Path of Datafile with Size We see by default PAREMTER set with the tablespace LOGGING. CONTENTS. ALLOCATION_TYPE.----------------. TS_NAME STATUS LOGGING CONTENTS EXTENT_MAN ALLOCATIO SEGMEN ------------. EXTENT_MANAGEMENT. CONTENETS.--------------. SEGMENT SPACE MANAGEMENT Logging Default / No Logging Permanent Default / Temporary / Undo Locally Default / Dictionary System Default / Local Uniform Size Automatic Default / Manual There Are Two Modes of Logging 1) Logging 2) No Logging  Logging . ALLOCATION TYPE.----------AAAA ONLINE ------------. LOGGING. SEGMENT_SPACE_MANAGEMENT FROM DBA_TABLESPACES WHERE TABLESPACE_NAME='AAAA'. EXTENT_MANAGEMENT.

indexes. MINIMUM EXTENT.LOGGING: specifies that. LOGGING IS THE DEFAULT. This is obsolete now. The default size 100 MB There Are Two Type of Segment Space Management for locally managed tablespace. and partition within the tablespace have all changes written to online redo log files. NOTE: If you specify LOCAL you cannot specify DEFAULT storage_clause. 1)Automatic 2) Manual . LOCALLY MANAGED: Specifies that the tablespace is managed via bitmap. or TEMPORARY STROAGE FOR LOCALLY MANAGED TABLESPACE Page # 5-12 The extents with in the locally managed tablespace can be allocated in one of these two ways: 1) System or autoallocate or automatic 2) Uniform 1) SYSTEM OR AUTOALLOCATE OR AUTOMATIC  Allocatin_type By default allocation types is system or autoallocate or automatic if we do not specify extent management local clause means the size of extent within the tablespace are system managed. There Are Three Types of Contents 1) Permanent 2) Temporary 3) Undo  Contents There Two Type of Extent Management  1) Local 2) Dictionary Extent_management DICTIONARY MANAGED: Specifies that the tablespace is managed using dictionary tables. 2) UNIFORM For uniform allocation we must give extent management clause and specify uniform size specifies that the TB is managed with uniform extent size. NOLOGGING: means do not write all changes to online redo log files. by default all tables.

Local management avoids recursive space management operations. The size of extents are managed locally can be determined automatically by the system. NOTE: If we are managing a database that has dictionary managed tablespaces and we want to convert them to locally manged tablespace. 3.DBF' SIZE 50M 3 NOLOGGING 4 OFFLINE 5 EXTENT MANAGEMENT LOCAL UNIFORM SIZE 100K . 1.1) AUTOMATIC:  Segment_Space_Management Oracle database uses bitmaps to manage the free space within segments. 4. 2.2. Locally managed tablespace do not record free space in the data dictionary tables. Changes to the extent bitmaps do not generate undo information. they reduce contention on these tables.0\ORADATA\BBBB01.TABLESPACE_MIGRATE_TO_LOCAL Create another tablespace other than default parameters 1 CREATE TABLESPACE BBBB 2 DATAFILE 'E:\ORACLE\PRODUCT\10. 2) MANUALL: Specifies that we want to use free list for managing free space within segments. ADVANTAGES OF LOCALLY MANAGED TABLESPACES: Locally managed tablespaces have the following advantages over dictionary managed tablespaces. use the DBMS_SPACE_ADMIN.

8 SEGMENT_SPACE_MANAGEMENT 9 FROM DBA_TABLESPACES 10 WHERE TABLESPACE_NAME IN ('AAAA' . 12SYSTEM SYSAUX Page # 5-14 . 4 LOGGING.-----------LOGGING PERMAN LOCAL SYSTEM AUTO OFFLINE NOLOGGING PERMANENT LOCAL UNIFORM MANUAL TABLESPACE IN THE PRECONFIGUED DATABASE: There are six tablespace that are automatically created with the database creation. 'BBBB'). 7 ALLOCATION_TYPE.------------------.--------------. Now perform the above query to see the parameters of the tablespace AAAA and BBBB SQL> SELECT 2 TABLESPACE_NAME. 5 CONTENTS. Tablespace created. 3 STATUS.----------AAAA BBBB ONLINE LOGGING CONTENTS EXTENT_MAN ALLOCATIO SEGMEN ------------. 6 EXTENT_MANAGEMENT. TS_NAME STATUS ------------.6 SEGMENT SPACE MANAGEMENT MANUAL.----------------.

TEMP Temporary tablespace is used when we execute a SQL statement that require sorting. This tablespace is created at database creation time. It contains the data dictionary and tables that contain administrative information about the database. In the preconfigured database. Some components and product that are earlier used by SYSTEM tablespace now use the SYSAUX tablespace. Create TEMPORARY tablespace . This means that if no temporary tablespace is specified when the user is created. These all contained in SYS schema and can be access by the SYS and system users or other administrative users. The tamp tablespace is defined as the default tablespace for sorting data. In OEM we can see a pie chart of the contents of this tablespace. EXAMPLE This tablespace contains the sample schemas that can be installed when we create the database. UNDOTBS1 This is the undo tablespace used by the database server to store undo information. USERS This tablespace is used to store permanent user objects and data.3456- TEMP UNDOTBS1 USERS EXAMPLE SYSTEM The system tablespace is used by the oracle server to manage the database. the user tablespace is the default tablespace for all objects created by NONSYSTEM users. SYSAUX This is an auxiliary tablespace to the system tablespace. the oracle database assigns this tablespace to the user.

2.DBF' SIZE 10M. Tablespace created. Page # 5-16 .0\ORADATA\ORCL\UNDOO01. FOR DATABASE 9i RELEASE 2 SQL > CREATE TABLESPACE ABCD DATAFILE 'D:\ORACLE\ORADATA\ORCL\ABCD01. We can set default temporary tablespace for all users ALTER DATABASE DEFAULT TEMPORARY TABLESPACE KHAN.0\ORADATA\ORCL\KHAN01.DBF' SIZE 50M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K.2. Restore default temporary tablespace ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP.DBF' SIZE 100M. ALTER A TABLESPACE We can alter any tablespace in several ways as the need of your system change. Create UNDO tablespace CREATE UNDO TABLESPACE UNDOO1 DATAFILE 'E:\ORACLE\PRODUCT\10. Tablespace created. Database altered.CREATE TEMPORARY TABLESPACE KHAN TEMPFILE 'E:\ORACLE\PRODUCT\10. Database altered.

C  After the tablespace creation. RESIZING A TABLESPACE a.Read write 2.RESIZING A TABLESPACE: a- We can resize of any tablespace by adding a new datafile SQL> ALTER TABLESPACE AAAA ADD DATAFILE 'E:\ORACLE\PRODUCT\10. 2 BY CHANGING THE STATUS OF TABLESPACE A Tablespace can be in one of the three different status or states.DBF' SIZE 5M. Tablespace altered.We can resize of any tablespace by adding a new datafile b. B  At the time of tablespace creation.Offline 1.Read only 3.1  By manually using alter database command B.2 Automatically using AUTOEXTEND A  At the time of database creation.By changing the size of datafile B.2. b- By changing the size of datafile We can enlarge a tablespace by .0\ORADATA\ORCL\AAAA03.1. 1.

When we create database at that time use AUTOEXTEND ON with the datafile 2.By manually using ALTER DATABASE 2. We can also decrease the size of data file NOTE: If there are database objects stored above the specified size.DBF' RESIZE 10M.At the time of tablespace creation. then the datafile is decrease only to the last block of the last object in the datafile 2Automatically using AUTOEXTEND We can use AUTOEXTEND clause in three ways. 3. 2. At the time of tablespace creation.At the time of database creation.0\ORADATA\ORCL\AAAA02.2. Tablespace altered. 1.Automatically using AUTOEXTEND 1By manually using ALTER DATABASE SQL> ALTER DATABASE DATAFILE 'E:\ORACLE\PRODUCT\10. CREATE TABLESPACE AAAA .1. After the tablespace creation. 1. At the time of database creation.

After the tablespace creation. ALTER DATABASE DATAFILE 'E:\ORACLE\PRODUCT\10. Tablespace created. SQL> DESC DBA_DATA_FILES Name Null? Type ----------------------------------------.DBF' SIZE 10M AUTOEXTEND ON. Determining wether AUTOEXTEND is ENABLED or DISABLED We use DBA_DATA_FILES view.DBF' AUTOEXTEND ON.2. 3. Database altered.2.-------.0\ORADATA\ORCL\AAAA01.DATAFILE 'E:\ORACLE\PRODUCT\10.---------------------------FILE_NAME FILE_ID TABLESPACE_NAME BYTES BLOCKS STATUS RELATIVE_FNO VARCHAR2(513) NUMBER VARCHAR2(30) NUMBER NUMBER VARCHAR2(9) NUMBER .0\ORADATA\ORCL\AAAA01.

0\ORADATA\ORCL\ABC01. FILE_NAME.------------------------------------------------------USERS SYSAUX UNDOTBS1 SYSTEM EXAMPLE ABC ABCD ABC1 XYZ BBBB UNDOO1 AAAA E:\ORACLE\PRODUCT\10.0\ORADATA\ORCL\USERS01.DBF E:\ORACLE\PRODUCT\10.0\ORADATA\ORCL\SYSAUX01.AUTOEXTENSIBLE MAXBYTES MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS ONLINE_STATUS VARCHAR2(3) NUMBER NUMBER NUMBER NUMBER NUMBER VARCHAR2(7) SQL> SELECT TABLESPACE_NAME.2.0\ORADATA\ORCL\AAAA01.DBF E:\ORACLE\PRODUCT\10.DBF E:\ORACLE\PRODUCT\10. TABLESPACE_NAME FILE_NAME AUTOEXTENSIB --------------------YES YES YES YES YES NO NO YES NO NO NO YES -----------------------------.2.2.DBF E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ABC101.2.2.DBF .2.2.DBF E:\ORACLE\PRODUCT\10.2.2.0\ORADATA\BBBB01.DBF E:\ORACLE\PRODUCT\10.DBF E:\ORACLE\PRODUCT\10. AUTOEXTENSIBLE FROM DBA_DATA_FILES.0\ORADATA\ORCL\UNDOO01.0\ORADATA\ORCL\UNDOTBS01.2.DBF E:\ORACLE\PRODUCT\10.0\ORADATA\ORCL\EXAMPLE01.0\ORADATA\ORCL\SYSTEM01.2.DBF E:\ORACLE\PRODUCT\10.0\ORADATA\ORCL\XYZ01.0\ORADATA\ORCL\ABCD01.DBF E:\ORACLE\PRODUCT\10.DBF E:\ORACLE\PRODUCT\10.

2. We cannot offline temporary tablespace until new default is not available.BY CHANGING THE STATUS OF TABLESPACE A Tablespace can be in one of the three different status or states. When the tablespace in read only mode. Tablespace altered. No further write operation can occur in the tablespace except existing transaction can be completed (committed or rollback) Tablespace is online while in read-only state. . Any of the following states may not be available because their availability depends on the type of tablespace. Because these command affect only the data dictionary. We cannot offline SYSTEM and SYSAUX tablespace. We cannot alter a temporary tablespace to permanent.Read write 2. For Example if tablespace type is permanent. SQL> ALTER TABLESPACE AAAA READ ONLY. For Example if tablespace type is default temporary. READ ONLY MODE: We can set permanent tablespace to read only mode by using alter tablespace command.Read only 3.Offline By default the status of the tablespace is Read Write. 1. Object can be dropped from read only status of tablespace.

but we use the temporary clause. However. the tablespace require recovery before you can bring it back online. we can use the following options. The oracle database ensures that all data is written to disk by taking a checkpoint for all the data files of the tablespace as it take them offline. ALTER TABLESPACE AAAA OFFLINE TEMPORARY. if one or more files of the tablespace are offline because of write error. . performing check pointing on them as it does so. media recovery is not required to bring the tablespace back online. The oracle database take the data files (which are not already offline) offline. b) OFFLINE TEMPORARY A tablespace can be taken offline temporarily if there are errors conditions exist for one or more data files of the tablespace. Tablespace altered. Tablespace altered. If no files are offline. and we take the tablespace offline temporarily. For normal offline there is no need to write NORMAL SQL> ALTER TABLESPACE AAAA OFFLINE. When we take tablespace offline.OFFLINE MODE: We can take an online tablespace offline so that this portion of the database is not available for general use. The rest of the database is open and available for users to access data. a) NORMAL b) TEMPORARY c) IMMEDIATE d) FOR RECOVER a) OFFLINE NORMAL A tablespace can be taken offline normally if no error conditions exist for any of data files of the tablespace.

Oracle recommends a backup before and after dropping a tablespace. the objects and data in it will no longer be available. DROP TABLESPACE BBBB. When we specify immediate. SQL> ALTER TABLESPACE AAAA OFFLINE IMMEDIATE. Use Contents and data file option DROP TABLESPACE BBBB INCLUDING CONTENTS AND DATAFILE.c) OFFLINE IMMEDIATE A tablespace can be taken offline immediately without the oracle database taking a checkpoint on any of the data files. The syntax is supported for backward compatibility. Tablespace altered. d) OFFLINE FOR RECOVER The for recover setting has been depreciated. INCLUDING CONTENTS: Drops all segments in the tablespace . Tablespace dropped. DROPPING TABLESPACE Page # 5-21 Once a tablespace has been dropped. To recover them can be a time consuming process. Tablespace dropped. media recovery for the tablespace is required before the tablespace can be brought online. NOTE: We cannot take a tablespace offline immediate if the database is running in NOARCHIVELOG mode.

Some restriction when we drop any tablespace     We cannot drop system and sysaux tablespace We cannot drop temporary tablespace until new default is not available We cannot drop a tablespace that contains any active undo segments.-----TS# NAME INCLUDED_IN_DATABASE_BACKUP BIGFILE FLASHBACK_ON SQL> select ts#. Page # 5-22 TO VIEWING TABLESPACE INFORMATION ON SQL*PLUS SQL> desc v$tablespace Name Null? Type ----------------------------------------------------------------------------------.-----------------------------0 SYSTEM 1 UNDOTBS1 2 SYSAUX NUMBER VARCHAR2(30) VARCHAR2(3) VARCHAR2(3) VARCHAR2(3) . When we drop any tablespace the operating system file cannot delete at the same time we can delete the tablespace than we can delete data file manually from the operating system. TS# NAME ---------. name from v$tablespace.AND DATA FILE: Delete the related operating system file CASCADE CONSTRAINTS: Drop referential integrity constraints from table outside the tablespace.-------.

SQL> desc dba_tablespaces Name Null? Type ----------------------------------------------------------------------------------.-------.4 USERS 3 TEMP 6 EXAMPLE 7 ABC 8 SCOTT1 8 rows selected.-----TABLESPACE_NAME BLOCK_SIZE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE MIN_EXTLEN STATUS CONTENTS LOGGING FORCE_LOGGING EXTENT_MANAGEMENT ALLOCATION_TYPE NOT NULL VARCHAR2(30) NOT NULL NUMBER NUMBER NUMBER NOT NULL NUMBER NUMBER NUMBER NUMBER VARCHAR2(9) VARCHAR2(9) VARCHAR2(9) VARCHAR2(3) VARCHAR2(10) VARCHAR2(9) .

LOGGING. VARCHAR2(3) VARCHAR2(6) VARCHAR2(8) VARCHAR2(11) VARCHAR2(3) TO VIEWING DATAFILE INFORMATION ON SQL*PLUS Page # 5-22 SQL> DESC V$DATAFILE Name Null? Type ----------------------------------------. STATUS. ALLOCATION_TYPE. SEGMENT_SPACE_MANAGEMENT FROM DBA_TABLESPACES . CONTENTS.PLUGGED_IN SEGMENT_SPACE_MANAGEMENT DEF_TAB_COMPRESSION RETENTION BIGFILE Query to view thee information of tablespace perform the query SELECT TABLESPACE_NAME.-------.---------------------------FILE# CREATION_CHANGE# CREATION_TIME NUMBER NUMBER DATE . EXTENT_MANAGEMENT.

4.TS# RFILE# STATUS ENABLED CHECKPOINT_CHANGE# CHECKPOINT_TIME UNRECOVERABLE_CHANGE# UNRECOVERABLE_TIME LAST_CHANGE# LAST_TIME OFFLINE_CHANGE# ONLINE_CHANGE# ONLINE_TIME BYTES BLOCKS CREATE_BYTES NUMBER NUMBER VARCHAR2(7) VARCHAR2(10) NUMBER DATE NUMBER DATE NUMBER DATE NUMBER NUMBER DATE NUMBER NUMBER NUMBER CHAPTER # 6 Administering User Security Managing Users 1. 3. Create new database users Alter database users Drop database users Monitoring information about existing users Obtain user information Page # 6-3 DATABASE USER ACCOUNTS: . 2. 5.

a user must specify a valid database user account and successfully authenticate as required by that user account.To access the database. The database administrator defines the names of the users who are allowed to access the database. Security domain include 1) A unique user name 2) Authentication mechanism 3) Tablespace quota 4) Default tablespace 5) Temporary tablespace 6) Account locking 7) Resource limit 8) Direct privilege 9) Role privilege AUTHENTICATION MECHANISM A user can access the database can be authenticated by on of the following A) Data dictionary (PASSWORD) B) Operating system (EXTERNALLY) C) Network (GLOBAL) Means of authentication can be defined at the time of user creation or Can be defined later by ALTER command In this lesson we study Data dictionary & Operating System Authentication. Each user account has A security domain defines the settings that apply to the users. TABLESPACE QUOTA .

If user does not explicitly define the tablespace at the time of segments are created. DIRECT PRIVILEGE Privilege are used to control the action that a user can perform in a database ROLE PRIVILEGE A user can be granted privileges indirectly through the use of roles. . TEMPORARY TABLESPACE Temporary tablespace are the location where extent are allocated by the oracle server if the user performs the operation like sorting the data. A user can be associated with one schema only. DEFAULT TABLESPACE Default tablespace are the location where segments that are created by user are stored. clusters. of session a user open. When we create any user we must consider the following point that called checklist for creating user. DATABASE SCHEMA A database schema is a named collection of object such as (tables. procedures and packages) that is associated with the particular user. This can be cover next part of this lesson. When a database user is created a corresponding schema with the same name is created for that user. ACCOUNT LOCKING User account can be lock to prevent the user when user logging on the database. This can be done automatically or the DBA can lock / unlock the a/c manually.Tablespace quota controls the amount of physical storage that is allowed to the user in the tablespace in the database. views. Therefore user and schema are often used interchangeably. RESOURCE LIMIT Limits can be places on the user of resources such as CPU time / Logical I/O / No.

Grant privileges and assign role to the user.Objects are reorganized and places on different tablespaces. CREATING A USER IN SQL*Plus BY PASSWORD Page # 6-6 Create user abc1 Identified by abc1 Default tablespace example Temporary tablespace temp Quota 15m on example Quota unlimited on users Password expire.Identify the tablespace where user stores objects. . NOTE: When this users creates objects by default objects are kept on example tablespace. 2. 3.An application is enhanced and requires more table or indexes. Quota : Maximum space allowed to the user for objects in any tablespace.Table owned by user grow continuously 2. CHANGING USER QUOTA ON TABLESAPACES We can modify user table quotas in following situations 1. Quota can be define integer byte/ kilo bytes (KB) and megabytes (MB) Unlimited: This keyword use for user can use as much as space available in any tablespace.Assign a default tablespace and temporary tablespace 4. If the user wants to kept object on another tablespace than must give tablespace name at the end of object.Decide tablespace quota for each tablespace 3.1.

Important note: after 0 qouta assign to user then no new extent can be allocated for the objects of user. Step#4 SQL> ALTER SYSTEM SET REMOTE_OS_AUTHENT = TRUE SCOPE = SPFILE. Step#3 Page # 6-6 SQL> ALTER SYSTEM SET OS_AUTHENT_PREFIX =" " SCOPE = SPFILE. User altered. System altered. Step#2 SQL> GRANT CONNECT. OR Alter user abc1 Quota 0 on users. CREATING A USER IN SQL*Plus BY EXTERNALLY Step#1 SQL> CREATE USER RAHEEL IDENTIFIED EXTERNALLY. .Than we use ALTER USER command to solve this problem SQL> ALTER USER ABC1 2 QUOTA 10M ON USERS. System altered. Grant succeeded. RESOURCE TO RAHEEL. User created.

2.ora file on notepad from the path C:\oracle\product\10. Step#6 Now create a new user Click Start  Setting  Control Panel  User Account  Create a New Account  Enter User name same as we create on SQL*Plus (RAHEEL)  Check on Limited  click NEXT  Select the account we create  Click Create Password  Enter Password  Than click Create Password Step#7 Click Start  Setting  Control Panel  Administrator Tools  Computer Management  Click on Local User & Groups  Double Click on Users  Right Click (The User Which We Create in Operating System ‗RAHEEL‘) Select Properties  Select Member Of Tab  Click on Add  Click on Advance  Than click on Find Now  Select Ora_dba  Than Click Ok 3 Times Step#8 Restart All Oracle services from services.msc Step#9 Log of current User Step#10 Log on the user we create RAHEEL Step#11 .ora And change the parameter #SQLNET.AUTHENTICATION_SERVICES= (NTS)  hash sign of previous SQLNET.0\db_1\NETWORK\ADMIN\sqlnet.Step#5 Open sqlnet.AUTHENTICATION_SERVICES= (NONE)  type new Save and close the file.

TO GET INFORMATION ABOUT THE USERS OF ORACLE USE THIS QUERY SQL> DESC DBA_USERS name null? Type -----------------------------------------. UNLOCKING A USER ACCOUNT AND RESETTING THE PASSWORD THROUG OEM AND SQL*PLUS Page # 6-10 ALTER USER SCOTT IDENTIFIED BY TIGER ACCOUNT UNLOCK. If we want to remove the user and its associated objects then we use cascade option DROP USER ABC1 CASCADE.Open SQL*PLUS and enter / on password window Now we connect to the ORCL database.--------------username user_id password account_status not null not null not null varchar2(30) number varchar2(30) varchar2(32) . User Altered DROPING A USER A user can be drop by using the following command DROP USER ABC1.---------.

Connect to database . name null? Type ----------------------------------------------------------------. The oracle database enables you control what user can or cannot do within the database These include the right to 1.lock_date expiry_date default_tablespace temporary_tablespace created profile initial_rsrc_consumer_group external_name not null not null not null not null date date varchar2(30) varchar2(30) date varchar2(30) varchar2(30) varchar2(4000) IF WE GET THE INFORMATION ABOUT TABLESPACE QUOTA OF USERS THEN DESC DBA_TS_QUOTAS.-------.-----tablespace_name username bytes max_bytes blocks max_blocks not null varchar2(30) not null varchar2(30) number number not null number number Managing Privileges WHAT IS PRIVILEGE ? A privilege is a right to execute a particular type of SQL statement or to access another user's object.

Granting privileges to all users (public) . For example the privilege of create tablespace is the system privilege. There are more then a hundred distinct system privileges.Execute another user stored procedure There are two types of oracle user privileges 1. Without specific permission. user can access only their own objects. Many system privileges contain the ANY clause.Object privileges: 1. procedure.Grant and revoke access to perform system functions 3.Create a table 3. view. Object privileges can be granted by the owner of an abject. System privileges can be granted by the administrator or by someone who explicitly give permission to administrator the privilege.Providing a user the right to perform a type of operation 2.OBJECT PRIVILEGES: Each object privilege allows a user to perform particular action on a specific object For example a table.2.SYSTEM PRIVILEGES: Each system privilege allows a user to perform a particular database action or class of database operations. 2. A DBA's control of privileges include 1.Select rows from another user table 4. factions or package.System privileges: 2. by the administrator.Grant privileges directly to the users or to roles 4. or by someone who has been explicitly given permission to grant privileges on the object. sequences.

Privileges that enable management of objects in a user’s own schema Example: Create Table 3. Privileges can be classified as 1. REVOKE COMMAND Delete the privileges. Revoke and Grand are the DDL commands. MOST COMMON SYSTEM PRIVILEGES ARE Index : Create any index Alter any index Drop any index Table : Create table Create any table Alter any table . Privileges that enable system-wide operation Example: Create Session. Privileges that enable management of objects in any schema Example Create Any Table ANY KEYWORD Signifies that user have the privilege in any schema GRANT COMMAND Signifies add a privilege to a user or a group of users.SYSTEM PRIVILEGES: There are more than 100 system privileges. Create Tablespace 2.

the Create Table Privilege allows you to create a table but only within your own schema.Create table include the create index and the analyze commands.Privilege such as create table. . But Create Any Table Privilege allows you to create table your own schema as well as . .The drop any table privilege is necessary to truncate a table in another schema. .Drop any table Select any table Update any table Delete any table Session : Create session Alter session Restricted session Tablespace: Create tablespace Alter tablespace Drop tablespace Unlimited tablespaces IMPORTANT NOTE: . For example. create procedure. NOTE: Granting a privilege with ANY clause means that the privilege crosses schema lines. create cluster include dropping this objects.User must have quota on tablespace or must have Grant unlimited tablespace.There is no create index privilege because .Unlimited tablespace cannot be granted to role .

Alter tablespace begin/end backup SYSOPER 1.other user‘s schemas. Selecting With Admin Option check box enables you to administrator the privilege and Grants the system privilege to other users.Having SYSOPER privileges with admin option 2. and perform recovery and other administrative tasks in the database. Carefully consider security requirements before granting system permissions.  SYSDBA and SYSOPER: These privileges allow you to shutdown. 1) Restricted Session 2) SYSDBA and SYSOPER 3) Drop Any Object 4) Create Any Directory 5) Grant Any Object Privilege 6) Alter Database and Alter System  Restricted Session: This privilege allows you to log in even if the database has been opened in restricted mode. Differentiates SYSDBA And SYSOPER Privileges SYSDBA 1. It includes the following system privileges. some system privileges are usually granted only to administrator. SYSOPER allow a user to perform basic operational tasks.Startup / shutdown 2. but without the ability to look at the user data. startup.Alter database open | mount 3.Alter database backup control file to recover database .Create database 3.

With the create any directory privilege. Manage. As a security measure. the opening system directory where the code resides must be linked to a virtual oracle directory object.4.Alter database Recover (Complete Recover  Drop Any Object The Drop Any privilege allows you to delete objects that other users own.  Create Any Directory: The oracle database allows developers to call external code (for example. you can potentially call insecure code objects. Drop and Alter Tablespace: These privileges allow for tablespace administration including creating. dropping and changing their attributes. a C library) from within PL/SQL.Restricted session 5. such as renaming a data file or flushing the buffer cache.  Create.Recover database until ( MEANS: past recovery ) 6.  Alter Database and Alter System: These very powerful privileges allow you to modify the database and the oracle instance.Deletion of Database 4.  Grant Any Object Privilege: This privilege allows you to grant object permissions on objects that you do not own.Alter database archive log 5.Restricted session 6. HOW TO GRANT SYSTEM PRIVILEGES ON SQL*PLUS .

For example: Select Any Table System privileges allow the user to accessing the objects of any schema but do not allow to access the object in sys/ dictionary schema. This was oracle 7 behavior. .----boolean false This parameter control restrictions on system privileges If set to true Allow access to objects in sys schema For example: Select Any Table System privileges allow the user to accessing the objects of any schema as well as sys/ dictionary schema.SQL > Grant create session to emi. If Grantee Want To Further Grant The System Privilege Then We Use With Admin Option SQL > Grant create session to emi with admin option. Now default is false means Do not allow access to sys schema. Note: WITH ADMIN OPTION privilege is usually reserved for security administrator and is rarely granted to other users. RESTRICTIONS ON SYSTEM PRIVILEGES SQL > Show parameter o7_dictionary_accessibility name -----------------------------------o7_dictionary_accessibility type value ----------.

HOW TO REVOKE SYSTEM PRIVILEGES ON SQL*PLUS Use REOVKE command to remove a system privilege from a user Only privileges granted with a GRAND command can be revoked Revoke create table from emi. REVOKING SYSTEM PRIVILEGES WITH ADMIN OPTION There are no cascading effects when a system privilege is revoked. regardless of whether it was given with admin option SCENARIO If DBA grant Create Session. IMPORTANT NOTE: The revoke command can only revoke privileges that have been granted directly with a grant option. create table privilege from UMAR RESULT: UMAR table still exist but no new table can be create OWAIS table still exist and have to create further new table as OWAIS want Therefore no effect on OWAIS because system privileges are independent NOTE : DBA having the ability to revoke system privilege from any user . Create Table Privilege With Admin Option to UMAR UMAR create table in his schema And UMAR give Create Session. Create Table privilege to OWAIS OWAIS create table in his schema NOW DBA revoke create session.

User created. SQL> CREATE USER SSS IDENTIFIED BY SSS DEFAULT TABLESPACE ABC QUOTA 5M ON ABC.If DBA grant create session with admin option to UMAR And UMAR give create session to OWAIS However DBA having the ability to revoke directly OWAIS privilege. STEP # 1 Connect to sys and Create 2 users with default tablespace and quota SQL> CONN SYS/ORACLE AS SYSDBAS Connected SQL> CREATE USER SSS IDENTIFIED BY RRR DEFAULT TABLESPACE ABC QUOTA 5M ON ABC. User created. . STEP # 2 Now DBA grant system privileges to user 1 (RRR) SQL> GRANT CONNECT TO RRR WITH ADMIN OPTION.

. Table created. SQL> CREATE TABLE AAA ( 2 NAME VARCHAR2(20)). SQL> GRANT CREATE TABLE TO SSS WITH ADMIN OPTION. STEP # 4 User 1 (RRR) grant system privileges to user 2 (SSS) SQL> GRANT CONNECT TO SSS WITH ADMIN OPTION . SQL> INSERT INTO AAA 2 VALUES 3 ('RAHEEL'). SQL> GRANT CREATE TABLE TO RRR WITH ADMIN OPTION.Grant succeeded. Grant succeeded. 1 row created. Grant succeeded. STEP # 3 Now connect to user 1 (RRR) and create objects and insert the values SQL> CONN RRR/RRR Connected.

Revoke succeeded. SQL> REVOKE CREATE TABLE FROM RRR.Grant succeeded. STEP # 5 Connect to user 2 (SSS) create objects and insert values SQL> CONN SSS/SSS Connected. Table created. SQL> INSERT INTO BBB VALUES ('SOVSTM'). . STEP # 6 Connect to sys and REVOKE system privileges from user 1 (RRR) SQL> CONN SYS/ORACLE AS SYSDBA. 1 row created. Connected. SQL> CREATE TABLE BBB ( NAME VARCHAR2(20)).

SQL> CREATE TABLE EMP ( EMPNO NUMBER(4)). Table created.STEP # 7 Connect user 1 (RRR) and create abject now user one receive an error of insufficient privileges SQL> CONN RRR/RRR Connected. SQL> CREATE TABLE EMP ( 2 EMONO NUMBER(4)). SQL> CONN SSS/SSS Connected. CREATE TABLE EMP ( * ERROR at line 1: ORA-01031: insufficient privileges STEP # 8 Connect user 2 (SSS) and create abject now user one successfully create object. Because SYSTEM PRIVILEGES are independent. .

EMP TO AAA. or package.SQL> INSERT INTO EMPNO VALUES (1111). . function. HOW TO GRANT OBJECT PRIVILEGES ON SQL*PLUS SQL > GRANT UPDATE ON SCOTT. procedure. 1 row created. view.EMP TO AAA WITH GRANT OPTION. USE WITH ADMIN OPTION Means user has able to transfer this grant to other GRANT UPDATE ON SCOTT. sequences. OBJECT PRIVILEGES: Object Privileges ALTER DELETE EXECUTE INDEX INSERT REFERENCES SELECT UPDATE Table Y Y Y Y Y Y Y View Y Y Y Y Y Y Y Sequence Y Y Procedure An object privilege is a privilege or right to perform a particular action of user on a specific table. This slide does not provide complete object privileges but commonly used objects. Each object has a particular set of grantable privileges.

User revoking the privileges must be the original granter of the object privilege being revoked REVOKE SELECT ON SCOTT. SQL> CONN TO SYS/ORACLE AS SYSDBA.EMP FROM AAA. User created. SCENARIO If user AAA grant SELECT object privilege on EMP WITH GRANT OPTION to BBB And BBB grant the SELECT privilege on EMP to CCC Later user AAA revoke SELECT privilege from BBB Result: This revoke also apply on CCC means (CCC do not has the right of select EMP) Therefore effect on CCC because object privileges are dependent STEP # 1 Connect to sys and Create two users and grants connect resource to both users. Connected SQL> Create User UMAR Identified By UMAR. .REVOKING OBJECT PRIVILEGES Use the revoke command to revoke object privileges.

CHAPTER # 4

Managing The Oracle Instance

MANAGEMENT FRAME WORK

There are three components of the oracle database 10g management framework:

  

A Database instance that is being managed A Listener that allows connections to the database The Management Interface. This may be either a Management Agent running on the database server (which connects it to oracle enterprise manager grid control) OR The stand-alone Oracle Enterprise Manager Database Control also called DATABSE CONSOLE

NOTE : Each of these components must be explicitly started before we can use the service of the component and must be shutdown cleanly when shutting down the Oracle Database.

STARTING AND STOPPING DATABASE CONTROL

Page # 4-4

When we install Oracle database, Oracle universal installer also installs Oracle enterprise Manager (OEM). Its web-based Database Control serves as the primary tool for managing our oracle database

STEP # 1 Open dos prompt Set oracle_sid=orcl2  database name may change C:>Emctl start dbconsole C:>Lsnrctl

STEP # 2

Open Internet Explorer On Address bar type  http://computer name:port number/em

Check Computer Name  right click on my computer Then properties Than click computer name For Port number  when we start emctl dbconsole we see port number of our database. Normally 1158 is the port number

STEP # 3 LOGIN SCREEN ENTER username and password

STEP # 4 Enterprise manager 10g windows open Click on administration Then work start We can do all things that we can perform on sql plus.

ISQL PLUS PRACTICAL

Page # 4-9

STEP # 1 Start dos prompt Write  isqlplusctl start STEP # 2

Open Internet Explorer Type the address for ISQL*PLUS http://PC-01:5560/isqlplus/ Syntax http:// host_name:portnumber/isqlplus Check Computer Name  Right click on my computer Then properties Than click computer name For Port number Or manually E:\oracle\product\10.1.0\Db_1\install\portlist STEP # 3 LOGIN SCREEN ENTER username and password Now isqlplus started. We can do all things that we can perform on sqlplus.  for isqlplus usually 5560.

LOGIN ISQLPLUS AS SYSDBA PRACTICAL

Page # 4-10

STEP # 1 Open CMD SET JAVA_HOME=D:\ORACLE\PRODUCT\10.2.0\DB_1\JDK SET ORACLE_HOME=D:\ORACLE\PRODUCT\10.2.0\DB_1 SET ORACLE_SID=ORCL

CD D:\ORACLE\PRODUCT\10.2.0\DB_1\OC4J\J2EE\ISQLPLUS\APPLICATIONDEPLOYMENTS\ISQLPLUS

Type D:  enter drive name where oracle install

s> d:\oracle\product\10.2.0\db_3\jdk\bin\java Djava.security.properties=%ORACLE_HOME%\oc4j\j2ee\home\config\jazn.security.props -jar %oracle_home%\oc4j\j2ee\home\jazn.jar -user "iSQL*Plus DBA/admin" -password welcome shell Now you enter JAZN:>  Prompt write the following steps on JAZN JAZ:> adduser "iSQL*Plus DBA" xyz xyz JAZN:>listusers JAZN:>grantrole WebDba "iSQL*Plus DBA" xyz JAZN:> exit

STEP # 2 Open Internet Explorer Type the path http:\\localhost:5560/isqlplus/dba security window open type username and password xyz/xyz now isqlplus started enter username sys password oracle as SYSDBA Now start work

dept. Select * from emp. Select * from cat. Select * from emp where job=‘SALESMAN‘. min(sal). Select sum(sal). Write following sql statement on notepad file Select * from emp .USING THE SQL PLUS Page # 4-12 For BLACK screen RUN  sqlplus Than enter username and password For WHITE screen Program  oracle 10g home 1  application development  sqlplus CALLING SCRIPT ON SQLPLUS Page # 4-14 STEP # 1 Create a script file on note pad. Select * from emp Where sal > (select sal from emp where ename=‘SMITH‘). max(sal) from emp. Update emp .

Set job=‘SALESMAN‘; Select * from emp; Rollback; Select * from emp; Where ename like ‗&\_%‘ escape ‗\‘; Select * from emp Where job in ( select job from emp where empno=7788); Insert into emp Values (9999,‘RAHEEL‘,‘SALESMAN‘,‘‘,‘‘,‘‘,‘‘,‘‘);

Now save the notepad file with sql extension  script file.sql

STEP # 2 On sqlplus or isqlplus

@path of the file  destination of the file you create above like @ E:\PRACTICE\Raheel\Raheel\final\10G\script.sql

INITIALIZATION PARAMETER FILE

Page # 4-15

In order to start an instance and open the database, we must connect sysdba and enter the startup command. The oracle server will then read the initialization parameter file and prepare the instance according to the initialization parameters contained within. For this we must have sysdba privileges There are two types of parameter files.

Static parameter file, PFILE, commonly referred as initsid.ora Dynamic persistent server parameter file SPFILE, commonly referred as spfilesid.ora.

CONTENTS OF PARAMETER FILE       A list of instance parameters The name of the database the instance is associated with Allocation for memory structures of the SGA What to do with filled online redo log files. ---------------------------The names and locations of control files. Information about undo tablespace.

Text initialization parameter file: PFILE  init<sid>.ora - Text File - Modified with an operating system editor - Mod made manually

(sid) means database name

- Whenever we need to change the value of the parameter file we must shutdown the database. - The pfile is read only during instance startup. (Changes take effect on next startup)

For oracle 9i

 default location C:\oracle\admin\orcl\pfile\initsid.ora

For oracle 10g (R2)  default location E:\oracle\product\10.2.0\Db_1\database\initorcl.ora Server parameter file: SPFILE :  spfile<sid>.ora  (sid) means database name - Binary File - Maintained by the oracle server

- Always resides on the server side having read and write by database server - Ability to make changes persistent across SHUTDOWN and STARTUP - Can self-tune parameter values - Can have RMAN support for backup the initialization parameter

For oracle 9i  default location C:\oracle\ora92\database\spfileorcl.ora For oracle 10g (R2)  default location E:\oracle\product\10.2.0\Db_1\dbs\spfileorcl.ora PRACITCAL -----------------------------------------------------------------------------------------------------------To see which parameter file is running with the current instance. SQL> show parameter spfile; NAME TYPE VALUE or show parameter pfile;

------------ ----------- -----------------------------spfile string C:\ORACLE\PRODUCT\10.2.0\DB_1\DBS\SPFILEORCL.ORA

------------------------------------------------------------------------------------------------------------

VIEWING AND MODIFYING INITILIZATION PARAMETERS

Page # 4-18

We can use enterprise manager to view and modify initialization parameters by clicking On Administration Tab  database configuration  All Initialization Parameters OR ALTER SYSTEM command is used to change the value of instance parameter. DESC V$SPPARAMETER SELECT * FROM V$SPPARAMETER

Startup command behavior
ORDER OF PRECEDENCE : When the command startup is used, the spfileSID.ora on the server side is used to start up the instance. If the spfileSID.ora is not found the default Spfile.ora on the server side is used to start up the instance. If the default spfile.ora is not found, the initSID.ora on the server side will be used to start up the instance. A specified PFILE can override the use of the default SPFILE to start the instance. CREATE SPFILE FROM PFILE FOR ORACLE 9i Create SPFILE = 'd:\oracle\ora92\database\spfileorcl.ora' from pfile = 'd:\oracle\admn\orcl\pfile\initorcl.ora'; This work also be done without defining address and shutdown stage Create spfile from pfile ; FOR ORACLE 10g CREATE SPFILE = 'C:\oracle\product\10.2.0\Db_1\dbs\SPFILEORCL1.ORA' FROM PFILE = 'C:\oracle\product\10.2.0\Db_1\database\INITorcl.ORA' File created. This work also be done without defining address and shutdown stage Create spfile from pfile ;

STARTING UP THE DATABASE :
There are 4 stages to startup and shutdown the database When startup database

Page # 4-21

To perform special maintenance operations . status and destination of DATA FILES AND ONLINE REDO LOG FILES .ora .ora specifying the PFILE parameter with STARTUP overrides the default behavior. . .First spfileSID. initsid. .Allocating SGA . At this stage following tasks are performed .If not found then.if not found then.Shutdown  Nomount  mount  open AT NOMOUNT STAGE: An instance is typically started only in NOMOUNT mode During Database creation.log files and trace files AT MOUNT STAGE: Mounting a database includes the following tasks: .ora .opening the alertSID.Locating and opening the control file specified in the parameter file. During Re-creation of control files.Reading the control file to obtain the name.Reading initialization parameter file . spfile.Associating a database with instance start at nomount stage.Starting the background Process . Or During certain backup and recovery scenarios.

Open online redo log files NOTE : If any of the data files or online redo log files are not present when you attempt to open the database.Performing full Database Recovery AT OPEN STAGE: Opening a database includes the following tasks: . then the oracle server returns an error. Total System Global Area 171966464 bytes Fixed Size Variable Size 787988 bytes 145750508 bytes . Alter database open..Open online data files .Renaming data files (data files for an offline tablespace can be renamed when the database is open) . SQL> startup nomount ORACLE instance started. to move the database form NOMOUNT TO MOUNT or from NOMOUNT TO OPEN use ALTER DATABASE COMMAND Alter database mount. STARTUP COMMAND  use to start database STARTUP NOMOUNT.Enabling and disabling online redo log file archiving options. .

This can be done in two ways 1.Before startup the database SQL> STARTUP RESTRICT ORACLE instance started. Database altered. SQL> alter database open. OPENING A DATABASE IN RESTRICTRED MODE : Page # 4-23 Last A restricted session is useful when you perform structure maintenance or a database import and export. Database opened. Database altered. Then database can be started in restricted mode so that it is available only to users having restricted session / administrative privileges.Database Buffers Redo Buffers SQL> SQL> 25165824 bytes 262144 bytes SQL> alter database mount. 1250452 bytes 281021292 bytes 327155712 bytes 2940928 bytes . Total System Global Area 612368384 bytes Fixed Size Variable Size Database Buffers Redo Buffers Database mounted.

Rollback the user current transactions 2. OR After database open SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION .Free all resources currently reserved by the user SQL> STARTUP RESTRICT. SYSTEM ALTERED After placing an instance in restricted mode. SYSTEM ALTERED. This can be done by the following SQL> ALTER SYSTEM KILL SESSION 'integer1.After database open use alter system command SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION.integer2' where integer1: value of the SID column in the V$SESSION view integer2: value of the SERIAL# column in the V$SESSION view Effects of terminating session : Alter system kill session command causes the background process PMON to perform the following steps 1. you may want to kill all current users before performing administrative tasks.or 2. .Release all currently held table or row lock 3.

SQL> GRANT CONNECT . SQL> CONN SYS/ORACLE AS SYSDBA. ERROR: ORA-01045: user ABC lacks CREATE SESSION privilege. Grant succeeded. Connected. logon denied Warning: You are no longer connected to ORACLE. User created. SQL> CONN ABC/ABC. RESOURCE TO XYZ IDENTIFIED BY XYZ. SQL> GRANT CONNECT. RESOURCE TO ABC IDENTIFIED BY ABC. Grant succeeded. User created. When we connect database an error occurred because this user has no right to connect with database. STEP # 2 Open another SQL session abc/abc xyz/xyz  session 2  session 3 scott/tiger  session 4 .TERMINATE SESSION STEP # 1 SQL> CREATE USER ABC IDENTIFIED BY ABC . SQL> CREATE USER XYZ IDENTIFIED BY XYZ.

Step # 6 Now Come to SYS session session  1 Find username . STEP # 5 Query on abc/abc session  2 SELECT * FROM SCOTT. Grant succeeded.EMP. SERIAL# from V$SESSION . STEP # 4 Now scott grant select right to abc and xyz SQL> GRANT SELECT ON SCOTT. Query on xyz session  3 SELECT * FROM SCOTT.STEP # 3 Query on scott/tiger session  4 SQL> SELECT * FROM EMP . SQL> UPDATE EMP SET SAL=1000.EMP TO ABC. SID. 14 rows updated. SQL> SELECT * FROM EMP. 14 rows selected.EMP TO XYZ.EMP. 14 rows selected. SQL> GRANT SELECT ON SCOTT. Grant succeeded. serial# from v$session view SQL> select USERNAME. SID.

SYSTEM ALTERED STEP # 7 Query on abc  SESSION Select * from scott.23’. . An error occurred -------------------------------------------------------------SQL> SELECT * FROM EMP. SQL> ALTER DATABASE OPEN READ ONLY.emp.Then Alter system kill session ‗integer1. integer2‘. OPENING A DATABASE IN READ ONLY MODE To prevent data from being modified by user transactions database can be open at read only mode. SELECT * FROM EMP * ERROR at line 1: ORA-00028: your session has been killed --------------------------------------------------------------ERROR: ORA-01012: not logged on This means the session of this user has been killed he is not able to work with the database. Where Integer 1 = SID Integer 2 = serial # SQL> AFTER SYSTEM KILL THE SESSION ‘123.

DML operation perform READ ONLY session can be used : .SHUTDOWN NORMAL : .perform recovery of offline datafiles and tablespaces.In this mode of database no DDL.Background process terminated and SGA remove from memory . but not tablespaces .No new connection can be made .Oracle server waits all users to disconnect .SHUTDOWM IMMEDIATE : .Current SQL statement being processed is not completed .No new connection can be made .When all transaction finished shutdown occur immediately .User automatically disconnect after completing the transaction in progress .database and redo buffer written to the disk .Execute disk sort using locally manage tablespaces .SHUTDOWN TRANSACTIONAL : .Next startup does not require recovery 2.Next startup does not require recovery Page # 4-24 3.Execute query .take datafiles offline and online.Oracle closes and dismount database before shutdown . SHUTDOWN THE DATABASE : There are 4 ways to shutdown database 1.

log file.When the database ARCHIVELOG.. MONITORING AN INSTANCE USING ALERT LOG FILES : Each oracle instance has an alert<sid>. ALTER.a list of non default initialization parameters . and RECOVER . The file must manage by DBA It continuous grow while the database continuous to work Alert log file should be the first place you look when diagnostic day-to-day operations or errors.Next startup does not require recovery 4.the log sequence number LGWR is writing to .The instance terminated without closing the files .SHUTDOWN ABORT : .Administrative operations. DROP .Oracle server does not wait for the user who are currently connected to the database .Oracle does not wait for user currently connected to the database . The file is on the server with the database and is stored in the directory specified with the background_dump_dest initialization parameter. such as the SQL statements CREATE.The database is not close or dismounts .Next startup requires instance recovery. The alert file keeps a record of the following information .information regarding to log switch . .when the database was STARTED and SHUTDOWN .Oracle closes and dismount database before shutdown.the startup backgroud process .the thread used by the instance .Database and redo buffers are not written to the disks .

However DBA grant privileges on them. but no database is mounted we can query V$BGPROCESS to see the list of background process that are running .0\admin\ORCL\bdump NOTE : This file can grow to an unmanageable size. These views are based on virtual tables that are built from memory structure inside the database server. These views provide access to information about changing states and condition in the database. This data stored in dynamic performance views. For example: If an instance has been started. and deadlock errors (ORA-60) The alertSID. That is why some of them can show you data before a database is mounted or open. These views are often referred as ―V DOLLOR‖ V$ views. We can query V$ FIXED_TABLE to see all view names. If alert log file delete during database open it must be re-created automatically.information regarding error messages such as ORA-600 and extent errors.1. and TABLESPACE creation of tablespace and undo segments . Some dynamic performance views contain that is not applicable to all states of an instance or database. . Any other user cannot access these views. These views are owned by the sys user. DESTINATION: for ORACLE 10g E:\oracle\product\10.DATABASE. DYNAMIC PERFORMANCE VIEWS: Page # 4-32 The oracle database also maintains a more dynamic set of data about the operation and performance of database instance.Block corruption errors (ORA-1578). And re-create every time instance started. SQL>SELECT * FROM V$FIXED_TABLE . That is they are not true tables.log location is defined by the BACKGROUND_DUMP_DEST initialization parameter. Read consistency is not granted on these views because the data is dynamic.

Dynamic Performance Views include information about:          Session File States Progress of Jobs and Tasks Locks Backup States Memory Usage and Allocation System and Session Parameter SQL execution Statistics and Metrics LIST OF COMMON DYNAMIC VIEWS V$CONTROLFILE List the name of control files V$DATAFILE Contain datafile information from the control file V$DATABASE Contains database information from the control file V$INSTANCE Display the state of current instance V$PARAMETER List parameter and values currently in effect fro the session V$SESSION List session information for each current session . But we cannot query V$DATAFILE to see the status of data files.SQL>SELECT * FROM V$BGPROCESS. Because database is not mounted.

SQL> --. Flashback query Query all data as it existed at a specific point in time. 4 rows deleted.V$SGA Contain summary information on the system global area (SGA) V$SPPARAMETER List the contents of SPFILE V$TABLESPACE Display the tablespace information from the control file V$THREAD Contain thread information from the control file V$VERSION Version numbers of core library components in the oracle server. .At 12 : 19 Delete Case . Commit complete. SQL> COMMIT. use the SELECT . AS OF query to retrieve Flashback data from the past.At 11 : 34 SQL> DELETE FROM EMP WHERE JOB='SALESMAN'. Flashback query lets you view and repair historical data. You can perform queries on the database as of a certain wall clock time or user-specified system commit number (SCN) Example --SQL> --. Next. .

Commit complete. SQL> SELECT * FROM EMP WHERE EMPNO=7900. 'YYYY-MM-DD HH24:MI:SS'). Once we confirm the validity of the accidentally deleted data.SQL> SELECT * FROM EMP AS OF TIMESTAMP SYSDATE-1/24. 7900 JAMES CLERK 7698 03-DEC-81 3000 30 SQL> --. it’s easy to reinsert the data by using the previous query as part of an INSERT statement. SQL> COMMIT . Or SQL> SELECT * FROM emp AS OF TIMESTAMP TO_TIMESTAMP ( '2010-03-05 11:33:30' . SQL> COMMIT. 1 rows updated. 7900 JAMES CLERK 7698 03-DEC-81 950 30 SQL> UPDATE EMP SET SAL=3000 WHERE EMPNO=7900.AT 12 : 22 SQL> SELECT * EMP WHERE EMPNO=7900. Commit complete. as shown here: SQL>INSERT INTO EMP SELECT * FROM EMP AS OF TIMESTAMP SYSDATE-1/24 WHERE JOB='SALESMAN' 4 rows created.AT 12 : 40 SQL> SELECT * FROM EMP AS OF TIMESTAMP . SQL> SELECT * FROM EMP UPDATE CASE SQL> --.

7499 ALLEN 7521 WARD 7654 MARTIN 7844 TURNER SALESMAN SALESMAN SALESMAN SALESMAN 7698 20-FEB-81 7698 22-FEB-81 7698 28-SEP-81 7698 08-SEP-81 10000 10000 10000 10000 300 500 1400 0 30 30 30 30 . SQL> SELECT * FROM EMP WHERE EMPNO=7900. 7499 ALLEN 7521 WARD 7654 MARTIN 7844 TURNER SALESMAN SALESMAN SALESMAN SALESMAN 7698 20-FEB-81 7698 22-FEB-81 7698 28-SEP-81 7698 08-SEP-81 1600 1250 1250 1500 300 500 1400 0 30 30 30 30 SQL> UPDATE EMP SET SAL=10000 WHERE JOB=’SALESMAN’. 1 row updated.AT 12 : 22 SQL> SELECT * EMP WHERE JOB=’SALESMAN’. 'YYYY-MM-DD HH24:MI:SS') WHERE EMPNO=7900 7900 JAMES CLERK 7698 03-DEC-81 950 30 SQL> UPDATE EMP SET SAL=(SELECT SAL FROM EMP AS OF TIMESTAMP TO_TIMESTAMP ('2010-03-08 12:20:00' . 4 rows updated. 7900 JAMES CLERK 7698 03-DEC-81 950 30 UPDATE CASE 2 SQL> --. SQL> SELECT * FROM EMP WHERE JOB=’SALESMAN’. SQL> COMMIT. 'YYYY-MM-DD HH24:MI:SS') WHERE EMPNO=7900) WHERE EMPNO=7900.TO_TIMESTAMP ('2010-03-08 12:20:00' . Commit complete.

statement. We could use the SCN for the transaction instead of time stamps. SQL> SELECT * FROM EMP WHERE JOB=’SALESMAN’. DDL/DML. This process is also known as Optimization of the query. . optimize its execution. use the time-stamp method to specify the time.AT 12 : 40 SQL> SELECT * FROM EMP AS OF TIMESTAMP TO_TIMESTAMP ('2010-03-08 12:20:00' . gets parsed.'RRRR-MM-DD HH24:MI:SS') WHERE E.SQL> --. Parsing means what Oracle understands about the statement and based on that. 4 row updated.EMPNO=EMPNO AND JOB='SALESMAN') WHERE JOB='SALESMAN'. or anything else. 7499 ALLEN 7521 WARD 7654 MARTIN 7844 TURNER SALESMAN SALESMAN SALESMAN SALESMAN 7698 20-FEB-81 7698 22-FEB-81 7698 28-SEP-81 7698 08-SEP-81 1600 1250 1250 1500 300 500 1400 0 30 30 30 30 The previous examples use a time stamp to pinpoint the exact time the data was accidentally dropped. Query Parsing What is Query Parsing ? In oracle. how to execute it. If you need to be very specific regarding the time point. The idea is how best Oracle can process the query or in other words. 'YYYY-MM-DD HH24:MI:SS') WHERE JOB=’SALESMAN’ 7499 ALLEN 7521 WARD 7654 MARTIN 7844 TURNER SALESMAN SALESMAN SALESMAN SALESMAN 7698 20-FEB-81 7698 22-FEB-81 7698 28-SEP-81 7698 08-SEP-81 1600 1250 1250 1500 300 500 1400 0 30 30 30 30 SQL> UPDATE EMP E SET SAL=( SELECT SAL FROM EMP AS OF TIMESTAMP TO_TIMESTAMP('2010-03-08 15:25:04'.

Parsing is of two types, Hard parse and Soft parse. If the said query is found in Oracle's cache, the query optimization is not needed.Oracle can pick up the optimized query and can execute it. If the query is run for the first time or the query's cached version is obsolete or flushed out from oracle's cache, query needs to be optimized and the process is c called Hard parse of the query. Hard parse , in general , is unavoidable as for the very first time, each query needs to be parsed , atleast for once. But in the subsequent executions, query should be simply soft parsed and executed. The mechanism which works in the backend for doing all this is called Optimizer. There are two versions of it, Rule Based and Cost Based. The Rule Based optimizer(RBO) is made deprecated from Oracle version release 10g. This was not very much efficient as it was "statement driven". The Cost Based is now the only and supported mode of optimizer which is, as the name suggests, cost based and takes into the account the resource consumption of the query.

Queries
============================================ Display time waited for each wait class. ============================================

SELECT a.wait_class, sum(b.time_waited)/1000000 time_waited FROM v$event_name a JOIN v$system_event b ON a.name = b.event GROUP BY a.wait_class;

=============================================== Display session wait information by wait class. ===============================================

SELECT * FROM v$session_wait_class WHERE sid = &enter_sid;

=============================================== Statistics (delete lock unlock) ===============================================

BEGIN DBMS_STATS.delete_table_stats('MY_SCHEMA','LOAD_TABLE'); DBMS_STATS.lock_table_stats('MY_SCHEMA','LOAD_TABLE'); DBMS_STATS.unlock_table_stats('MY_SCHEMA','LOAD_TABLE');

END;

============================================= Retrieve SAMPLE Date (%) ============================================ SELECT e.empno, e.ename, d.dname FROM emp SAMPLE (10) e JOIN dept d ON e.deptno = d.deptno;

=============================================== past 30 minutes waits =============================================== select ash.event, sum(ash.wait_time +ash.time_waited) ttl_wait_time from v$active_session_history ash where ash.sample_time between sysdate - 30/1440 and sysdate group by ash.event order by 2 /

================================================= What user is waiting the most(last_hour) ? =================================================

select sesion.sid, sesion.username, sum(active_session_history.wait_time + active_session_history.time_waited) ttl_wait_time from v$active_session_history active_session_history, v$session sesion where active_session_history.sample_time between sysdate - 1/24 and sysdate and active_session_history.session_id = sesion.sid group by sesion.sid, sesion.username order by 3

============================================== What SQL is currently using the most resources? (lasthour) ============================================== select active_session_history.user_id, dba_users.username, sqlarea.sql_text, sum(active_session_history.wait_time + active_session_history.time_waited) ttl_wait_time from v$active_session_history active_session_history, v$sqlarea sqlarea, dba_users where active_session_history.sample_time between sysdate - 1/24 and sysdate and active_session_history.sql_id = sqlarea.sql_id and active_session_history.user_id = dba_users.user_id group by active_session_history.user_id,sqlarea.sql_text, dba_users.username order by 4 /

============================================== What object is currently causing the highest resource waits? (lasthour) ==============================================

select dba_objects.object_name, dba_objects.object_type, active_session_history.event, sum(active_session_history.wait_time + active_session_history.time_waited) ttl_wait_time from v$active_session_history active_session_history, dba_objects where active_session_history.sample_time between sysdate - 1/24 and sysdate and active_session_history.current_obj# = dba_objects.object_id group by dba_objects.object_name, dba_objects.object_type, active_session_history.event order by 4

=========================================== script to gather database statistics

========================================== begin DBMS_STATS.GATHER_DATABASE_STATS ( estimate_percent =>100, block_sample=>FALSE, method_opt=>'for all columns size auto', degree=>null, cascade=>true, no_invalidate=>false, options=>'GATHER STALE', gather_sys=>FALSE); DBMS_STATS.GATHER_DATABASE_STATS ( estimate_percent =>100, block_sample=>FALSE, method_opt=>'for all columns size auto', degree=>null, cascade=>true, no_invalidate=>false, options=>'GATHER EMPTY', gather_sys=>FALSE); end;

========================================= script to gather dictionary statistics ========================================

begin DBMS_STATS.GATHER_DICTIONARY_STATS ( estimate_percent =>100, block_sample=>FALSE, method_opt=>'for all columns size auto', degree=>null, cascade=>true, no_invalidate=>false, options=>'GATHER STALE' ); DBMS_STATS.GATHER_DICTIONARY_STATS ( estimate_percent =>100, block_sample=>FALSE, method_opt=>'for all columns size auto',

degree=>null, cascade=>true, no_invalidate=>false, options=>'GATHER EMPTY' ); end;

======================================== schedule a job (statistics) =======================================

begin sys.dbms_scheduler.create_job(job_name => '"SYS"."ESTIMATE100_GATHERAUTO"', job_type => 'PLSQL_BLOCK', job_action => 'begin DBMS_STATS.GATHER_DATABASE_STATS ( estimate_percent =>100, block_sample=>FALSE, method_opt=>''for all columns size auto'', degree=>null, cascade=>true, no_invalidate=>false, options=>''GATHER STALE'', gather_sys=>FALSE); DBMS_STATS.GATHER_DATABASE_STATS ( estimate_percent =>100, block_sample=>FALSE, method_opt=>''for all columns size auto'', degree=>null, cascade=>true, no_invalidate=>false, options=>''GATHER EMPTY'', gather_sys=>FALSE); end;', repeat_interval => 'FREQ=DAILY;BYHOUR=2;BYMINUTE=0;BYSECOND=0', start_date => trunc(sysdate+1) + 2/24, job_class => 'DEFAULT_JOB_CLASS', comments => 'Gather auto stats on every table with 100% sampling', auto_drop => FALSE, enabled => FALSE);

sys.dbms_scheduler.set_attribute(name => '"SYS"."ESTIMATE100_GATHERAUTO"', attribute => 'job_priority', value => 4); sys.dbms_scheduler.enable('"SYS"."ESTIMATE100_GATHERAUTO"'); end;

Oracle Datapump parameter REMAP_SCHEMA
Loads all objects from the source schema into a target schema.

Syntax
REMAP_SCHEMA=source_schema:target_schema

Suppose that you execute the following Export and Import commands to remap the hr schema into the scott schema:
> expdp SYSTEM/password SCHEMAS=hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp

> impdp SYSTEM/password DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp REMAP_SCHEMA=hr:scott

In this example, if user scott already exists before the import, then the Import REMAP_SCHEMA command will add objects from the hr schema into the existing scott schema. You can connect to the scott schema after the import by using the existing password (without resetting it). If user scott does not exist before you execute the import operation, Import automatically creates it with an unusable password. This is possible because the dump file, hr.dmp, was created by SYSTEM, which has the privileges necessary to create a dump file that contains the metadata needed to create a schema. However, you cannot connect to scott on completion of the import, unless you reset the password for scott on the target database after the import completes.

Basic Introduction to SQL*PLUS
The SQL*PLUS (pronounced "sequel plus") program allows you to store and retrieve data in the relational database management system ORACLE. Databases consist of tables which can be manipulated by structured query language (SQL) commands. A table is made up of columns (vertical) and rows (horizontal). A row is made up of fields which contain a data value at the intersection of a row and a column. Be aware that SQL*PLUS is a program and not a standard query language.

Getting Started
It is a prerequisite that users are registered for ORACLE, an ORACLE account is needed. On Unix platforms you must start the script oraenv to set the ORACLE environment. Enter the command . oraenv and press <Return;>. Don't forget to type a blank between the dot and oraenv.

If you are working with a PC using MS Windows, simply use Netinstall to install the product. You can find the software in the database folder. Enter sqlplus on unix systems or run it on Windows from the start menue. Answer the displayed prompts by entering your ORACLE user-name and password. The SQL*PLUS command prompt SQL > indicates that you are ready to work.

Some elementary Commands
alter user user identified by newpassword Help exit, quit ho[st] ho[st] command ho[st] oerr enables user to change the password accesses the SQL*PLUS help system terminates SQL*PLUS leads to the operating system without leaving SQL*PLUS executes a host operating system command accesses the ORACLE error help for unix

Editing and Executing
All entered input is stored as a single SQL*PLUS statement in the command buffer. Pressing the <Return> key while editing will either open a new numbered line or, if the previous line ends with a semicolon or consists of a single slash, will execute the SQL*PLUS command. Opening new numbered lines allows you to structure statements and enables you to refer to particular lines by later using edit functions. l[ist] ln or n ln m a text c/oldstring/newstring i del r[un] / ; lists command buffer (the current line is marked with a star) makes line n the current line and lists it lists lines n through m appends text to current line changes oldstring to newstring in current line inserts a line after current line deletes the current line runs and lists command buffer runs command buffer lists command buffer

If you use substitution variables, like &variable, instead of values or names in your SQL statement, SQL*PLUS will prompt you and substitute the entered value. A substitution variable is a user variable name preceded by an ampersand.

Working with Command Files
You can use command files to save complex commands. After creating a command file you can retrieve, edit, and run it. The default file extension is .sql . If you use other file extensions you must write the full file name like name.extension. ed[it] overwrites a scratch file with the contents of the command buffer edit enables you to edit this file with the defined host operating system editor. The name of the scratch file is afiedt.buf . After leaving the editor the buffer is listed and you can execute it.

app[end]. you will be prompted for that value. from tabname selects specified columns from table tabname select col1. are arguments you wish to pass to the command file If you run a command file in which a substitution variable like &1 is used..col2 from tabname where col1 < col2 and col2 !=0 order by col2 Columns col1. Queries and Subqueries Retrieving data from the database is the most common SQL operation. Examples select * from tabname selects all columns and rows from table tabname select distinct col from tabname selects column col from table tabname and returns only one copy of duplicate rows select col1. col2 multiplied by 3 select 2*3 from dual calculates 2*3 and will display the result Selecting Rows and Ordering To retrieve specific rows from a table you need to add a where clause. A subquery is a select which is nested in another SQL command The Describe Command desc[ribe] name lists the column definition for table or view name Basic Select Commands The basic select command consists of two parts.col2 from tabname where col1 like '_A%' or col1 like '+++' order by col2 desc . Examples select col1. rep[lace].col2 from table tabname and lists col1. col2*3 from tabname selects col1. called clauses: select some data from table. To display the retrieved data in a specific order you need to add an order by clause. select col1.. col2 are selected from table tabname and all rows where col2 is not equal to zero and col1 is less than col2 are displayed in an ascending order (ordered bycol2). A query is an SQL command (specifically a select) that retrieves information from one or more tables.. get filename loads the host operating system file filename into the command buffer sta[rt] filename [arg1 arg2 . A where clause consists of one or more search conditions which can be connected by logical operators.] executes file filename arg1 arg2 .sql creates file filename and stores the command buffer into it stores command buffer into file filename Possible options are cre[ate]. col2 . You can avoid being prompted by passing an argument to the command file.ed[it] filename sav[e] filename sav[e] filename [option] enables you to edit an existing or new file filename..

set operator union union all intersect minus returns all distinct rows selected by either query returns all rows selected by either query. The omission of the linking where clause causes a cartesian product of both tables.col2 This is the most common type of join. you can do this by issuing different queries or a single JOIN query. If a column name is not unique.col1.Columns col1. Since the names of the resulting columns in this example are the same. If a statement contains multiple set operators. select col1.tab2 where tab1.col2 are selected from table tabname and all rows where col1 is not in the range between value1 and value2 are displayed. columns of table1 and table2.col1 "Header 2" from tabname alias1.col2=tab2. select col1.tab1. .col2 are selected from table tabname and all rows where col1 is equal to '+++' or where the second letter in col1 is an 'A' are displayed in a descending order. including all duplicates returns all distinct rows selected by both queries returns all distinct rows selected by the first query but not the second Example select * from table1 union all select * from table2 This will combine all rows.col3 In this example the table tabname is joined with itself.tabname alias2 where alias1.columnname).col3 from tab1. In a JOIN query. tablename. Using of two different alias names for the same table allows you to refer to it twice.col1.col2 are selected from table tabname and all rows where col1 is equal to value1 or to value2 are displayed. In this example two different escape characters are used.col2=alias2.col2 from tabname where col1 not between value1 and value2 Columns col1.col2 from tab1. The underscore matches exactly one character whereas the percent sign can match zero or more characters.tab2. therefore it is also called an equi-join Non-Equi Join select tab1.alias2. Querying Multiple Tables If you want to retrieve information from different tables.g. you must use a prefix to make clear which column from which table you want to select (e. the second column gets a new header. It returns rows from two tables based on an equality condition.col2 from tabname where col1 in ( value1. you list the names of the tables you are querying in the from clause and the names of the linking columns in the where clause. A JOIN combines rows from two or more tables where columns which the tables have in common match. it is called a non-equi join.value2 ) Columns col1.tab2 where tab1. Using Set Operator Set operators combine the results of two queries into a single result. Self Join select alias1.col2. Simple Join select col1. they will be evaluated from left to right.col1 between lowval and highval Since this join doesn't return rows based on a equality condition.

.col2(+) Suppose you want to retrieve information from two tables where not all rows match but the result should contain all values from one or more columns..col1 will be selected.)=(subquery) where cond updates rows in table tabname .col2 from tab1. where cond updates rows in table tabname columns are set to values of expressions if condition cond is true update tabname set (col1..... the outer join works as a simple join..col2.col2. drop table tabname alter table tabname add (col1 type1..val 2.col2 type2.) values (val1. coln are the column names. varchar. alter and delete objects (e. those rows which do not match will also be selected.. grant privilege on object to user revoke privilege on object from user removes table tabname from the database adds columns to table tabname modifies column definitions renames table oldname enables user to change the password to newpassword grants a privilege to user revokes a privilege from user Data Manipulation Language DML DML commands manipulate and query data in existing tables. type1.type2..) rename oldname to newname alter user user identified by newpassword.col2=expr2. All matching rows will be selected and when you append the outer join operator (+) to a column name.col2 and a NULL value for the non existing value of tab1. create table tabname (col1 type1.. the values from tab2. number(p. date.) creates table tabname col1 ..tab2 where tab1. specifies the datatype of a column which can be number... create table tabname as subquery creates table tabname subquery inserts rows into the table upon its creation.. In the example the number of rows which are selected is the number of rows in table tab2. insert into tabname (col1. A subquery is a form of the select command which enables you to select columns from an existing table.col2 type2. These commands do not commit current actions. Data Definition Language DDL DDL commands allow you to create.Outer Join select col1. char.) alter table tabname modify (col1 type1.g tables. varchar2(size) specifies variable length (max 2000) character string having a maximum length of size bytes. number(p) specifies a fixed point number.. char(size) specifies fixed length (max 255) character data of length size.col2 type2.) inserts rows into table tabname insert into tabname subquery inserts rows(selected by a subquery) into &table tabname update tabname set col1=expr1. If rows match... if not.s) specifies a fixed point number having precision p (total number of digits) and scale s (number of digits to the right of the decimal point). number specifies a floating point number. create view viewname as subquery creates view viewname A view is a logical table based on one or more tables.. views) and also to grant and revoke privileges. A simple join will select only matching rows whereas the outer join extends the result.col1=tab2..

CEIL( (NVL(HWM. you have to specify schema.emp Transaction Control Commands Transaction Control Commands manage changes made by Data Manipulation Language commands.1)*&&BLKSIZE)/1024/1024 )||'M.'.delete from tabname [where cond] columns are set to selected values if condition cond is true either deletes all rows from table tabname or rows where cond is true Schema When you select data from a table or you insert data into a table then this object has to be in your own schema.FILE_ID = B.g="" for="" size="" span="" your=""> SELECT /*+rule*/ 'ALTER DATABASE DATAFILE '''||FILE_NAME||''' RESIZE '||CEIL( (NVL(HWM. A transaction ends with a commit. exit. CEIL( BLOCKS*&&BLKSIZE/1024/1024) CEIL( (NVL(HWM. MAX(BLOCK_ID+BLOCKS-1) HWM FROM DBA_EXTENTS GROUP BY FILE_ID ) B WHERE A.1)*&&BLKSIZE)/1024/1024 ) SAVINGS FROM DBA_DATA_FILES A. If you are not the owner of the object. but the owner granted some privileges to you. In most cases transactions are implicitly controlled. ( SELECT FILE_ID. commit rollback rollback to savepoint savep savepoint savep makes all changes since the beginning of a transaction permanent rolls back (undoes) all changes since the beginning of a transaction rolls back to savepoint savep defines savepoint savep Resize Datafile to Optimal Size SQL> Define BLKSIZE=<="" block="" db="" e. In other words.FILE_ID(+) . Example select * from scott.tabname. rollback . CEIL( BLOCKS*&&BLKSIZE/1024/1024) CURRSIZE. or any DDL statement which issues an implicit commit.1)*&&BLKSIZE)/1024/1024 ) SMALLEST. you must be the owner. A transaction (or logical unit of work) is a sequence of SQL statements that ORACLE treats as a single unit.

The alert log typically shows an entry as follows :ORA-19815: WARNING: db_recovery_file_dest_size of 42949672960 bytes is 100.' ALTER DATABASE DATAFILE 'D:\ORACLCE\APP\ADNAN\ORADATA\ORCL\SYSTEM01.DBF' RESIZE 684M. Add disk space and increase db_recovery_file_dest_size parameter to reflect the new space. ************************************************************************ You have following choices to free up space from flash recovery area: 1.OUTPUT 'ALTERDATABASEDATAFILE'''||FILE_NAME||'''RESIZE'||CEIL((NVL(HWM. Invariably we needed to restart the database and hope that the problem resolves itself.DBF' RESIZE 89M. . and has 0 remaining bytes available. 3.00% used.DBF' RESIZE 5M. Back up files to tertiary device such as tape using RMAN BACKUP RECOVERY AREA command.DBF' RESIZE 82M.DBF' RESIZE 466M. SMALLEST 684 466 89 5 82 CURRSIZE 690 490 90 5 100 SAVINGS 6 24 1 0 18 Oracle OCP test Quiz ORA-19809: limit exceeded for recovery files – db_recovery_file_dest_size and archiver error As we working on development systems normal work around was to free up some space in the db_recovery_file_dest and hope that that the database would continue after the archiver logger error. If you are using Data Guard. ALTER DATABASE DATAFILE 'D:\ORACLCE\APP\ADNAN\ORADATA\ORCL\UNDOTBS01. ALTER DATABASE DATAFILE 'D:\ORACLCE\APP\ADNAN\ORADATA\ORCL\USERS01. then consider changing RMAN ARCHIVELOG DELETION POLICY. Consider changing RMAN RETENTION POLICY. ALTER DATABASE DATAFILE 'D:\ORACLCE\APP\ADNAN\ORADATA\ORCL\EXAMPLE01. 2. ALTER DATABASE DATAFILE 'D:\ORACLCE\APP\ADNAN\ORADATA\ORCL\SYSAUX01.1)*8192)/1024/1024)||'M.

then use RMAN CROSSCHECK and DELETE EXPIRED commands.995.trc: ORA-19809: limit exceeded for recovery files ORA-19804: cannot reclaim 1063256064 bytes disk space from 42949672960 limit ARCH: Error 19809 Creating archive log file to ‗+FRA‘ connect from Rman RMAN > CHANGE ARCHIVELOG ALL VALIDATE. Fix ~~~~ There are a couple of possible options. If an operating system command was used to delete files. Metalink Document https://metalink. Delete unnecessary files using RMAN DELETE command. Just deleting the old backups/archive logs from disk is not sufficient as it‘s the rman repository/controlfile that holds the space used information.p27_show_header.1 has an unpublished note on the subject Cause ~~~~~~~ We register all the information about what we place in the flash recovery area in the rman repository/controlfile. as set by dest_size then we will fail.p27_show_help:621248. ************************************************************************ Errors in file /u00/app/oracle/diag/rdbms/sid/SID/trace/SID_ora_20214.4.oracle. RMAN > DELETE EXPIRED ARCHIVELOG ALL.com/metalink/plsql/f?p=200:27:9917209390401703684::::p27_id. If we determine that there is not sufficient space in the recovery file destination. 1. 1) Increase the parameter db_recovery_file_dest_size 2) Stop using the db_recovery_file_dest by unsetting the parameter. ( This assumes you never really wanted to use this option ) 3) Remove the Entries from the rman repository/Controlfile .

LOG' . ALTER DATABASE ADD LOGFILE GROUP 4 ('D:\ORACLE\ORADATA\ORCL\REDO04A.LOG') SIZE 1M.The removal is desribed in the RMAN documentation but this is a quick and dirty way if you don‘t have an rman repository – but could endanger your ability to recover – so be careful. 'D:\ORACLE\ORADATA\ORCL\REDO03B. To solve availability problem this can be done by SQL command. ADDING ONLINE REDO LOG FILE GROUPS In some cases you may need to create additional log file group. 'D:\ORACLE\ORADATA\ORCL\REDO04B. SQL > select * from V$LOGFILE.LOG' TO GROUP 4 . ADDING ONLINE REDO LOG FILE MEMBER We can add new members to existing online redo log file groups using the following SQL command: ALTER DATABASE ADD LOGFILE MEMBER 'D:\ORACLE\ORADATA\ORCL\REDO04C. a) delete unwanted archive log files from disk ( rm /del ) b) connect to rman c) rman crosscheck archivelog all – marks the controlfile that the archives have been deleted d) rman delete expired archivelog all – deletes the log entries identified above MAINTAINING ONLINE REDO LOG FILES Before adding group and members first check how many group already in the database using the view SQL > select * from V$LOG.LOG' TO GROUP 3 .

An instance requires at least 2 group of online redo log files. An ACTIVE and CURRENT group cannot be dropped. Otherwise the files are created in a default directory of the database server. When an online redo log file group is dropped.LOG'. the operating system file are nat deleted. DROPPING ONLINE REDO LOGFILE GROUPS Online redo log file group can be dropped by the SQL command ALTER DATABASE DROP LOGFILE GROUP 4. NOTE: If database is in archive mode group can not be dropped until archival process not completely done. RESTRICTIONS: While deleting online redo log file group we must consider the following restrictions 1.When adding member use the fully specified name of the log file members. Even group is in INACTIVE MODE DROPPING ONLINE REDO LOG FILE MEMBERS We can drop online redo log file member by using SQL statement ALTER DATABASE DROP LOGFILE MEMBER 'D:\ORACLE\ORADATA\ORCL\REDO02B. 3. 2. RESTRICTIONS: While deleting online redo log file members we must consider the following restrictions .

Alter database rename file command ALTER DATABASE RENAME FILE COMMAND use following steps: STEP # 1: Shutdown the database SQL > SHUTDOWN. when a online redo log file member is dropped. the operation system file cannot be deleted. Relocate or rename online redo log files in one of the 2 following ways: 1.1. 3. the member can not be dropped 4. REALLOCATING OR RENAMING ONLINE REDO LOG FILES The location of online redo log files can be changed by renaming the online redo log files. If the database is in archived mode and the log file group to which the member belongs is not archived. STEP # 4: Rename the online redo log file member using the SQL >ALTER DATABASE RENAME FILE . If the group is current. ensure that the new online redo log file can exists. STEP # 2: Copy the online redo log file to the new location in operating system STEP # 3: To start database at mount SQL > STARTUP MOUNT. you must force switch log file before you can drop the member. We cannot drop the last valid member of any group 2. Add new members and drop old members 2. Before renaming the online redo log files.

and ultimately stop database activity because activity cannot continue. you must test different configurations. Oracle server multiplexed group can contain different no. CLEARING ONLINE REDO LOG FILES An online redo log file might become corrupt while the database is open . The command can overcome two situations where dropping online redo log file is not possible:   If the are only two log groups The corrupt online redo log file belongs to the current group Use the UNARCHIVED keyword in the command to clear the corrupted online file to avoid archiving. of members this is called asymmetric configuration (means all members in a group placed on same disk) In this case we get temporary result because of disk failure Oracle recommended try to built symmetric configuration (means member of any group also placed on different location) By doing this if one member is not available the other is available and instance does not shutdown Separate archive log file and online redo log files on different disks to reduce contention b/w the ARCn and LGWR .LOG’ TO ‘D:\ORACLE\ORADATA\REDO03B. In this situation ALTER DATABASE CLEAR LOGFILE command can be used to reinitialize the online redo log file with out shutdown the database. ONLINE REDO LOG FILE CONFIGURATION To determine the appropriate number of online redo log files for a database.LOG’.‘D:\ORACLE\ORADATA\ORCL\REDO03C.

3. STALE: Indicates that the contents of the file are incomplete 3. In the V$log views the status column having the values 1. DELETED: . CURRENT: Indicates the current online redo log file group. UNUSED: Indicates that the online redo log file group has never been written to 2. In the V$logfile views the status column having the values 1. redo log file group. It 4. INVALID: Indicates that the file is inaccessible 2. This implies that the online redo log file group is active. SQL > Select * from V$log.Data files and online files should be placed on different disk to reduce contention b/w LGWR and DBWn SIZE OF ONLINE REDO LOG FILE The minimum size of online redo log file is 50KB and Maximum size is specifying in the operating system. INACTIVE: Indicates that the online redo log file group is no longer needed for instance recovery. ACTIVE: Indicates that the online redo log file group is active but is not the current online is needed for crash recovery. SQL > Select * from V$logfile.

we need to step through a series of operations. after first shutting down the database and starting it up initially in the mount mode: SQL> SHUTDOWN IMMEDIATE. SQL> ALTER DATABASE ARCHIVELOG. Tuesday. November 15. Set the DB_FLASHBACK_RETENTION_TARGET initialization parameter to specify how far back you can flashback your database. SQL> ALTER DATABASE OPEN 2.440 minutes): SQL> SHOW PARAMETER RETENTION SQL> ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=1440. as we learn in the FLASH RECOVERY AREA CHAPTER 3. Shut down and restart the database in the mount exclusive mode. 4. SQL> STARTUP MOUNT. Check that our database is in the archive log mode by either querying the $DATABASE view. as follows: 1. 2011 Configuring Flashback Database through SQL In order to configure the Flashback Database feature. Set up a flash recovery area. If it isn’t. we can turn archive logging on with the ALTER DATABASE statement shown in the following code. The following code sets the Flashback target to 1 day (1. If we are using a single instance. or by simply issuing the following command: SQL> ARCHIVE LOG LIST The preceding output reveals that the database is indeed running in the archive log mode.Indicates that the file is no longer used 4. BLANK Indicates that the file is in use. a simple MOUNT command can be used: .

and database levels. • Flashback Transaction Query: Lets us view changes made at the transaction level. as follows: Row level We can use Flashback techniques to undo erroneous changes to individual rows. retrieve it and undo erroneous changes. Using this technique. There are three types of row-level Flashback techniques. by querying the V$DATABASE view: SQL> SELECT FLASHBACK_ON FROM V$DATABASE. It can also provide an audit history of changes. This technique helps in analysis and auditing of transactions. and all of them rely on undo data stored in the undo tablespace: • Flashback Query: Allows us to view old row data based on a point in time or an SCN. we can undo changes made by an entire transaction during a specified period. Oracle Flashback Concept FLASHBACK LEVELS In Oracle Database 10g. you have access to flashback techniques at the row. SQL> ALTER DATABASE OPEN. Use the ALTER DATABASE OPEN command to open the database and then confirm that the Flashback Database feature is enabled. such as when a batch job runs twice and you want to determine which objects were affected. we can view the older data and. Table level There are two main Flashback features available at the table level: . 5. if necessary. table. SQL> STARTUP MOUNT. effectively allowing us to compare present data against historical data without performing any DML activity. Enable the Flashback Database feature: SQL> ALTER DATABASE FLASHBACK ON.SQL> SHUTDOWN IMMEDIATE. • Flashback Versions Query: Allows us to view all versions of the same row over a period of time so that you can undo logical errors. 6.

the only way to recover from human error was to employ traditional backup and restore techniques. The process of restoring the database files and then rolling forward through all the redo logs could often involve significant downtime.• Flashback Table: Restores a table to a point in time or to a specified SCN without restoring data files. we have no choice but to recover the entire database. we may accidentally change the wrong set of data or drop a table. and Flashback technology offers us a much more efficient and much faster way to recover from logical errors. we may want to revert the entire database to a previous point in time. The row-level Flashback techniques and Flashback Table use undo data Flashback Drop use new concept of Recycle Bin and Flashback Database rely on the new concept of Flashback log data. but to recover from human errors. FLASHBACK DATABASE Before Oracle Database 10g. we can make the database perform the check in the database buffer cache itself. restoring data file backup copies and then using archived redo logs to advance the database forward. Flashback techniques allow us to selectively restore certain objects. In some extreme cases. . and if the two checksums differ. No matter how limited the extent of the corruption.Traditional Recovery Techniques Unlike traditional recovery techniques. Note: If we have a damaged disk drive. to undo errors at various levels. The DB_BLOCK_CHECKSUM parameter is FALSE by default. we would undertake traditional point-in-time recovery techniques. in most cases while the database is still online and available to users. thus eliminating the possibility of corruption at the physical disk level. By setting the DB_BLOCK_CHECKSUM initialization parameter to FULL. on archived redo logs to completely recover a database without restoring data files and performing traditional media recovery. it also relies. When the block is subsequently read again. For example. if we suffered logical database corruption. or if there is physical corruption (not logical corruption due to application or user errors) in our database. respectively. The Flashback Table feature relies on undo data. For example. we would need to restore entire data files and apply the archived redo logs. The Flashback Drop feature uses the Recycle Bin to restore a dropped table. Flashback vs. to a much smaller extent. Traditionally. This feature uses DML changes to undo the changes in a table. Or we may just want to query historical data and perform change analysis. Database level • Flashback Database: The Flashback Database feature allows us to restore an entire database to a point in time. we must still use the traditional methods of restoring backups and using archived redo logs to perform the recovery. With traditional techniques. the checksum for the data block is computed again. the primary use of Flashback techniques isn’t to recover from a media loss. This was often time-consuming and cumbersome. there is likely corruption in the data block. thus undoing all changes since that time. Furthermore. Flashback Database mainly uses flashback logs to retrieve older versions of the data blocks. Note: Oracle can check data block integrity by computing checksums before writing the data blocks to disk. without resorting to a point-in-time recovery. however. • Flashback Drop: Allows us to reverse the effects of a DROP TABLE statement. As we can see. we can restore a dropped schema or an erroneously truncated table. Oracle’s Flashback technology employs a variety of techniques. We will focus on these techniques in this chapter.

the Flashback Database feature restores data files but without requiring backup data files and using just a fraction of the archived redo log information. SCN. A Flashback Database operation simply reverts all data files of the database to a specified previous point in time. This means that we can recover from logical errors in a fraction of the time —perhaps as little as a hundredth of the time. The only difference is that RMAN will automatically retrieve the necessary archived redo logs. Since the specified target time and the actual recovery time may differ slightly. it is the size of the error and not the size of the database that determines the time it takes to recover. Note: Flashing back a database is possible only when there is no media failure. which are stored in the new flash recovery area. Once the Flashback Database feature is enabled. we can’t use the Flashback Database feature in cases where a data file has been damaged or lost. to undo changes to a point in time just before a specified target time or SCN. you’ll have to recover using a restored data file from backups. We’ll take a look at the whole Flashback Database process in more detail shortly. We can issue the FLASHBACK DATABASE command from either RMAN or SQL*Plus.In Oracle Database 10g. With Flashback Database. or log sequence. Tip Since we need the current data files in order to apply changes to them. but first let’s look at how to enable (and disable) the Flashback Database feature. Thus. If you lose a data file or it becomes corrupted. we simply use the FLASHBACK DATABASE command to return the database to its state at a previous time. We can use Flashback Database in the following situations:  To retrieve a dropped schema  When a user error affects the entire database  When we truncate a table in error  When a batch job performs only partial changes The Flashback Database feature uses flashback database logs. Oracle Shutdown SHUTDOWN THE DATABASE: There are 4 ways to shutdown database . we then use archived redo logs to recover the database over the short period of time between the target time and the actual recovery time. depending on the size of the database — that it would take using traditional methods. unless we use the SET AUTORECOVERY ON feature in SQL*Plus. whereas in SQL*Plus we may have to supply the archived redo logs. the time it takes to recover is directly proportional to the number of changes that we need to undo.

1. During Re-creation of control files. Oracle 10g startup STARTING UP THE DATABASE: There are 4 stages to startup and shutdown the database When startup database Shutdown  Nomount  Mount  Open At NOMOUNT Stage: An instance is typically started only in NOMOUNT mode During Database creation. .SHUTDOWN ABORT:      Oracle does not wait for user currently connected to the database Database and redo buffers are not written to the disks The instance terminated without closing the files The database is not close or dismounts Next startup requires instance recovery. Next startup does not require recovery 4.SHUTDOWN TRANSACTIONAL:     No new connection can be made User automatically disconnect after completing the transaction in progress When all transaction finished shutdown occur immediately Next startup does not require recovery 3.SHUTDOWN NORMAL:       No new connection can be made Oracle server waits all users to disconnect database and redo buffer written to the disk Background process terminated and SGA remove from memory Oracle closes and dismount database before shutdown Next startup does not require recovery 2.SHUTDOWM IMMEDIATE:     Current SQL statement being processed is not completed Oracle server does not wait for the user who are currently connected to the database Oracle closes and dismount database before shutdown.

Reading the control file to obtain the name. Note that all three of these operations require Oracle to access the data files but can’t accommodate any user operations in the files. Prior to this stage.log files and trace files At MOUNT Stage: Mounting a database includes the following tasks:    Associating a database with instance start at nomount stage. initsid. Locating and opening the control file specified in the parameter file. At this stage following tasks are performed  Reading initialization parameter file First spfileSID. the general users can’t connect to the database at all. or renaming data files.    Allocating SGA Starting the background Process opening the alertSID.ora specifying the PFILE parameter with STARTUP overrides the default behavior.ora If not found then. spfile. flashback options.Or During certain backup and recovery scenarios. When the database is started in the open mode. At OPEN Stage: The last stage of the startup process is opening the database. all valid users can connect to the database and perform database operations. changing the archive logging mode of the database. Performing full Database Recovery We usually need to start up a database in mount mode when you’re doing activities such as performing a full database recovery. status and destination of DATA FILES AND ONLINE REDO LOG FILES   To perform special maintenance operations Renaming data files (data files for an offline tablespace can be renamed when the database is open)   Enabling and disabling online redo log file archiving.ora if not found then. You can bring the database into the o pen mode by issuing the ALTER DATABASE command as follows: .

If media recovery rather than instance recovery is needed. the Oracle server first opens all the data files and the online redo log files. it’s the greater of 48MB or 4MB * number of CPUs * granule size. Oracle Parameter related to Database Buffer Cache DB_CACHE_SIZE This parameter sets the size of the default buffer pool for those buffers that have the primary block size (this is the block size defined by DB_BLOCK_SIZE). If we aren't using SGA_TARGET. we simply use the STARTUP command to mount and open our database all at once: SQL> STARTUP To open the database.SQL> ALTER DATABASE OPEN. to move the database from NOMOUNT TO MOUNT or from NOMOUNT TO OPEN use ALTER DATABASE COMMAND ALTER DATABASE MOUNT. For example. we can use a number like 1. IN SHORT Opening a database includes the following tasks:   Open online data files Open online redo log files NOTE If any of the data files or online redo log files are not present when you attempt to open the database. if the SCNs in the control files don’t match some of the SCNs in the data file headers—the background process will automatically perform an instance recovery before opening the database. STARTUP COMMAND  use to start database STARTUP NOMOUNT. and verify that the database is consistent. ALTER DATABASE OPEN. DB_KEEP_CACHE_SIZE . Parameter type: Dynamic. Default value: If we're using the SGA_TARGET parameter. Database altered. If the database isn’t consistent—for example. the default is 0. More commonly. then the oracle server returns an error. It can be modified with the ALTER SYSTEM command. Oracle will signal that a database recovery is called for and won’t open the database until you perform the recovery.024MB.

any object will remain in the pool as long as free memory is available in the buffer cache. Oracle removes objects from this pool as soon as the objects are used. the oldest unused objects sitting in memory are removed to make space for new objects. DB_nK_CACHE_SIZE If we prefer to use nonstandard-sized buffer caches. Oracle SGA_TARGET Parameter SGA_TARGET The SGA_TARGET parameter determines whether our database will use automatic shared memory management. Default value: 0 Parameter type: Dynamic. large pool. 8. Objects are removed (aged out) only when there is no free space.The normal behavior of the buffer pool is to treat all the objects placed in it equally. We don’t have to specify the five automatic shared memory components in our initialization file (shared pool. if we know that certain objects don’t really need to be in memory for a long time. this parameter is not configured. which removes the objects right after they’re used. which shows the values of all our . It can be changed by using the ALTER SYSTEM command. The parameter is set as follows: DB_RECYCLE_CACHE_SIZE = 200MB Default value: 0. In order to use automatic shared memory management. 4. For example. we can assi gn them to a recycle pool. and streams pool). The DB_KEEP_CACHE_SIZE parameter specifies the size of the keep pool. and it’s set as follows: DB_KEEP_CACHE_SIZE = 500MB Default value: 0. In contrast. You can change this parameter’s value with the ALTER SYSTEM command. as in the following two examples: DB_4K_CACHE_SIZE=2048MB DB_8K_CACHE_SIZE=4096MB The values for n that can be used in this parameter are 2. by default. When this happens. Parameter type: Dynamic. 16. this parameter is not configured. That is. by default. Oracle will show zero values for these when we query the V$PARAMETER view. It can be changed by using the ALTER SYSTEM command. set the SGA_TARGET parameter to a positive value. database buffer cache. we need to specify the DB_nK_CACHE_SIZE parameter for each. or 32. Parameter type: Dynamic. DB_RECYCLE_CACHE_SIZE The DB_RECYCLE_CACHE_SIZE parameter specifies the size of the recycle pool in the buffer cache. the keep pool always retains an object in memory if it’s created with the KEEP option. The use of two specialized buffer pools—the keep pool and the recycle pool—allows us to specify at object-creation time how we want the buffer pool to treat certain objects. Java pool.

we can leave out all the automatic SGA parametersDB_CACHE_SIZE. the nondefault-sized buffer cache pools and nKBsized buffer caches. Default value: 0 (no automatic shared memory management) Parameter type: Dynamic. choose minimum values for any of the five auto-memory parameters. and STREAMS_POOL_SIZE—from our init.ora file. and the fixed SGA allocations) will be deducted from the SGA_TARGET value first. we disable automatic shared memory management. We may. however. JAVA_POOL_SIZE. the buffer cache keep pool. SHARED_POOL_SIZE. The value for SGA_TARGET must be a minimum of 64MB. in which case we should specify the values in the initialization file. When we use automatic shared memory management by setting a value for the SGA_TARGET parameter. while making sure that the database is compatible with an earlier release.initialization parameters. If we set the SGA_TARGET parameter to zero. the buffer cache recycle pool. run the following query: SQL> SELECT ( (SELECT SUM(value) FROM V$SGA) (SELECT CURRENT_SIZE FROM V$SGA_DYNAMIC_FREE_MEMORY) ) "SGA_TARGET" FROM DUAL. To get a quick idea about how much memory to allocate for the SGA_TARGET parameter under automatic shared memory management. and we have to manually set the values for all the previously mentioned SGA components. LARGE_POOL_SIZE. Note If we set the SGA_TARGET parameter. Oracle Compatible Parameter COMPATIBLE The COMPATIBLE parameter allows us to use the latest Oracle database release. . You can use the ALTER SYSTEM command to modify the value. and the upper limit is dependent on the operating system. in which case we can explicitly specify them in the file. unless we want to ensure a minimum size for some of these. the memory we allocate for the manually sized components (the log buffer.

ora A text file that contains a list of all initialization parameters. Server parameter file (SPFILE): Dynamic persistent server parameter file SPFILE. commonly referred as initSID. Default value: 10.0 Parameter type: Static DB_NAME and DB_UNIQUE_NAME DB_NAME The DB_NAME parameter sets the name of the database. commonly 2.2 features. In this case. we can reset the COMPATIBLE initialization parameter to 10.2.ora A binary file that contains the initialization parameters Initialization parameter file (pfile): Static parameter file. The DB_NAME value should be the same as the value of the ORACLE_SID environment variable. before we set the value for this parameter. Types of initialization parameter file Oracle uses a parameter file to store the initialization parameters and their settings for an instance. instead.2). If. PFILE.0.2.Suppose we upgrade to the Oracle Database 10g Release 2 version. we immediately raise the compatible value to 10. Default value: false Parameter type: Static DB_UNIQUE_NAME The DB_UNIQUE_NAME parameter lets us specify a globally unique name for the database. after the application has been suitably upgraded. You can have a DB_NAME value of up to eight characters. referred as spfileSID. we could set the COMPATIBLE parameter equal to 9. This parameter can’t be changed after the database is created. which is the default value for Oracle Database 10g Release 2 (10. We must understand this irreversible compatibility clearly. but our application developers haven’t made any changes to their Oracle9i application. we can use all the new 10.2.2 so the untested features of the new Oracle version won’t hurt our application. This is a mandatory parameter and the value is the same as the database name you used to create the database. but we won’t be able to downgrade our database to 9. Later on. We can use either of the following two types of parameter files: 1. Contents Of Parameter File A list of instance parameters The name of the database the instance is associated with .2 or any other lower versions.

ora (sid) means database name Text File Modified with an operating system editor Modification made manually Whenever we need to change the value of the parameter file we must shutdown the database. 'B023'). Saturday.ora  (sid) means database name .Ability to make changes persistent across SHUTDOWN and STARTUP .Can have RMAN support for backup the initialization parameter Verify Database 32/64 bit creation to check database been created originally in a 32-bit environment and is now on a 64-bit platform select decode(instr(metadata. '64bit Database'. (Archive Destination) The names and locations of control files.2.0\Db_1\database\initorcl.Allocation for memory structures of the SGA What to do with filled online redo log files.Maintained by the oracle server .ora Server parameter file: SPFILE :  spfilesid.Binary File . 2012 DB Buffer Usage Query . September 8. Information about undo tablespace.Can self-tune parameter values . The pfile is read only during instance startup.Always resides on the server side having read and write by database server . Text initialization parameter file: PFILE  initsid. (Changes take effect on next startup) For oracle 10g (R2)  default location E:\oracle\product\10. 0. '32bit Database') "DB Creation" from kopm$.

decode(lrba_seq. 3. 'Free'. 1. 2. decode(lrba_seq. s. 'Being Modified'). 'Not Modified'. 0. s. 'Available'.osuser os_user.CPU USAGE BY USER SELECT s. 'Free'. 'Available'. 'Other').action. 'Being Modified'). 2.username. 0.client_info. 0. '[ORACLE PROCESS]') user_name. . 'Being Read'. 0. s. 'Not Modified'.sid. count(*) "count" from sys.ksusestv cpu_usage.DB Buffer Usage select decode(state.module. nvl(s. 1. 'Being Read'. k. 3.machine.program. 'Other') block_status. CPU USAGE BY current Users --. s. s. s.-.serial#.x$bh group by decode(state. s.

'CTXSYS'. 'EXP_FULL_DATABASE'. s sys. 'UNLIMITED TABLESPACE') admin_option = 'YES') grantee not in ('SYS'. privilege. 'MDSYS'. 'ORDSYS' ) Oracle User info using Process ID set serveroutput on size 50000 set echo off feed off veri off accept 1 prompt 'Enter Unix process id: ' DECLARE v_sid number. 'DBSNMP'.x$ksusesta k WHERE k. 'OEM_MONITOR'.ksusestn = 12 AND s. 'IFSSYS'.v_$session%ROWTYPE. 'IMP_FULL_DATABASE'. 'SYSTEM'.ksusestv DESC Find Power Privileges given to users To check which Powerful privileges are granted to users perform following query select grantee.type != 'BACKGROUND' ORDER BY k. sys.indx = s. 'ORDPLUGINS'. .s. 'OUTLN'. admin_option from where or or and sys. 'AQ_ADMINISTRATOR_ROLE'.dba_sys_privs (privilege like '% ANY %' privilege in ('BECOME USER'.logon_time FROM v$session s. 'DBA'.sid AND k.

v_$session where sid = v_sid. select * into s from sys. return.put_line('Foreground .v_$process where addr = s. BEGIN begin select sid into v_sid from where and or exception when no_data_found then dbms_output. select * into p from sys.process||' . dbms_output. end.put_line('SID/Serial s.program). : '|| : '|| 'PID: '||s.v_$process p.paddr = &&1 s.process = '&&1'). sys.v_$session s p. dbms_output. dbms_output.paddr.put_line('Unable to find process id &&1!!!').'||s.addr (p.put_line('======================================== ==========').put_line(sqlerrm).'||s.sid||'.v_$process%ROWTYPE. return. sys.serial#).spid = s. when others then dbms_output.p sys.

put_line('Latch Spin 'NONE')).server||' '||s.program).osuser||' on : '|| s.put_line('Previous SQL statement:').latchwait. 'NONE')).username). for c1 in ( select * from sys.spid||' : '|| s.' || to_char(s.0') || ' min'). for c1 in ( select * from sys. dbms_output.put_line('Lock/ Latch : '|| nvl(s. : '|| to_char(s. : '|| nvl(p.machine). dbms_output.v_$sqltext . dbms_output. dbms_output.last_call_et/60.sql_hash_value order by piece) loop dbms_output.put_line('Last Call : '|| to_char(sysdate(s.latchspin. 'NONE')||'/ '||nvl(p.taddr.dbms_output. end loop. dbms_output.terminal). dbms_output.type).put_line(chr(9)||c1. dbms_output.put_line('Login Time 'Dy HH24:MI:SS')).put_line('Shadow '||p.put_line('Ora User : '|| 'PID: '||p. dbms_output.put_line('Status Flags: '|| s. '990.put_line('Tran Active : '|| nvl(s.put_line('Current SQL statement:').terminal || '/ ' || : '|| s.logon_time.v_$sqltext where HASH_VALUE = s. dbms_output. 'Dy HH24:MI:SS') || ' . dbms_output.sql_text).status||' '||s.put_line('Terminal p.put_line('OS User '||s. dbms_output. 'NONE')).last_call_et/60/60/24).lockwait.

Short locks 'BL'.Long locks 'TM'. 'DML/DATA ENQ'. for c1 in ( select * from sys.v_$session_connect_info where sid = s. ENQ'.v_$session_wait where sid = s. dbms_output.event).sid) loop -dbms_output.network_service_banner).put_line('Locks:'). -. for c1 in ( select /*+ ordered */ decode(l.sql_text). -. -end loop.where HASH_VALUE = s. end loop. FILE'. dbms_output. -- dbms_output.prev_hash_value order by piece) loop dbms_output.put_line('Session Waits:').put_line(chr(9)||c1. 'CONTROL 'TX'.put_line(chr(9)||': '||c1. -. 'BUF HASH TBL'.type.put_line(chr(9)||c1. 'PLS USR LOCK'. 'CF'. 'UL'.sid) loop dbms_output. end loop.for c1 in ( select * from sys.state||': '||c1.put_line('Connect Info:'). 'TRANSAC .

'MOUNT/STRTUP'. 'PF'. 'EXTEND . 'SEQNO VALUE '. 'PROCESS 'SC'. '. 'FILE SET NUM'. 'SMON LOCK INSTCE'. 'CROSS INST F'. FILE '. '. 'SEQNO 'ST'. 'GET 'KK'. '. 'INSTCE RECVR'. 'SEQNO ENQ TRANSC'. 'DISTRIB 'IN'. 'MEDIA 'PR'. 'LS'. 'RECO LOCK TRAN'. 'RT'. 'LIBCACHE INV'. 'ROW WAIT 'SM'. 'SCN 'SN'. '. 'INSTANCE 'IS'. '. '. 'IV'. 'RW'. 'SPACE 'TA'. 'TD'. '. 'DATA 'DM'. 'DIRECT LOAD '. 'CURSOR BIND '. '. 'SGA OPN FILE'. STATE '. 'FS'. 'IR'. '. 'SQ'. 'LOG SW KICK 'MR'. 'GENERIC ENQ 'TE'. '. 'DLL ENQ SEG '. '. 'MOUNT DEF RECVRY'. 'FI'. 'DF'. 'LOG SWITCH 'MM'.'CI'. 'DL'. 'DR'. 'DX'. 'SV'. 'REDO THREAD '. 'PWFILE ENQ STRT'. ENQ '. 'CU'.

'X'. to_char(l. 'FILE#='||substr(l. 'TM'. 'RS'.id1. o.1.id2. 'TS'. 'RT'. 4. 'NULL'.id1 = o. 'RS'. 'NONE'.request) ) lrequest. 'ID1='||l. 'RX'. 1. 'TEMP 'WL'. 'NULL'.sid where sid and l. 'X'. 'S'. 'RS+SLOT#'||l. decode(l. 'USER NAME '. 'UN'.request. 'S'.name. 'TT'. 'NONE'. '. 6. 'TX'. 'TD'. decode(l.type. 0.id1. 2. 'THREAD='||l. 5. 'WL'. 'RX'. 'TEMP SEGMENT'.5)||' ROW='||l.3)|| ' BLOCK#='||substr(l. o.name.id1||' ID2='||l. 'RW'. to_char(l.v_$lock l.obj#(+) ) loop .id2. 'WRITE decode(l.'TS'.id1. 'TYPE='||l. 2.id2) objname from sys. 0.id1||' WRP#'||l. 'RSX'. 'MR'. TABLE REDO '.obj$ o = s.id1. decode(l. o. 6. 0. 'NEW BLOCK ALLOCATION').id2. 'RSX'. 1. 'ENQUEUE'.4.name. 3.type) type.lmode. 4. 'REDO LOG FILE#='||l.lmode) ) lmode. 3. 5. sys.

• db: Oracle records the same type of auditing as with the os setting.EXTENDED: This value prints all database audit records plus the SQLTEXT and SQLBIND values to OS files in the XML format. If we don’t want auditing to be turned on. but also provides extended audit information like the SQLBIND and SQLTEXT columns of the SYS.'||c1. end loop. In addition. On a UNIX system. which is the AUD$ table owned by SYS.objname).2): • XML: This value for audit trail enables database auditing and writes audit details to OS files in XML format. • XML. since the default value for this parameter is none.extended: This is similar to the db setting.dbms_output. which is an operating system file. • none: This value disables auditing. the . we can set the AUDIT_TRAIL parameter to any of the following values: • os: Oracle writes the audit records to an operating system audit trail. Oracle will still write audit information to an operating system file for all database actions that are audited by default. If we want auditing turned on. undef 1 Oracle 10g Parameters related to Audit AUDIT_TRAIL The AUDIT_TRAIL parameter turns auditing on or off for the database. but it directs all audit records to the database audit trail. you have two XML-related AUDIT_TRAIL values (new in Oracle Database 10.put_line('======================================== ==============='). • db.lrequest||' . END. and those database actions that are always automatically audited. audit records for the SYS user. which disables database auditing. including audit records from the OS. dbms_output.AUD$ table. do nothing.put_line(chr(9)||c1. The parameter is set as follows: AUDIT_TRAIL = db Default value: none Parameter type: Static Chapter 11 provides more information about auditing actions within an Oracle database.lmode||' R: '||c1. or false.type||' H: '||c1. Tip Even if we don’t set the AUDIT_TRAIL parameter to any value.

We can also specify this parameter if we choose the XML or XML.AUD$) will start growing and because is relies on SYSTEM tablespace you might have performance problems in the future. You can modify this parameter with the ALTER SYSTEM . Create a SYSTEM. DEFERRED command. will audit all actions of the SYS user and any other user with a SYSDBA or SYSOPER role and will write the details to the operating system audit trail specified by the AUDIT_TRAIL parameter. from a 5TByte E-Business Suite. 1. . CREATE TABLE SYSTEM. with 50MB auditing produced every day.default location for this file is the $ORACLE_HOME/rdbms/audit directory. (stored in table SYS. By writing the audit information to a secure operating system location. if set to a value of true. Here is a practical guide. Default value: false Parameter type: Static Auditing If you enable auditing then the auditing information. Of course. See Chapter 11 for more details on this feature. we can specify a different directory if we wish.EXTENDED options for the AUDIT_TRAIL option. we remove any possibility of the SYS user tampering with an audit trail that is located within the database. The possible values are true and false. Auditing housekeeping must be setup.AUD$ . . AUDIT_SYS_OPERATIONS This parameter.AUD$_BU TABLESPACE AUDIT_DATA AS SELECT * FROM SYS. since the audit records are written to operating system files in both cases.dbf' SIZE 10000M AUTOEXTEND OFF LOGGING PERMANENT EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT MANUAL. AUDIT_FILE_DEST The AUDIT_FILE_DEST parameter specifies the directory in which the database will write the audit records.AUD$_BU table stored in a different tablespace(AUDIT_DATA) where you will move all you auditing produced CREATE TABLESPACE AUDIT_DATA DATAFILE '/filesystem034/oradata/SID/audit_data_001. when we choose the operating system as the destination with the AUDIT_TRAIL parameter by specifying AUDIT_TRAIL=os. Default value: $ORACLE_HOME/rdbms/audit Parameter type: Dynamic.

COMMIT. END IF. Tip: To speed up searching on SYSTEM.INTERVAL => 'TRUNC(SYSDATE+1)' .AUD$ to SYSTEM. / 3.Dbms_System.AUD$_BU (USERID) NOLOGGING TABLESPACE AUDIT_DATA.SUBMIT ( job => X .aud$ .ksdwrt (3. 2. IF rowCount > 0 THEN COMMIT. CREATE INDEX SYSTEM.'ORA-AUDIT TRAIL: rows moved from SYS.AUD$_BU_USERID_IDX ON SYSTEM.WHERE 1=2.aud$).'dd/mm/yyyy hh24:mi:ss') .aud$_bu (SELECT * FROM sys.aud$'.AUD$_BU you can create 2 indexes (one on timestamp# and the other to userid) CREATE INDEX SYSTEM. Create a procedure(Keep_Size_Aud_Log) that moves the rows from SYS.next_date => TO_DATE('27/02/2008 12:35:21'. Unit II Preparing for OCP DBA Exam 2: Database Administration Basics of the Oracle Database Architecture .AUD$_BU_TIME_IDX ON SYSTEM. sys.AUD$_BU').KEEP_SIZE_AUD_LOG. BEGIN SELECT COUNT(*) INTO rowCount FROM sys.AUD$ to SYSTEM.' .no_parse => FALSE ). Execute the procedure every day at midnight with a job DECLARE X NUMBER.AUD$_BU (TIMESTAMP#) NOLOGGING TABLESPACE AUDIT_DATA. BEGIN SYS.DBMS_JOB. EXECUTE IMMEDIATE 'truncate table sys.what => 'SYS. INSERT /*+ APPEND */ INTO SYSTEM. END. END Keep_Size_Aud_Log.AUD$_BU CREATE OR REPLACE PROCEDURE Keep_Size_Aud_Log IS rowCount NUMBER.

You should review this chapter carefully. Whatev er the Oracle feature. This discussion will explain the components of the SGA and the PGA. About 22 percent of OCP exam 2 is on material in these areas. All three structures of the Oracle database server running together to allow users to read and modify data are referred to as an Oracle instance. Oracle Memory Structures Focus first on the memory components of the Oracle instance. and your day-to-day responsibilities as an Oracle DBA. to recovery mechanisms that allow the DBA to restore systems after seemingly unrecoverable problems. which is commonly referred to as the SGA. both to be a successful Oracle DBA and to be a successful taker of the OCP Exam 2 for Oracle database administration. There are also disk resources that store the data that applications use to track data for an entire organization. you will understand and demonstrate knowledge in the following areas: The Oracle architecture Starting and stopping the Oracle instance Creating an Oracle database A major portion of your understanding of Oracle. Oracle in action consists of many different items. Some of these components are memory structures. is understanding the Oracle database architecture. This set of memory components represents a "living" version of Oracle that is available only when the instance is running. from memory structures. The other memory structure in the Oracle instance is called the Program Global Area. as the concepts presented here will serve as the foundation for material covered in the rest of the book. The Oracle Architecture In this section. and also cover the factors that determine the storage of information about users connected to the Oracle instance. while others are processes that execute certain tasks behind the scenes.In this chapter. memory. All of these features working together allow Oracle to handle data management for applications ranging from small "data marts" with fewer than five users to enterprise-wide client/server applications designed for online transaction processing for 50. The first and most important is called the System Global Area. it’s all here. and process components of the Oracle instance. to special processes that make things run faster. you will cover the following topics related to the Oracle architecture: Oracle memory structures Oracle background processes Oracle disk utilization structures The Oracle database server consists of many different components. certification series. or PGA.000+ users in a global environment. Figure 6-1 demonstrates the various disk. and special resources designed to allow for recovering data from problems ranging from incorrect entry to disk failure. There are two basic memory structures on the Oracle instance. .

Since every . the specific data returned by the query for each user will not reside in the shared pool. The SGA consists of three different items. One fact that is important to remember about redo logs and user processes is that every process that makes a change to the database must write an entry to the redo log in order to allow Oracle to recover the change. listed here. Explore the usage of the shared pool in the Oracle database architecture. they are talking about the SGA. the Oracle database avoids contention for disk usage that would invariably cause database performance to slow down. The final area of the SGA is the redo log buffer. and thus not be shared. By having all user processes writing those redo log records to memory. also referred to by many DBAs as the "row" cache. The redo log buffer allows user processes to write their redo log entries to a memory area in order to speed processing on the tracking of database changes. The availability of a buffer for storing redo information in memory prevents the need for user processes to spend the extra time it takes to write an entry directly to disk. When DBAs talk about most things related to memory. This information is treated as a shared resource in the library cache. The other mandatory component of the shared pool is the data dictionary cache. the database as a whole benefits in terms of performance from the presence of cached dictionary data in memory. The SGA stores several different components of memory usage that are designed to execute processes to obtain data for user queries as quickly as possible while also maximizing the number of concurrent users that can access the Oracle instance. which stores online redo log entries in memory until they can be written to disk. The shared SQL library cache is designed to store parse information for SQL statements executing against the database. This memory structure is designed to store the data from the Oracle data dictionary in order to improve response time on data dictionary queries. The shared pool has two required components and one optional component. these database changes are kept in order to rebuild database objects in the event of a disk failure. Since all user processes and the Oracle database internal processes use the data dictionary. Of course. The buffer cache The shared pool The redo log buffer The buffer cache consists of buffers that are the size of database blocks. They are designed to store data blocks recently used by user SQL statements in order to improve performance for subsequent selects and data changes. the database will recognize the opportunity for reuse and let the user process utilize the parse information already available in the shared pool. When the database is set up to archive redo logs.The Oracle SGA The Oracle SGA is the most important memory structure in Oracle. If another user process comes along wanting to run the same query that Oracle has already parsed for another user. Parse information includes the set of database operations that the SQL execution mechanism will perform in order to obtain data requested by the user processes. The required components of the shared pool are the shared SQL library cache and the data dictionary cache. because sharing data between applications represents a data integrity/security issue. The optional component of the shared pool includes session information for user processes connecting to the Oracle instance.

data change process has to write a redo log entry. and present the selected output to the user. the MTS architecture. After the user’s select statement has completed. Another structure exists in the buffer cache. sort areas. it makes sense that processes be able to write that change as quickly as possible in order to boost speed and avoid problems. the block that contains the row will then be called a dirty buffer. each user process has its own dedicated server process reading data blocks into the buffer cache. Oracle looks in the buffer cache to see if the data block that contains the row has already been loaded. The PGA is used to store real values in place of bind variables for executing SQL statements. Whether user session information is stored in the PGA or the shared pool depends on whether the multithreaded server (MTS) option is used. No user process ever interfaces directly with any record on a disk. and the purpose of the Server process appear in this discussion. The procedure is the same for a data change. such as bind variable information. the DBA should know that the database already stores parse trees for recently executed SQL statements in a shared area called the library cache. then Oracle must locate the data block that contains the row. When the user wants to select data from a table. If it has. Exercises 1. More information about shared vs. When the DBA uses MTS. The buffer cache stores data blocks that contain row data that has been selected or updated recently. and it is designed to store those dirty buffers until the changes are written back to disk. load it into memory. and Unit V of this Guide. There is one overall performance gain that the buffer cache provides that is important to note . which simply means that some row in the buffer has been changed. and what are its components? What is the function of the PGA? . then the buffer cache has achieved its selective performance improvement by not having to look for the data block on disk. In the dedicated server process configuration. Unit IV. the PGA stores session information for each user running against Oracle. called the dirty buffer write queue. The final SGA resource is the buffer cache. The Oracle PGA The PGA is an area in memory that helps user processes execute. and other aspects of cursor handling. From the prior discussion of the shared pool. except that after Oracle writes the data to the row. . This area of memory allows for selective performance gains on obtaining and changing data. why do the users need their own area to execute? The reason users need their own area in memory to execute is that. So. If not. MTS relates to how Oracle handles user processes connecting to the database. even though the parse information for SQL or PL/SQL may already be available. This fact is true for the redo log buffer as well. . When MTS is not used. dedicated servers. Oracle keeps the block in memory according to a special algorithm that eliminates buffers according to how long ago they were used. What is the name of the main memory structure in Oracle. 2. all data is read into the database buffer cache by shared server processes acting on behalf of user processes. Location of User Session Information The question of location for user session information is an important one to consider. When the DBA uses the MTS configuration. the values that the user wants to execute the search or update upon cannot be shared. session information is stored in the shared pool of the SGA.

This setup is allowed because the Oracle instance has its own background processes that handle everything from writing changed data blocks onto disk to securing locks on remote databases for record changes in situations where the Oracle instance is set up to run in a distributed environment. First. It works in conjunctio the Oracle database buffer cache memory structure. this background process hand resolution of distributed transactions against the database. the SMON process handles disk sp management issues on the database by taking smaller fragments of space and "coalescing" them. It prevents users from ever accessing a disk to perform a da change such as update. Finally. Likewise. . There are several background processes in the Oracle instance. those updated blocks are written to disk by DBW These events are called checkpoints. there will be user processes accessing information. It was mentioned in the discussion of the SGA that no user process ever interfaces directly with I/O. using background processes. The usage and function of this Oracle background process is twofold. PMON watches the user processes on the database to make sure that they work co If for any reason a user process fails during its connection to Oracle. LGWR handles telling DBWR to write the changes. SMON The system monitor process. DBWR The database writer process. This process also writes the log sequence number of the current online redo log to th datafile headers and to the control file. or piecing the together. In any Oracle instance. In Oracle databases using the distributed option. LGWR handles initiating the process of clearing the dirty buffer w queue. In Oracle databases that archive their online redo logs. in the ev an instance failure—when the memory structures and processes that comprise the Oracle instance cannot contin run—the SMON process handles recovery from that instance failure. This background process handles all data block writes to disk." or backed out of the database reverted to their original form. the Oracle instance will be doing some things behind the scenes.3. the ARCH process handle automatically moving a copy of the online redo log to a log archive destination. PMON will clean up the remnants of its activ and make sure that any changes it may have made to the system are "rolled back. This background process handles the writing of redo log entries from the redo log buffer t online redo log files on disk. insert. Second. At various times. LGWR The log writer process. or delete. Where is user session information stored in memory on the Oracle instance? How is its location determined? Oracle Background Processes A good deal of the discussion around users thus far speaks of processes--user processes doing this or that. . The following list presents each background process and its role in the Oracle instance. ARCH (optional) The archiver process. PMON The process monitor process. depending on database configuration. RECO (optional) The recoverer process.

CKPT (optional) The checkpoint process. when users conn the database. 2. In high-activity databases. which connects the process to a dispatcher. segments. and recover an Oracle database. the DBA sees the physical database files that store these logical database structures. Executes data reads from disk on behalf of user processes. they must obtain access to a shared server process via a dispatcher process. the table acquires an extent to place the additional data in. However. Exercises 1. CKPT can be used to handle writing log sequence numbers to the datafile headers and control file. When the row data for a table exceeds the space allocated to it by the segment. D001. LCK9 (optional) The lock processes. depending on whether the DBA uses MTS or not. Through another. store. This process acts as part of the Oracle MTS architecture to connect user proce shared server processes that will handle their SQL processing needs. An extent is similar to a segment in that the extent stores information corresponding to a table. Figure 6-2 demonstrates the concept of a logical and physical view of storage in the Oracle instance. S999 The server process. alleviating LGWR of that responsibility. There are structures that are stored on disk that the DBA must understand how to manage. access. or series of rollback entries. The user process comes into the database v SQL*Net listener. the dispatcher finds the user process shared server that will handle interacting with the database to obtain data on behalf of the user process. and this section will identify and discuss the meaning of each structure in kind. D999 (optional) The dispatcher process. S000. index.. the DBA must first understand that there are two different "lenses" through which he or she must view the way Oracle looks at data stored on disk. A segment is a logical data object that stores the data of a table. 3. the difference is that an extent handles table growth. and extents. of which there can be as many as ten. In databases that use the Parallel Server op this background process handles acquiring locks on remote tables for data changes. Through one lens. Access to Server processes can eit shared or dedicated. described below. Name the background process that handles reading data into the buffer cache. Figure 2: The logical and physical views of a database A tablespace is a logical database structure that is designed to store other logical database structures. These structures include tablespaces.. To begin. In the MTS architecture. the DBA sees the disk utilization of the Oracle database consisting of logical data structures. Which process handles writing data changes from the buffer cache back to disk? Which process handles writing redo log information from memory to disk? Which process can be configured to help it? Which background processes act as part of the multithreaded server (MTS) architecture? Which background process coalesces free space on disk? Oracle Disk Utilization Structures In addition to memory. The objects a DBA may place into a tablespace are things like . LCK0.. From there. Oracle must execute disk management processing in order to create.

After all redo logs are filled. The objects in a tablespace. The final database disk resource that will be covered in this section is the control file. and redo log files. Datafiles correspond to the tablespace level of the logical Oracle disk storage architecture in that a tablespace may consist of one or more datafiles. In turn.ora sets include the size of various objects of the SGA. The name of the control .tables. Another database disk resource that is used by Oracle is the password file. parameter files. or rollback segments cannot span across multiple tablespaces. such as tables and indexes. the files that comprise the current online redo log get fuller and fuller until they reach capacity. If redo log archiving has been selected. any datafile on the database can contain data for only one tablespace. either on the machine or on the entire network. the location of the control file. so it is imperative that the file be present at database startup. Individual data objects. the redo log is filled and LGWR switches writing redo log entries to the other redo log. LGWR begins reuse of the first redo log file it wrote records to. can have their segments and extents span across multiple datafiles belonging to that one tablespace. namely segments and extents corresponding to different tables. password files. and thus it is imperative to have a control file. can span across multiple datafiles. also referred to as redo log "members. Just as a table. The control file to the physical structure of the Oracle database is like the data dictionary to the logical structure. Each redo log can consist of one or more redo log files.ora. starting the entire process again. the password file is not present on the Oracle database. The parameter file is another important physical database disk resource that is available to Oracle. The password file is only used on Oracle databases that use database authentication. however. In addition to datafiles." In cases where operating system authentication is used. The other lens through which the DBA will view the data stored on disk is the physical lens. "Starting and Stopping the Oracle Instance. A logical database object such as a table or index can have multiple extents. either automatically by the ARCH process or manually by the DBA. as well as what the redo log member filenames are and where to find them. the redo logs are archived as well. Without a control file.ora. this file specifies many initialization parameters that identify the database as a unique database. the database name. indexes. The control file tells Oracle what the datafiles are called for all tablespaces and where they are located on the machine. The parameter file is commonly referred to as init. Data blocks store row data for segments and extents. Redo log files are used to store information about the changes users make to the database. rollback segments. provided that all datafiles are part of the same tablespace. Some parameters that init. These files are generally large enough to store many entries There are generally two (minimum) redo logs available to the LGWR process of the Oracle instance for the purpose of storing redo log entries. The use of operating system authentication will be covered in more detail in the next section. This resource stores passwords for users who have administrative privileges over the Oracle database. and others. and any other objects that consist of segments and extents. the blocks are taken together to comprise a datafile. the structures that Oracle uses to store information about the database on disk include: control files. The cornerstone of the physical method that Oracle uses to store data in the database is the Oracle data block. Oracle database server would be unable to find its physical components. but those extents and segments can be stored in only one tablespace. Underlying all the logical database objects in Oracle disk storage are the physical methods that Oracle uses to store those objects." The operation of online redo logs occurs in this way: LGWR writes entries to the files of one of the two (or more) online redo logs. The database cannot start without init. As the redo log entries are written to the logs. Used upon database startup. Once the capacity of all redo log members is reached. index.

the main disk resources of Oracle are listed below: Datafiles Redo log files Control files Exercises 1. To recap. The act of installing the Oracle software is specific to the operating system on the machine used to host the Oracle database.file is specified in the init. The first step of configuring the Oracle server is managing the creation and startup of the Oracle instance. Security in Oracle server consists initially of user authentication. the DBA must first answer an important question. you will cover the following topics related to starting and stopping the instance: Selecting an authentication method Starting an Oracle instance and opening the database Shutting down the Oracle instance Altering database mode and restricting login The first order of business for the DBA in many environments is to install the Oracle software. or whether the DBA plans to monitor the site remotely.ora file for the database instance. along with a password. How are the two linked? Starting and Stopping the Oracle Instance In this section. 3. Just as users supply a password. Once installation is accomplished. in order to gain entry into the database. Oracle offers two options with respect to password authentication. However. Name five physical disk resources on the Oracle instance. The users of an Oracle system each have a username that they enter. Selecting an Authentication Method In order to determine what method of authentication to use for the Oracle database. That question is "How do I plan to support this database?" The answer to that question usually boils down to whether the DBA will be working on the same site as the host machine running Oracle primarily to support database administration tasks. 2. the DBA will start working on other aspects of the Oracle server before actually creating his or her first database. and the first step for managing the instance is password authentication. with a monitoring server that manages the database administration for many other databases in addition to the one being set up. . so too must the DBA. What are the three logical resources on the Oracle instance? Explain the difference between a logical view of disk resources and a physical view of disk resources.

If the DBA can in fact obtain a secure connection with the host system running Oracle. By using operating system authentication. the DBA will be able to log onto the database simply by using the "/" character in place of a username and password. then the choice of whether to use operating system authentication or Oracle authentication is largely a matter of personal preference. However. the DBA thereby requires Oracle users to provide a password only when logging into the operating system on the machine hosting Oracle.98) Login: bobcat Password: User connected. then the question of whether or not a secure connection can be established with the host system running Oracle must be answered. The decision-making flow may go something like this. or to grant the DBA special prioritization for executing processes on the host . if the DBA logs onto the machine hosting Oracle and wants to execute some privileged activities such as creating users or otherwise administrating the database. not only is the host machine at risk to the extent that the user has access to the machine’s resources. then the DBA can use either the Oracle method of authentication or the operating system authentication method.45. he or she can simply use the "/" character at login time and Oracle will verify with the operating system that the user’s password is correct and allow access. If the DBA plans to administer the database locally. distributed. If the DBA cannot obtain a secure connection remotely.0 (c) 1979. and multithreaded server options Operating system authentication allows the user or DBA to access the database quickly and easily. using the operating system to perform authentication on the Oracle database leaves Oracle’s data integrity and security at the level that the operating system provides. and also on a matter of preference. the login procedure for the DBA using operating system authentication may look something like the following: UNIX® SYSTEM V TTYP01 (23. it is recommended that where it does not hinder usage of the database and where it improves security. Connected to Oracle 7. but the Oracle database is at risk as well to the level that the user has access to Oracle resources.4 (23.45.The use of either depends on the answer to the question of whether the DBA will administer the database locally or remotely. with minimal typing and no chance that a password can be compromised at any time during the Oracle login process. To use operating system authentication first requires that a special group be created on the operating system level if that feature is supported. then the DBA must use the Oracle method of user authentication.0.67.1996 Oracle Corporation(c) All rights reserved. Today is 12/17/99 14:15:34 [companyx] /home/bobcat/ --> sqlplus / SQL*PLUS Version 3.3. If for some reason a user’s ID is compromised. in a UNIX environment. When the user wants to access the Oracle database. Operating system authentication presents some advantages and disadvantages to using Oracle’s methods for user authentication.67.98) With the parallel. use the Oracle methods of user authentication.3. If the database administrator is planning to administer the database from a remote location. For example.2. Therefore. The two methods available are to either allow Oracle to manage its own password authentication or to rely on the authentication methods provided by the operating system for Oracle access. Similarly.

this is not advised in situations where the database is administered by multiple database administrators who may have limited access to accomplish various functions. When the DBA connects to the database as internal. They have equivalents used with Oracle authentication —sysoper and sysdba. In this case. it is possible for the DBA to simply connect as internal when the need arises to do any DBA-related activities. the DBA can then perform certain operations to create databases and objects with operating system authentication. The sysdba keyword denotes a collection of privileges that are akin to those privileges granted with the internal keyword. respectively--and from here on this book will assume the use of Oracle authentication. The sysdba privilege administers certain other privileges as well. the DBA can connect to the database for the purposes of administration using the connect name/pass as sysdba command. In the future. Once the DBA is connected as internal and the database instance is started. and are used in conjunction with operating system authentication. for handling database reads for user processes.system for Oracle. In effect.. rather than dedicated servers. the DBA cannot connect as internal when shared servers are used in conjunction with the MTS architecture. The sysoper and sysdba privileges provide some breakout of responsibilities and function with the privileges they allow the grantee to perform. The internal privilege is a special access method to the Oracle database that allows the DBA to start and stop the database. thus. The ability to connect as internal is provided for backward compatibility. These two privileges are administrated via the operating system and cannot be revoked or administrated via Oracle. One additional constraint for connecting to the database as internal (in addition to having group privileges and proper process execution prioritization) is that the DBA must have a dedicated server connection. This step of some other operating system requirements must be fulfilled in order to connect to the database for startup and shutdown as internal. The sysoper privilege handles administration of the following privileges: Starting and stopping the Oracle instance Mounting or opening the database Backing up the database Initiating archival of redo logs Initiating database recovery operations Changing database access to restricted mode As shown by the types of privileges granted with sysoper. The performance of these functions is contingent upon the DBA having certain roles granted to their userid. The roles the DBA must have granted to them in this case are called osoper and osdba. it is better simply to grant sysdba or sysoper directly to the user who administers the system. and other availability functions. However. Those privileges are listed as follows: . Therefore. Choosing which privilege to grant to the user depends on what type of administrative functions the DBA may fulfill. sysdba is a DBA privilege that is granted to the DBA for startup and shutdown recovery and backup. the use of sysoper and sysdba. the sysdba and sysoper privileges are usually enabled as well.

where the database name is substituted for sid. there is another role that is created upon installation of the Oracle software. and its permitted settings are NONE. EXCLUSIVE. This role is called DBA. The location for the password file varies by database. and SHARED. and it also has all system privileges granted to it. The first step is to set a value for an initialization parameter in the init. the database administrator will be unable to execute administrative operations on the database. After creating the password file. the DBA simultaneously assigns the password for internal and SYS. The DBA first creates a file to store the authentication passwords for all persons that will be permitted to perform administrative tasks on the Oracle database. This functionality is managed by a special utility called ORAPWD. and should be executed with care to ensure that the DBA does not log off before the process is complete.The sysoper privilege All system privileges granted with admin option The create database privilege Privileges required for time-based database recovery Obviously. several items must be completed in order to continue with using Oracle’s authentication method to allow DBA access to the database without allowing access as internal. These various settings have different meanings with respect to allowing remote database administration on the Oracle instance. the REMOTE_LOGIN_PASSWORDFILE parameter may be set to NONE to disallow remote access to . This number will determine the number of users that will have administrator privileges allowed for their ID. this is the role granted to the DBA ultimately responsible for the operation of the database in question.pwd PASSWORD=phantom ENTRIES=5 Once this password file creation is complete. This process is dangerous. First. The actual execution of ORAPWD may look something like this from within Oracle: SQL> ORAPWD FILE=/home/oracle/dbs/orapworgdb01. a filename for the password file that stores users that can log in as DBA must be specified. The final item to be specified to the ORAPWD utility is the number of entries that are allowed to be entered into the password file. In addition. but for the most part it can be found in the dbs subdirectory under the Oracle software home directory of the machine hosting the Oracle database. Care should be taken when specifying this value. Oracle’s method of user authentication for database administrators when operating system authentication is not used is called a password file.ora file. If the DBA does log off after deleting the password file. The password for administering the password file is the next parameter that the ORAPWD utility requires. Entries can be reused as members of the DBA team come and go. he or she will not be able to do so without deleting and re-creating the password file. This parameter is called REMOTE_LOGIN_PASSWORDFILE. and the user’s and the password file’s passwords are changed. if the DBA connects as internal and SYS and issues the alter user name identified by password command in order to change the password. The filename for the password file is usually orapwsid. When operating system authentication is used on the database. The NONE setting means that the database will not allow privileged sessions to be established over nonsecured connections because no password file exists. By specifying a password for this file. The name of the password file can vary according to the operating system used by the machine hosting the Oracle instance. If too few values are specified and the DBA needs to add more.

it is an important point to make that the DBA should not look for objects they may create using their own username as the owner. What are the two Oracle roles granted to DBAs in order to perform database administration? . When using password file authentication to administer a database remotely via a nonsecure connection. The other feature is that any object created in any login as sysdba or sysoper will be owned by the SYS schema.the database for administration purposes. In this configuration. One such user that is created when Oracle is installed is SYS. All administrative operations on the database must happen by a DBA who logs into the instance as SYS or as internal when this option is set. The DBA can log into the database as user SYS and create the database and other usernames as necessary. SQL> CONNECT john/mary AS SYSDBA. SQL> There are two important key points to remember with respect to password files.ORA in order to use a password file for authentication. the DBA can query a dynamic performance view from the Oracle data dictionary on the password file called V$PWFILE_USERS. Connection succeeded. More on the data dictionary will be presented in this chapter. What is the name of the utility used to create a password file? Describe its usage. One is gaining information about the users listed in them. the REMOTE_LOGIN_PASSWORDFILE parameter should be set to EXCLUSIVE. Then. While this fact of ownership may not be all that important. parameters. 2. which means that the password file allows access only by SYS and the DBA connected as internal. 3. The following code block shows how the DBA can set this parameter in the init. the other is related to schema ownership. allowing the DBAs to log into the database as themselves with all administrator privileges. The final option is SHARED. the objects they create will be owned by their schemas. What two methods of user authentication are available in Oracle? Explain some advantages and disadvantages for each. To find out which users are in the database password file. and the related parameter that must be set in INIT. the DBA can then connect to the database as some user with sysdba privileges. especially given the ability to create and use public synonyms to obtain data without regard to schema ownership. or simply mount the existing database. Exercises 1. In the event that the DBAs simply log in as themselves without the as sysdba trailer. the other users that will administer the instance can log onto it as themselves and execute DBA tasks as needed. the DBA will add users who will administer the Oracle instance to the password file and grant the sysoper and sysdba privileges directly to those userids. After creating the password file with the ORAPWD utility and setting the REMOTE_LOGIN_PASSWORDFILE parameter to EXCLUSIVE in order to administer a database remotely.ora file: REMOTE_LOGIN_PASSWORDFILE=none REMOTE_LOGIN_PASSWORDFILE=exclusive REMOTE_LOGIN_PASSWORDFILE=shared The EXCLUSIVE setting indicates that the password file developed by the ORAPWD utility for security use on that database instance can be used for that instance and that instance only.

In Server Manager. the startup command can be issued with an option called nomount. The appropriate tool in this case is Server Manager or Enterprise Manager. an Oracle instance is NOT an Oracle database. This step is the first that should be accomplished when creating a new database or allowing access to an existing database. it should also be said that the Oracle instance is very close in similarity to the Oracle database. This option is used for preventing any problems with existing databases that are mounted at the time that a new database is created. Start the appropriate administrative tool and connect as sysdba or internal. With those points made. The Oracle instance is the memory structures. Another recommended safety measure for creating new databases in the same instance that . the DBA should do the following: 1. To start the Oracle database instance. With that distinction made. or starting the database and initializing recovery from failure. The Oracle database is a set of tables. The distinction is between an Oracle instance and an Oracle database. What is SYS? How is it used? Starting the Oracle Instance and Opening the Database There is an important distinction that sometimes gets blurry in the minds of DBAs and especially Oracle developers who don’t work with Oracle internals often enough to notice a difference. and other data objects that store information that applications place into storage in the Oracle product. This option will start the instance for database creation. These different options correspond to the level of access to the database once the database instance is running. all working together to fulfill user data requests and changes. The DBA must supply the name of the database (also known as the SID) and the parameter file Oracle should use to start the database. There are several different options the DBA can use to specify the startup status of the database. performing a forced start. For starting the instance without mounting the database. and disk resources. This set of options is listed below: Startup nomount Startup mount Startup open Startup restricted Startup force The first option available is starting up the instance without mounting the database. mounting and opening for anyone’s use. The options available for starting up an Oracle database are starting the database without mounting it. but will not open any other database that may be available to the Oracle instance. procedures. attention should now turn to starting the Oracle instance.4. mounting and opening in restricted mode. background processes. Within the Server Manager tool there are several different options for database availability at system startup. First of all. the command used for starting any database is the startup command. Each startup feature has several associated facts about the access level permitted while the database is running in that mode. use the startup start_option command to start the instance. indexes. 2. with mounting but not opening. Using Server Manager.

reorganizing or renaming objects. first and foremost so that users and applications can access the database in order to work. Hence. Typically. The DBA will need to specify the database name and the parameter file for this option to mount the database to the instance for the physical database object maintenance activities described above. . the DBA will execute the startup option as before. In any event.already owns a database is to back up the existing database before creating the new one. the DBA may want to consider a temporary grant of restricted session to the developer. the options considered now are called opening the database. There are two special cases for database startup left to consider. in addition to starting and opening the database. However. The DBA will open the database for many reasons. In some cases. the DBA can execute the startup restrict command within Server Manager. In other situations. the DBA may need to work on some aspect of the physical database structure. the DBA must use the startup open option. the DBA may grant the restricted session privilege to a developer who is assisting in the database maintenance work. Although any user on the database can have this privilege granted to them. In this case. In situations where the DBA needs to perform a full database recovery." TIP: In a database that is mounted. but the mode option used in this situation is the mount option. such as the movement of redo log file members. In order for the DBA to start the instance and then mount and open the database. In these situations. the DBA can issue the startup recover command from the Server Manager tool. and Oracle will start the instance and initiate the complete recovery at instance startup. or to specify the usage of Oracle’s archival of redo logs feature. the DBA will execute a special command that restricts database access to only those users on the system with a special access privilege called restricted session. A complete discussion of backup and recovery occurs in Unit III. A nonmounted database can be mounted to an instance after creation of that database using commands described in the section of this chapter titled "Altering Database Availability. In this case. data files. the DBA can alter the control file. any user with a valid username and password who has been granted the create session privilege or the CONNECT role can access the Oracle database. The same startup command is used for starting the database in all modes. creating new indexes or fixing old ones. the DBA may want the instance to initiate its complete recovery at the time the instance is started. both of which are used for circumstances outside of normal database activity. the DBA will want to use the restrict option for logical database object maintenance such as reorganizing tablespaces. To accomplish the task. followed by a revocation of the privilege afterward to prevent possible data integrity issues in later maintenance cycles. large-volume data loads. Once the DBA has opened the database. the DBA may want to start the instance and mount but not open an existing database for certain DBA maintenance activities. One of those two situations is when the database has experienced a failure of some sort that requires the DBA to perform a complete database recovery of the database and the instance. In this case. the DBA should mount but not open the database. the DBA may want to open the database without letting users access the database objects. Oracle may require certain archived redo logs to be present for this option to complete successfully. All other options for starting a database will allow access to the database in one form or another. In some cases. and other DBA maintenance activities. From database startup. In cases where archiving is used. This method is generally preferable to a permanent grant of restricted session to someone outside the DBA organization. This is the most common situation for a DBA to start the database in when there is DBA maintenance activity required on the logical portion of the Oracle database. such as in the case of reorganizing large tables that involves a large-volume data load. typically only the database administrator will have it.

as there is usually a need for instance recovery in this type of situation. either graphically with the use of the Shut Down menu under the Instance menu or with the shutdown command in line mode. The DBA can give database startup an additional shove with the startup force command option. The task must also be accomplished from the Server Manager.m. This option will use a method akin to a shutdown abort (see the next section on database shutdown) in order to end the current instance having difficulty before starting the new instance. The second is that the database does not force users already logged onto the system to log . What is the tool used for starting the Oracle database? What connection must be used for the task? What are the five options for database startup? Shutting Down the Oracle Database Shutting down the Oracle instance works in much the same way as starting the instance. Sometimes (rarely) there is a situation where the Oracle database cannot start the instance under normal circumstances or shut down properly due to some issue with memory management or disk resource management. 2. User X will experience no interruption in database availability as a result of shutdown normal. The first is that no new users will be permitted access to the system.m. In other words. The first and lowest priority is normal. with the requirement to cease allowing access to the database and the requirement to accomplish the task while being logged on as internal. there will be no need to perform a database recovery. 3.the use of this option will be more carefully considered in the next unit. DBA issues shutdown normal from Server Manager at 3 p. 4. The following description of events illustrates specifically how the shutdown process works under normal priority: 1.m. The database will now shut down. The final option for database startup is used in unusual circumstances as well. Exercises 1. It is not recommended that the DBA use this option without extreme care. and receives the following message: ora-01090: shutdown in progress—connection is not permitted. The options for database shutdown are listed below: Shutdown normal Shutdown immediate Shutdown abort There are three priorities that can be specified by the DBA for shutting down the database. the database will make the DBA wait for all other users to finish what they are doing before the database will actually close. User Y attempts to log into the database at 3:05 p. There are three rules that can be abstracted from this situation. User X is logged onto the system at 2:30 and performs data entry until 3:15 p. User Z is the last user logged off at 3:35 p. the DBA may need to push things a bit. 2. It is the lowest priority because Oracle will wait for many other events to play themselves out before actually shutting down the connection. 5. the treatment of OCP Exam 3 on database backup and recovery.m. When the DBA starts the database up again. In these cases.

the database will shut down immediately. This option may be used in order to shut down an instance that is experiencing unusual problems. 2. which is still handled by Oracle. This activity should not require much effort from the DBA. Third. under normal shutdown situations. The final priority to be discussed with shutting down a database is the shutdown with abort priority. While Oracle attempts to shut down the dat abase. The database will most likely need instance recovery after an immediate shutdown. which requires the database to be unavailable to the users.off in order to complete the shutdown. The additional item that a shutdown abort uses to prevent the database from waiting for rollback to complete is not to roll back uncommitted transactions. the DBA may have to initiate emergency maintenance on the database. The first is the issue of recovery. Use of this priority when shutting down a database instance should be undertaken with care. What connection must be used for the task of database shutdown? What are the three options for database shutdown? Changing Database Availability and Restricting Login During the course of normal operation on the database. Perhaps there are some problems with the database . Some of the factors that the database shutdown will depend on are whether many users have active transactions executing at the time the shutdown command is issued. the rollback portion of the database shutdown may take some time to execute. However. particularly in situations involving user processes running large-volume transactions against a database. the DBA’s session will not allow the DBA to access any other options or issue any other commands until the shutdown process is complete. Otherwise. The time the process can take depends on several factors. A higher-priority shutdown that the DBA can enact in certain circumstances is the shutdown immediate command. Exercises 1. This approach requires more instance recovery activity. Oracle will not wait for a user to logoff as it did in points 2 and 4 above. the other issue associated with shutting down the database immediately is that the effect of the shutdown is not always immediate! In some cases. it is usually best to avoid using this option entirely. However. Instead. Oracle terminates the user connections to the database immediately and rolls back any uncommitted transactions that may have been taking place. In all cases that this priority is used. Normal database shutdown may take some time. Only in a situation where the behavior of the database is highly unusual or when the power to the database will cut off in less than two minutes should the shutdown abort option be employed. how many users are logged on to the system and on the shutdown priority issued by the DBA. it is recommended that the DBA shut things down with immediate priority when a power outage is looming. the DBA may require changing the availability of the database in some way. as Oracle will handle the recovery of the database instance itself without much intervention. or in the situation where the database could experience a power outage in the near future. there is no need for instance recovery. with no exceptions. This is the highest priority that can be assigned a shutdown activity. There are two issues associated with shutting down the database with immediate priority. A power outage can be particularly detrimental to the database. therefore. and use shutdown immediate in circumstances requiring the DBA to close the database quickly. Shutting down a database with immediate priority is similar to using the normal priority in that no new users will be able to connect to the database once the shutdown command is issued. For example.

The method used to close access to the database to all users except those with the restricted session privilege is alter database enable restricted session. To change the status of a database to be mounted. In some cases. Creating an Oracle Database In this section. the DBA can enable the database’s restricted session mode. the DBA may want to consider a temporary grant of restricted session to the developer. This option is called the restricted session. After database work. Alternately. 2. the DBA can issue the alter database open statement from the SQL command prompt and open the database for user access. This step can be accomplished in two ways. Although any user on the database can have this privilege granted to them. can access the database. One fact that is important to remember about the Oracle database is that it can be accessed by multiple instances. After the activities that required the database not to be mounted are complete. the DBA can alter the availability of the database in several ways. and other activities that require the database to be open but access to the data to be limited. or the CONNECT role. the DBA will want to mount the database to the instance. tablespace reorganization. the DBA will want to allow the users access to the database. the DBA may grant the restricted session privilege to a developer who is assisting in the database maintenance work. but have the database still be closed and therefore unavailable to the users. What statement is used to change the status of a database? Explain the use of the restricted session privilege. and needs to make some changes to the database. The final option to be covered corresponds to situations where the DBA has the database open for use. Like mounting the database manually. as discussed earlier in the section on starting the database. In these situations. then a database user with the create session privilege. the DBA can use the graphical user interface to open the database for user access. For this and many other reasons. or in the course of a manual startup. Some of these changes may include re-creating indexes. mainly.that need to be resolved while the instance is still running but the database is unavailable. In some situations. In cases where the DBA wants to limit access to the database without actually closing it. This method is generally preferable to a permanent grant of restricted session to someone outside the DBA organization. The first way a DBA may want to alter the status and availability of the database instance is to change the mount status of a database. typically only the database administrator will have it. large-volume data loads. such as in the case of reorganizing large tables that involves a largevolume data load. The following discussion will highlight some of those ways. When the database is in open mode. In order to restore access to the database to all users without the restricted session privilege is to issue the following command: alter database enable restricted session. Mounting the database allows the DBA to do several database maintenance activities without allowing users the chance to access the database and cause contention. the DBA can use either the graphical interface of Server Manager to mount the database or use the alter database mount statement to achieve that effect. the DBA may need to start a database with the nomount option. This option prevents logging into the database for any user that does not have the restricted session privilege granted to the user. This option is handled in one way. you will cover the following topics related to creating an Oracle database: . followed by a revocation of the privilege afterward to prevent possible data integrity issues in later maintenance cycles. Exercises 1.

such as datafiles and redo log files. and pays check. Now. Creating a database involves three activities that will be discussed in this section. and customer accounts receivable invoices. Most of the time. The first activity for creating a database is mapping a logical entity-relationship diagram that details a model for a process to the data model upon which the creation of database objects like indexes and tables will be based. Figure 6-4 shows the logical data model of the employee table and the invoice table. The employee fills out the expense sheets for the expenses incurred on behalf of the company. such as the tracking of inventory.Entity relationships and database objects Creating a database in Oracle Creating the Oracle data dictionary Once the DBA has set up some necessary preliminary items for running the Oracle instance. receipts. employee expense vouchers. such as password authentication. . The relationships. Some actions that take place in this employee expenditure system may be submits expense sheet. the entities (or nouns) in the model may include employees. which creates a check for the employee and mails the payment to the employee. a payment creator such as accounts payable. but it accurately models the business process within an organization to reimburse an employee for his expenses. the employees send their vouchers to the accounts payable organization. One fundamental tenet of database design is remembering that every database application is a model of reality. These entities and relationships can translate into several different types of visual representations or models of a business reality. then take the entity-relationship diagram and create a logical data model out of those entities and processes. Then. The process is very simple. Figure 6-3 illustrates each entity by a small illustration. on the other hand. map loosely to the idea of a verb. expense sheets. explore the combination of those entities and their relationships. A discussion of each element in the database creation process will be discussed now in detail. The model for a database should be a model for the process that the database application will represent. the DBA can then create the database that users will soon utilize for data management. and a payer account for the company that is reimbursing the employee. The final (and perhaps the most important) aspect of creating a database is creating the structures that comprise the Oracle data dictionary. The second activity that the DBA will perform as part of creating a database is the creation of physical data storage resources in the Oracle architecture. or action that takes place between two nouns. payments. with the relationships between each entity represented by an arrow and a description. deducts money from account. When the developers of a database application create the employee expenditure system modeled by the entity-relationship diagram above. In the employee expenditure system mentioned above. Entity Relationships and Database Objects The first part of creating a database is creating a model for that database. A logical data model is a more detailed diagram than the entity-relationship diagram in that it fills in details about the process flow that the entity-relationship diagram attempts to model. they will first take those entities and map out the relationship. the database is used to model some sort of business reality. The concept of an entity maps loosely to the nouns in the reality the database application is trying to model. submits receipts. payment of sales bonuses.

the relationship of one table to another through foreign keys should correspond somewhat to the relationship that occurs between two entities in the process flow being modeled. This pair of facts is referred to as the ordinality of the database tables. while the records of the EXPENSE table have a one-to-one relationship with records of the EMPLOYEE table. That piece of information identifies a pair of facts about the relationship. There is an interesting piece of information communicated above and below the line on the opposite side of each table as well. This estimate of row count should be something that is forecasted over a period of time. Some of these questions relate to Oracle-specific features. the employee will fill in various pieces of information. so that the DBA is not constantly trying to allocate more space to an application that continually runs out of it. This forecast of sizing for the database will allow the DBA some "breathing room" when the database application is deployed. there may or may not be expense sheets in the EXPENSES table. the relationship between employee and expense sheet is optional for employees but mandatory for expense sheets. the empid is the tie that binds an expense sheet to the employee who created it. In the example above. This means that for any given record in the EMPLOYEE table. or none at all. however. The first element of the pair identifies whether the relationship is mandatory from the perspective of the table appearing next to the pair. and the expense amount. Therefore. In the example in the diagram above. in the logical data model. while a zero (0) indicates that the relationship is optional. In terms of the entity-relationship diagram. The second component of that pair indicates whether there is a one-to-one. Some objects that the . the designer of the database should know row count estimates for each object to be created in Oracle. The database designer may ask several questions related to the physical design of that system as follows: How many employees will be allowed to use the system? What sort of company chargeback system will be used to take the employee expense payment from the budget of the department for which the expense was incurred on behalf of the employee? How many expense sheets will be submitted per month and per year? The proper creation of a database in Oracle depends on answering these and many other questions regarding the physical relationship between the machine hosting Oracle and the data Oracle stores as part of the application model. the employee ID number. A one indicates that the relationship is mandatory for the pair. each employee may have submitted one or more expense sheets. the EMPID column in EXPENSE corresponds to the primary key column of the EMPLOYEE table. or many-to-many correspondence between records of one table and records of another table. while each expense sheet corresponds to one and only one employee. say two years. including the expense ID number. In the case of the table structure in Figure 6-5. For example. That is to say.On the expense sheet. records in the EMPLOYEE table have a one-to-many relationship with the records of the EXPENSE table. the entities are called tables and the relationships are called foreign keys. However. Creating a physical database out of the logical data model requires considering several issues. every expense sheet record in the EXPENSES table will correspond to an employee record. The line between the two entities is similar to a relationship. one-to-many. The relationship between columns to tables corresponds loosely to the activity or relationship that exists between the two entities that the tables represent.

Spanish. One final. These physical structures are called the redo log files. and languages read from right to left.designer will need to produce sizing estimates for are the tables and indexes. for example. or Italian. scoring a positive response from the users while also minimizing the impact of application activity on the Oracle instance. as many users will not know. . Backup and recovery are handled as a whole topic unto themselves in the OCP DBA Exam series. In addition." There are three main steps in creating databases in the Oracle environment. The reason for the difficulty is knowing what the users will want with respect to data access. These languages fall into distinct categories with respect to the mechanisms on a computer that will store and display the characters that comprise those languages. See Unit III covering OCP Exam 3. In a point related to indexes. "Database Backup and Recovery. to find out information about the tables or indexes. The first is creating the physical locations for data in tables and indexes to be stored in the database. What is an entity-relationship diagram? Explain both concepts of entities and relationships. try to avoid providing users with free rein to access data via ad hoc queries. The final step in creating an Oracle database is to create the logical structures of the data dictionary. The data dictionary comprises an integral portion of the database system. that searching a table on an indexed column is far preferable to searching on a nonindexed column. These physical locations are called datafiles. Japanese. the designer of the application should know what the users of the database will need regarding data access. Examples of single-byte character sets are any of the Romance or Teutonic languages originating in Western Europe. Both the users and Oracle refer to the data dictionary in order to find information stored in tables or indexes. and also in this book. Southeast Asia. Dutch. The second step is to create the files that will store the redo entries that Oracle records whenever any process makes a data change to the Oracle database. and the redo log files. or to find out information about the underlying physical structure of the database. Examples of the multibyte character sets available are the languages that originated in Eastern Asia. where possible. specifying the database’s character set is critical to the proper functioning of the database. German. or redo log members. multibyte character sets. French. such as English. The developers of the application should. and Korean. and the tablespaces that will contain those tables and indexes. Exercises 1. the datafiles. and perhaps the most important. area of all to consider at the onset of database system creation in the Oracle environment is how the user will preserve the data in the system from any type of failure inherent in the usage of computer machinery. This feature of database design is perhaps the hardest to nail down after the initial estimate of transaction activity for the database application. Examples of a language read right to left include Hebrew and Arabic. for performance reasons. There are several different options for specifying character sets in the Oracle database. Such methods may include full and partial backups for the database and the archiving (or storing) of redo logs created by Oracle to track changes made in the database. just as there are many different languages available for use by different peoples of the world. The distinct categories are single-byte character sets. These languages include Mandarin. or the Pacific Rim. Providing the "canned" query access via graphical user interfaces or batch reporting allows the designers to tune the underlying queries that drive the screens or reports.

Step 1 in the process is to back up the database. 6. 2.ORA file. Verify the instance name. a database instance will have more than one parameter file used exclusively for starting it. The worst thing a DBA can face when creating a new database is when a datafile or log filename in a parameter file may not have been changed before creating the second database. This file is generally referred to as the init. More details will be given shortly about the required parameters that must be unique for database creation. which causes the first database to be unusable. A parameter file is as unique as the database that uses it. This situation leaves the first database vulnerable to being overwritten when the second database is created.ora or parameter file. 3. Always remember to back up any existing database that uses the same instance and host machine. optional relationships? What is a foreign key? Is a foreign key part of the entity-relationship diagram or the logical data model? To what item in the other model does the foreign key relate to? Creating a Database in Oracle Creation of the Oracle database is accomplished with the create database statement. Generally. Start the appropriate database management tool. 5. Sometimes accidents do happen in database creation. Create or edit the init. to handle various situations that the DBA may want to configure the instance to handle. The first thing to remember about database creation is the Oracle recommended methodology for actually creating the database. The list describes each parameter in some detail and offers some potential values if appropriate. 4. What is a logical data model? How does the logical data model correspond to the entity-relationship diagram? What structures in a data model relate loosely to the entities and the relationships of an entityrelationship diagram? What is ordinality? Explain the concept of mandatory vs. one parameter file that is specifically configured to handle an increase in processing associated with heavy transaction periods at the end of the year. Each database instance usually has at least one parameter file that corresponds to it and it only. Start the instance. Back up existing databases. The following list highlights key initialization parameters that have to be changed in order to correspond to a unique database.2. the DBA will take this generic parameter file and alter certain parameters according to his or her needs. There are several parameters that must be changed as part of setting up and running a new Oracle database. Steps 1 and 2 are critical in preserving the integrity of any existing databases that may already exist on the Oracle instance. For example. Oracle provides a generic copy of that parameter file INIT. A critical resource used to start any instance is the file that contains any initialization parameter that the DBA cares to set for the Oracle database and instance being used.ORA in the software distribution used to install Oracle server on the machine hosting Oracle. a DBA may have one parameter file for general use on starting the Oracle instance when users will access the system. and another parameter file designed to start the instance in proper configuration for DBA maintenance weekends. The steps are as follows: 1. 4. . Create and back up the new database. which can happen if the DBA attempts database creation without changing the DB_NAME parameter in the INIT. 3. Usually. This step prevents headaches later if there is a problem with database creation damaging an existing database.ora parameter file.

Oracle will overwrite the contents o that file with the physical layout of the database being created. PROCESSES The number of processes that can connect to Oracle at any given time. This param cannot be changed for the life of the database.DB_NAME The local name of the database on the machine hosting Oracle. This value includes background processes (of which there are at least five) and user processes. he/she can name them here. permanent damage may result in the event a database is created. Data blocks are unit components datafiles into which Oracle places the row data from indexes and tables. If there are particular segments the DBA wants Oracle to acquire. DB_BLOCK_SIZE The size in bytes of data blocks within the system. If the name specified for this parame do not match filenames that exist currently. The control files docum the physical layout of the database for Oracle. DB_BLOCK_BUFFERS The maximum number of data blocks that will be stored in the database buffer cach the Oracle SGA. then Oracle will create a new control fil for the database at startup. If this is not changed. If the file does exist. It is the seco component of a database’s unique name within the network. ROLLBACK_SEGMENTS A list of named rollback segments that the Oracle instance will have to acquire at database startup. CONTROL_FILES A name or list of names for the control files of the database. and one componen a database’s unique name within the network. DB_DOMAIN Identifies the domain location of the database name within a network. .

the user must have the osdba or sysdba granted to them and enabled. ‘redo2c. Oracle w issue warnings to users as they connect if the number of users connecting has excee LICENCE_MAX_WARNING. The following code block contains a create database statement: CREATE DATABASE orgdb01 CONTROLFILE REUSE LOGFILE GROUP 1 (‘redo1a. the DBA can create the database with the create database command In order to create a database. After starting the instance without mounting a database.dat’ SIZE 30M AUTOEXTEND 10M MAXSIZE 100M. ‘temp01.dat’ SIZE 30M AUTOEXTEND 10M MAXSIZE 100M. ‘users01. This number determines the number of sessions tha users can establish with the Oracle database at any given time. the DBA will need to start the database instance while connected to the database as sysdba and while running Server Manager. ‘redo2b. GROUP 2 (‘redo2a.log’) SIZE 1M. ‘redo1c.log’. . Set to less than LICENSE_MAX_SESSIONS.dat’ SIZE 30M. ‘index01. LICENSE_MAX_USERS Used for license management. To start the instance. The task of connecting to the database as sysdba has already been discussed.log’) SIZE 1M MAXLOGFILES 2 DATAFILE ‘data01. Following the creation of the appropriate initialization parameter file.LICENSE_MAX_SESSIONS Used for license management.dat’ SIZE 10M MAXDATAFILES 20 ARCHIVELOG.dat’ SIZE 20M. use the startup nomount command in order to run the instance without mounting a previously existing database. As an alternative to licensing by concurrent sessions DBA can limit the number of usernames created on the database by setting a nume value for this parameter. ‘rbs01.log’. ‘redo1b.log’. LICENSE_MAX_WARNING Used for license management.log’.

As its name implies. Of the disk resources created. In the interests of preserving the integrity of the Oracle database. Adding more datafiles and redo logs increases the size of a control file. Both have many powerful privileges and should be used carefully for administrative tasks on the database. the database will not know about it. Redo logs are entries for changes made to the database. An existing database will need recovery if its control file is overwritten by the creation of another database.A new database is created by Oracle with several important features. This feature should be enabled in all but read only databases. The controlfile reuse clause is included in the create database statement to allow Oracle to reuse the file specified if it already exists. The first item to remember about database creation is that the database will be created with two special users. If information about a datafile or redo log file is not contained in the control file for the database. One of these resources is the SYSTEM tablespace. In general. This syntax is purely optional. Not only are physical database resources and database administrative passwords created as part of the create database command. This size of the control file is related to the number of datafiles and redo log files that are used on the Oracle database. Some of those objects are the Oracle data dictionary and rollback segments. the maxdatafiles parameter indicates the maximum number of datafiles a database can have. The names of the two users created by Oracle are SYS and SYSTEM. If the create database statement specifies a datafile or a redo log file that currently exists on the system and the reuse keyword is used. up to a total size specified by the maxsize keyword. This parameter can be a potential limitation later when the database grows to a point where it cannot accommodate another datafile because the maxdatafiles parameter would be exceeded. When autoextend is used. Redo logs are created with the logfile clause. Oracle will overwrite them. the DBA should remember that when the users SYS and SYSTEM are created. but some important logical disk resources are created as well. and the password for SYSTEM is MANAGER. and furthermore. and they are where Oracle physically stores the data in any and all tablespaces. The datafiles are specified with the datafile clause. As covered. the control file identifies all other disk resources to the Oracle database. which are designed to allow for performing important activities required throughout the life of a database. the datafiles will automatically allocate more space when the datafile fills. the one most central to database operation is the control file. A workaround for this problem is to use the autoextend option when defining datafiles. the DBA should ensure that only the data dictionary and system . Control files are generally not very large. When archivelog is used. fewer datafiles that grow larger with the autoextend option and fewer redo logs decrease the size of control files. Another pair of options set at database creation time are called maxdatafiles and maxlogfiles. then Oracle will overwrite that file with the data for the new redo log member or datafile for the database being created. Many important database objects are stored in the SYSTEM tablespace. This parameter is a keyword specified in the create database statement. the password for SYS is CHANGE_ON_INSTALL. Oracle archives the redo logs generated. perhaps 250K for even a large database. For now. and the DBA will not be able to recover it if the disk containing it is lost. and it must be followed by an integer. care should be taken when reusing files in order to prevent "accidental reuse" in a situation where a database already exists on the machine and the DBA creates another one that overwrites key files on the first database. There must be one rollback segment in the SYSTEM tablespace for Oracle to acquire at database startup. The final and most important option included in the create database statement is the archivelog option. if is not used and the create database statement includes files that already exist. Other items created as part of the create database command are the datafiles and the redo log files. The SYSTEM tablespace certainly is a tablespace in the Oracle system that is HIGHLY important to the operation of the Oracle database. Sometimes the SYSTEM tablespace is compared to the root directory of a machine’s file system. or else the database won’t start. BEWARE OF REUSING CONTROL FILES.

sql.sql. the character set specified for the database should not be changed at any point after the database is created.SQL script. along with special public synonyms for those views.sql Creates views that are used for the SQL*Loader tool. Some areas that the DBA may want to address right away are placement of redo logs and datafiles and the separation of tables from their corresponding indexes. which tracks all audit trail information generated by Oracle when the auditing feature of the database is used. Finally. Generally. Every object in the database is tracked in some fashion by the Oracle data dictionary. discussed in the unit covering OCP Exam 3. the DBA should consider some preliminary work on distributing the I/O load in order to simplify the maintainability of the database in the future. This script calls several other scripts in the process of creating several different data dictionary components used in everything procedural related to the Oracle database. Also. it is recommended to place the rest of the rollback segments available to the database in a special tablespace designed only to hold rollback segments. discussed later in this unit.rollback segments are placed in the SYSTEM tablespace. the create database command specifies the character set used throughout the database.sql Creates the SYS. the database that was just created is mounted and opened directly by Oracle for the DBA to begin placing data objects into it. After database creation.AUD$ dictionary table. 2. catexp. What resources are created as part of the creation of a database? What is the SYSTEM tablespace? What is its significance? What is a parameter file? What are some of the parameters a DBA must set uniquely for any database via the parameter file? Creating the Oracle Data Dictionary The data dictionary is the first database object created at the time a create database command is issued. Within the catalog. In particular. The code that actually creates the objects is in several scripts called by this master . The code for creating these dictionary views is not contained in catproc. The first script.sql script there are calls to several other scripts. catalog. Once the database is created. Name some of the steps in creating a new Oracle database. "Database Backup and Recovery. no data objects such as tables or indexes should be placed in the SYSTEM tablespace. indexes. the DBA will find the further allocation of rollback segments in addition to the rollback segment in the SYSTEM tablespace to be an important initial consideration on creating the database." The other script generally run by the Oracle database when the data dictionary is created is the CATPROC.sql Creates views that are used by the IMPORT/EXPORT utilities. Oracle generally creates the data dictionary without any intervention from the DBA at database creation time with the use of catalog.sql and catproc.sql. Exercises 1. 3. and rollback segments. Like DB_BLOCK_SIZE. which is used to process large-volume data loads from one system to another. such as tables. catldr. runs a series of other scripts in order to create all the data dictionary views. which are listed below: cataudit.

script. DBWR moves data blocks out of the buffer cache. archiver (ARCH). making large continuous free disk space out of smaller empty fragments. and extents. 2. the appropriate cleanup activity and rollback occurs. and pipes. SMON handles instance recovery at startup in the event of a failure. How is the data dictionary created? What two scripts are used as part of database creation? Chapter Summary This chapter covered introductory material related to Oracle database administration. ARCH handles the automatic archiving of online redo log files. or shared between many processes in the MTS architecture. Before starting the instance. process monitor (PMON). The options available are operating system authentication and Oracle authentication. memory structures. system monitor (SMON). control files. RECO and LCKn handle transaction processing on distributed database configurations. LGWR writes redo log entries out of the redo log buffer and into the online redo log. They can either be dedicated to one user process.sql are stored procedures. snapshots. or handle activities in the background on Oracle’s behalf. recoverer (RECO). and the redo log buffer. and parameter files. redo log files. log writer (LGWR). These disk resources are divided into two categories: physical resources and logical resources. packages. and server (Snnn). The logical resources are tablespaces. and periodically sifts through tablespaces. and also of the methods in which they act together to allow users to access information. These different processes have functions that are related to activities that happen regularly in Oracle against the memory structures. The SGA. the DBA must figure out what sort of database authentication to use both for users and administrators. and certain utilities for PL/SQL constructs like alerts. consists of a minimum of three components: the data block buffer cache. and the tasks required for creating an Oracle database. Several memory structures exist on the Oracle database to improve performance on various areas of the database. the shared pool. locks. mail. Exercises 1. disk resources. Tying memory structures and disk resources together are several memory processes that move data between disk and memory. The factors that weigh on that choice are whether the DBA wants to use remote administration via network or local administration directly on the . Some of the objects created by the scripts called by catproc. The core background processes available on the Oracle instance include data block writer (DBWR). The material in this chapter comprises about 22 percent of questions asked on OCP Exam 2. PMON ensures that if a user process fails. password files. The topics covered in this chapter included an overview of the Oracle architecture. The memory structures of an Oracle instance include the System Global Area (SGA) and the Program Global Area (PGA). Figure 6-1 gives a clear idea of the background processes. The next area covered by the chapter was on how to start the Oracle instance. CKPT handles writing new redo log number information to datafiles and control files in the database at periodic intervals during the time the database is open. or both. triggers. the process of starting and stopping access to a database and to an Oracle instance. The first area of discussion in this chapter was an overview of the various components of the Oracle database. Server processes read data into the buffer cache on behalf of user processes. checkpoint (CKPT). dispatcher (Dnnn). and disk resources that comprise the Oracle instance. segments. Dnnn are dispatchers used to route user processes to a shared server in MTS configurations. lock (LCKn). in turn. Corresponding to several of these memory areas are certain disk resources. The physical disk resources on the Oracle database are datafiles.

the DBA can then begin the work of creating the database. in order to prevent data loss or accidental deletion of a disk file resource. the SYS and SYSTEM users. then the DBA must create a password file using the ORAPWD utility. The recover option starts the instance. Several initialization parameters were identified as needing to be set to create a database.machine running Oracle. The DBA must again connect to the database as internal using the Server Manager tool. DB_DOMAIN. To have database administrator privileges on the database. control files. The mount option starts the instance and mounts but does not open the database. immediate. the database refuses new connections to the database by users and waits for existing connections to terminate. and the Oracle data dictionary for that database. the DBA can execute the create database command. the designer of the application must then give a row count forecast for the application’s tables. restrict. After creating the database. and opens it for general user access. PROCESSES. ROLLBACK_SEGMENTS. Several options exist for shutting down the database as well. They are called sysdba and sysoper in environments where Oracle authentication is used. and this password is the same as the one used for authentication as user SYS and when connecting as internal. which creates all physical disk resources for the Oracle database. The open option starts the instance. then the shutdown normal will complete. The three options for shutting down the Oracle database are normal. the SYSTEM tablespace. This row count forecast allows the DBA to size the amount of space in bytes that each table and index needs in order to store data in the database. The physical resources are datafiles. and abort. a DBA must be granted certain privileges. The command to start the instance from Server Manager is called startup. LICENSE_MAX_SESSIONS. recover. mounts the database. LICENSE_MAX_WARNING. After developing a model of the process to be turned into a database application. The restrict option starts the instance. There are several different options for starting the instance. mount. The DBA issuing a shutdown immediate causes Oracle to prevent new connections while also terminating current ones. rolling back whatever transactions were taking place in the sessions just terminated. and force. DB_BLOCK_SIZE. LICENSE_MAX_USERS. open. . the DBA should back up existing databases associated with the instance. mounts the database. if any. and osdba or osoper where operating system authentication is used. They are DB_NAME. After the parameter file is created. The next thing that should happen is the DBA should create a parameter file that is unique to the database being created. The password file itself is protected by a password. The nomount option starts the instance without mounting a corresponding database. They are nomount. one rollback segment in the SYSTEM tablespace. The final area covered in this chapter was the creation of a database. The first area covered was the process modeling that takes place when the database designer creates the entity-relationship diagram. DB_BLOCK_BUFFERS. If the DBA chooses to use Oracle authentication. The steps of database creation were discussed. In order to start a database instance. it is recommended that the DBA back up the new database in order to avoid having to re-create the database from scratch in the event of a system failure. Once this sizing is complete. First. the DBA must run Server Manager and connect to the database as internal. but leaves the database closed and starts the database recovery procedures associated with disk failure. The final option for shutting down a database is shutdown abort. Once the last user has logged off the system. which disconnects current sessions without rolling back their transactions and prevents new connections to the database as well. When the DBA shuts down the database with the normal option. and redo log files. The force option gives the database startup procedure some extra pressure to assist in starting an instance that either has trouble opening or trouble closing normally. There are two alter database statements that can be used to change database accessibility once the instance is started as well. and opens it for users who have been granted a special access privilege called restricted access.

The SGA consists of: the buffer cache for storing recently accessed data blocks. and background processes that handle disk writes and other time-consuming tasks in the background. Physical disk resources are control files that store the physical layout of database. the data dictionary. rollback segments. indexes. the redo log buffer for storing redo entries until they can be written to disk. Logical disk resources are tablespaces for storing tables. and certain packages for PL/SQL such as pipes and alerts. and the data dictionary. password files to store passwords for DBAs when Oracle authentication is used. parameter files. indexes.Of particular importance in the database creation process is the process by which the data dictionary is created. triggers.sql. This task can also be handled by LGWR. This script runs several other scripts that create everything required in the data dictionary to allow procedural blocks of code in the Oracle database. and defragments small free spaces in tablespaces into larger ones. disk resources that store Oracle data. CKPT writes redo log sequence numbers to datafiles and control files when enabled. functions. Two-Minute Drill Three major components of the Oracle architecture are memory structures that improve database performance. Disk resources in the Oracle architecture are divided into physical and logical categories. and shared pool for storing parsed information about recently executed SQL for code sharing. PMON monitors user processes and cleans up the database transactions in the event that they fail. It also writes redo log sequence numbers to datafiles and control files at checkpoints (also handled by CKPT when enabled) and tells DBWR to write dirty buffers to disk. . procedures. SMON automatically handles instance recovery at startup when necessary. This creation process happens automatically by Oracle. The data dictionary must be created first in a database because all other database structure changes will be recorded in the data dictionary. DBWR writes data blocks back and forth between disk and the buffer cache. Several scripts are run in order to create the tables and views that comprise the data dictionary.sql. The storage of these logical disk resources is handled with segments and extents. Memory structures in the Oracle architecture are System Global Area (SGA) and Program Global Area (PGA). There are two "master" scripts that everything else seems to hang off of. The second is called catproc. which are conglomerations of data blocks. This script creates all the data dictionary tables that document the various objects on the database. redo log files that store redo entries on disk. namely packages. rollback segments. snapshots. The first is catalog. and datafiles that store tables. LGWR writes redo log entries between redo log buffer and online redo log on disk. The fundamental unit of storage in a datafile is the data block.

do not mount a database. There are at least six different options for starting a database: Startup nomount Start instance. the DBA must connect as internal or sysdba. shutdown abort—no new . Startup mount Start instance. any user with a username and password. Startup open Start instance. and enable (disable) restricted session. mount and open database. but existing sessions may take as long as they want to wrap up. Snnn (server process) reads data from disk on the database on behalf of the user process. Startup force Make an instance start that is having problems either starting or stopping. open. When a database is open. may connect to the database. Startup restrict Start instance. Startup recover Start instance. and their transactions rolled back. existing sessions are terminated. Dnnn receives user processes from SQL*Net listener in multithreaded server (MTS) environments. they are called sysdba and sysoper. mount and open database.ARCH handles archiving of online redo logs automatically when set up. Under OS authentication. mount but do not open the database. There are two roles DBAs require to perform their function on the database. and begin recovery for disk failure scenario. The tool used to start and stop the database is called Server Manager. Options available for alter database are mount. In Oracle authentication environments. Closing or shutting down a database must be done by the DBA while running Server Manager and while the DBA is connected to the database as internal or sysdba. the privileges are called osdba and osoper. To use Oracle authentication. There are three options for closing a database: shutdown normal—no new existing connections allowed. but restrict access to those users with restricted session privilege granted to them. the DBA must create a password file using the ORAPWD utility. RECO resolves in-doubt transactions on distributed database environments. The database availability can be changed at any time using the alter database command. LCKn obtains locks on remote databases. Two user authentication methods exist in Oracle: operating system authentication and Oracle authentication. shutdown immediate—no new connections allowed. To start and stop a database. with the create session privilege or the CONNECT role granted to them. leave database closed.

the DBA should create a parameter file with unique values for several parameters. The create database command also creates the Oracle data dictionary for that database. The default password for SYSTEM is MANAGER. On conclusion of the create database statement. LICENSE_MAX_USERS The maximum number of users that can be created in the Oracle instance. DB_BLOCK_BUFFERS The number of blocks stored in the buffer cache. The size of a datafile is fixed. After creating the parameter file. including the following: DB_NAME The local name for the database. LICENSE_MAX_SESSIONS The maximum number of sessions that can connect to the database. LICENSE_MAX_WARNING The sessions trying to connect above the number specified by this parameter will receive a warning message.connections allowed. The default password for SYS is CHANGE_ON_INSTALL. which creates all physical database structures in the database. the database is created and open. The first step in creation of a database is to model the process that will be performed by the database application. The number of datafiles and redo log files created for the life of the database can be limited with the maxdatafiles and maxlogfiles options of the create database statement. DB_BLOCK_SIZE The size of each block in the database. the DBA executes the create database command. unless the autoextend option is used. bot not both. The next step in creating a database is to back up any existing databases associated with the instance. DB_DOMAIN The network-wide location for the database. Instance recovery is required after shutdown abort is used. usually. ROLLBACK_SEGMENTS Named rollback segments that the database must acquire at startup. existing sessions are terminated. along with logical database structures like SYSTEM and an initial rollback segment. as well as the SYS and SYSTEM users. After that. This task is done first to capture the other database objects that are created in the database. PROCESSES The maximum number of processes available on the database. LICENSE_MAX_SESSIONS and LICENSE_MAX_WARNING are used for license tracking or LICENSE_MAX_USERS is used. . transactions are not rolled back.

The size of a control file is directly related to the number of datafiles and redo logs for the database. procedures. indexes. alerts. locks. etc. like PL/SQL packages. triggers. .sql Creates dictionary views for all procedural aspects of Oracle.sql Creates all data dictionary tables and views that track database objects like tables. and rollback segments. snapshots. At least two scripts are used create the database: catalog. and special utility PL/SQL packages such as those used to manage pipes. catproc. functions.

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.