You are on page 1of 27

run { allocate channel proddb1 type disk; allocate channel proddb2 type disk; allocate channel proddb3 type

disk; allocate auxiliary channel stddb3 type disk; duplicate target database for standby from active database spfile parameter_value_convert 'stddb3,proddb' set log_archive_config='DG_CONFIG=(stddb1,proddb,stddb2,stddb3)' set db_file_name_convert='/vol1/oradata/proddb','/vol1/oradata/stddb3','/vol1/or adata/stddb3','/vol1/oradata/stddb1','/vol1/oradata/stddb3','/vol1/oradata/stddb 2' set log_file_name_convert='/app/oracle/admin/proddb/flash_recovery_area/PRODDB/o nlinelog', '/app/oracle/admin/stddb3/flash_recovery_area/STDDB3/o nlinelog', '/app/oracle/admin/stddb3/flash_recovery_area/STDDB3/o nlinelog', '/app/oracle/admin/stddb1/flash_recovery_area/STDDB1/o nlinelog' '/app/oracle/admin/stddb3/flash_recovery_area/STDDB3/o nlinelog', '/app/oracle/admin/stddb2/flash_recovery_area/STDDB2/o nlinelog' set DISPATCHERS='(PROTOCOL=TCP)(SERVICE=stddb3XDB)' set control_files='/vol1/oradata/proddb/control01.ctl' set db_recovery_file_dest='/app/oracle/admin/stddb3/flash_recovery_area' set db_recovery_file_dest_size='10248M' nofilenamecheck; }

run { allocate channel proddb1 type disk; allocate channel proddb2 type disk; allocate channel proddb3 type disk; allocate auxiliary channel proddb type disk; duplicate target database for standby from active database spfile parameter_value_convert 'stddb1,proddb' set log_archive_config='DG_CONFIG=(stddb1,proddb,stddb2)' set db_file_name_convert='/vol1/oradata/stddb1','/vol1/oradata/proddb','/vol1/or adata/stddb1','/vol1/oradata/stddb2' set log_file_name_convert='/app/oracle/admin/stddb1/flash_recovery_area/STDDB1/o nlinelog', '/app/oracle/admin/proddb/flash_recovery_area/PRODDB/o nlinelog', '/app/oracle/admin/stddb1/flash_recovery_area/STDDB1/o nlinelog', '/app/oracle/admin/stddb2/flash_recovery_area/STDDB2/o nlinelog' set DISPATCHERS='(PROTOCOL=TCP)(SERVICE=proddbXDB)' set control_files='/vol1/oradata/proddb/control01.ctl' set db_recovery_file_dest='/app/oracle/admin/proddb/flash_recovery_area' set db_recovery_file_dest_size='10248M' nofilenamecheck; }

dgmgrl DGMGRL> connect sys/oracle@proddb DGMGRL> create configuration dg_project as primary database is proddb connect id entifier is proddb; DGMGRL> add database stddb1 as connect identifier is stddb1 maintained as physic al; DGMGRL> add database stddb2 as connect identifier is stddb2 maintained as physic al; DGMGRL> enable configuration; DGMGRL> show configuration; DGMGRL> enable database proddb; DGMGRL> enable database stddb1; DGMGRL> enable database stddb2; DGMGRL> edit database proddb set property FastStartFailoverTarget='stddb1'; DGMGRL> edit database stddb1 set property FastStartFailoverTarget='proddb'; DGMGRL> edit database stddb2 set property FastStartFailoverTarget='proddb'; DGMGRL> edit database proddb set property LogXptMode='SYNC'; DGMGRL> edit database stddb1 set property LogXptMode='SYNC'; DGMGRL> edit database stddb2 set property LogXptMode='SYNC'; DGMGRL> edit configuration SET PROTECTION MODE AS MaxAvailability; DGMGRL> enable fast_start failover; DGMGRL> start observer file='/backup/Proddb.log'; SQL> conn sys/oracle@proddb as sysdba SQL> select name, open_mode, database_role from v$database; SQL> create pfile='/app/oracle/admin/proddb/pfile/initproddb.ora' from spfile SQL> shu immediate; SQL> startup pfile='/app/oracle/admin/stdby/pfile/initstdby_new.ora' nomount; SQL> create spfile from pfile='/app/oracle/admin/stdby/pfile/initstdby_new.ora'; SQL> shu immediate; SQL> startup mount; SQL> alter database flashback on; SQL> archive log list; SQL> alter database recover managed standby database using current logfile disco nnect;

alter system set log_archive_config='DG_CONFIG=(proddb,stddb1,stddb2)' scope=spf ile alter system set db_file_name_convert='/vol1/oradata/proddb','/vol1/oradata/stdd b1','/vol1/oradata/proddb','/vol1/oradata/stddb2' scope=spfile; alter system set log_file_name_convert= '/app/oracle/admin/proddb/flash_recovery_area/PRODDB/onlinelog', '/app/oracle/ad min/stddb1/flash_recovery_area/STDDB1/onlinelog', '/app/oracle/admin/proddb/flash_recovery_area/PRODDB/onlinelog', '/app/oracle/ad min/stddb2/flash_recovery_area/STDDB2/onlinelog' scope=spfile alter system set log_archive_config='DG_CONFIG=(proddb,stddb1,stddb2)' scope=spf ile alter system set db_file_name_convert = '/vol1/oradata/proddb','/vol1/oradata/stddb1', '/vol1/oradata/stddb1','/vol1/oradata/stddb2' scope=spfile; alter system set log_file_name_convert=

'/app/oracle/ad min/stddb2/flash_recovery_area/STDDB2/onlinelog'. For example. enter: SQL> SELECT SUPPLEMENTAL_LOG_DATA_PK. PRIMARY_ROLE) DB_UNIQUE_NAME=stddb3' ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_4='ENABLE'. execute the following statements: SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY. Database altered. . UNIQUE INDEX) COLUMN S. alter system set log_file_name_convert= '/app/oracle/admin/proddb/flash_recovery_area/PRODDB/onlinelog'.stddb1. PRIMARY_ROLE) DB_UNIQUE_NAME=stddb2' ALTER SYSTEM SET LOG_ARCHIVE_DEST_4='SERVICE=stddb3 LGWR SYNC VALID_FOR=(ONLINE_ LOGFILES. '/app/oracle/admin/stddb2/flash_recovery_area/STDDB2/onlinelog'. '/app/oracle/ad min/stddb1/flash_recovery_area/STDDB1/onlinelog' scope=spfile alter system set log_archive_dest_2='SERVICE=stddb1 LGWR SYNC VALID_FOR=(ONLINE_ LOGFILES. '/app/oracle/ad min/stddb1/flash_recovery_area/STDDB1/onlinelog'. SUPPLEMENTAL_LOG_DATA_UI FROM V$DATABASE. That info.'/vol1/oradata/stddb1' scope=spfile. PRIMARY_ROLE) DB_UNIQUE_NAME=stddb1' alter system set log_archive_dest_3='SERVICE=stddb2 LGWR SYNC VALID_FOR=(ONLINE_ LOGFILES. On Primary Database ==================== Supplemental logging on the primary database generates additional information in the redo log. '/app/oracle/ad min/stddb2/flash_recovery_area/STDDB2/onlinelog' scope=spfile alter system set log_archive_config='DG_CONFIG=(proddb. '/app/oracle/admin/stddb1/flash_recovery_area/STDDB1/onlinelog'. start a SQL session and query th e V$DATABASE fixed view. Is then used during the redo application process in th e standby database to make sure the correct rows are affected by the generated S QL.--YES YES If supplemental logging is not enabled.'/app/oracle/admin/proddb/flash_recovery_area/PRODDB/onlinelog'. SUP SUP --. To see whether supplemental logging is enabled.stddb2)' scope=spf ile alter system set db_file_name_convert = '/vol1/oradata/proddb'. '/vol1/oradata/stddb2'.'/vol1/oradata/stddb2'.

20.0/db_1) (SID_NAME = stddb2) ) ) LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.2. ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_3='ENABLE'.0/db_1) (SID_NAME = stddb2) ) (SID_DESC = (GLOBAL_DBNAME = stddb2_DGMGRL) (ORACLE_HOME = /app/oracle/product/11.61)(PORT = 1521)) ) ADR_BASE_LISTENER = /app/oracle proddb = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=TCP)(HOST = 172.0/db_1) (SID_NAME = stddb1) ) (SID_DESC = (GLOBAL_DBNAME = stddb1_DGMGRL) (ORACLE_HOME = /app/oracle/product/11.2.251.2.61)(PORT=1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = proddb_DGMGRL) ) ) stddb1 = .20.2.0/db_1) (SID_NAME = stddb1) ) (SID_DESC = (GLOBAL_DBNAME = stddb2) (ORACLE_HOME = /app/oracle/product/11.0/db_1) (SID_NAME = proddb) ) (SID_DESC = (GLOBAL_DBNAME =proddb_DGMGRL) (ORACLE_HOME = /app/oracle/product/11.standby_role) db_unique_name=standby' scope=spfile.================================================ alter system set log_archive_dest_3='location=/app/oracle/admin/stddb3/archive v alid_for=(standby_logfiles. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = proddb) (ORACLE_HOME = /app/oracle/product/11.2.0/db_1) (SID_NAME = proddb) ) (SID_DESC = (GLOBAL_DBNAME = stddb1) (ORACLE_HOME = /app/oracle/product/11.251.2.

(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=TCP)(HOST = 172.20.251.117)(PORT=1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = stddb1_DGMGRL) ) ) stddb2 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=TCP)(HOST = 172.0/db_1) (SID_NAME = testdb) ) (SID_DESC = (GLOBAL_DBNAME = stdby_DGMGRL) (ORACLE_HOME = /app/oracle/product/11.0/db_1) (SID_NAME = stdby) ) ) LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.129)(PORT=1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = stddb2_DGMGRL) ) ) orapwd file=orapwproddb password=oracle entries=5 force=y ignorecase=y orapwd file=orapwstddb1 password=oracle entries=5 force=y ignorecase=y # listener.0/db_1) (SID_NAME = stdby) ) (SID_DESC = (GLOBAL_DBNAME =testdb_DGMGRL) (ORACLE_HOME = /app/oracle/product/11.1.0/db_1) (SID_NAME = testdb) ) (SID_DESC = (GLOBAL_DBNAME = stdby) (ORACLE_HOME = /app/oracle/product/11.1.20.1.ora ================================================================ SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = testdb) (ORACLE_HOME = /app/oracle/product/11.251.localdomain)(PORT = 1521)) ) .1.

1.dat' .arc' standby_file_management=auto fal_client=testdb fal_server=stdby db_file_name_convert='/vol1/oradata/testdb'.stdby)' log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES. PRIMARY_ROLE) DB_UNIQUE_NAME=stdby' log_archive_dest_state_1='ENABLE' log_archive_dest_state_2='ENABLE' log_archive_format='%s_%t_%r.ora' compatible='11.ora testdb = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=TCP)(HOST = localhost.'/app/oracle/admin/stdby/flash_recovery_area/STDBY/onlinelog' dg_broker_config_file1='/app/oracle/admin/testdb/dgbroker1/dg1.ora ======================================> db_name='testdb' db_unique_name='testdb' db_block_size=8192 sga_max_size=2048M sga_target=1536M db_recovery_file_dest='/app/oracle/admin/testdb/flash_recovery_area' db_recovery_file_dest_size=10G diagnostic_dest='/app/oracle' dispatchers='(PROTOCOL=TCP)(SERVICE=testdbXDB)' remote_login_passwordfile='EXCLUSIVE' undo_tablespace=undotbs1 undo_management=auto control_files='/vol1/oradata/testdb/control01.localdomain)(PORT=1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = stdby_DGMGRL) ) ) inittestdb. ALL_ROLES) DB_UNIQUE_NAME=testdb' log_archive_dest_2='SERVICE=stdby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES.localdomain)(PORT=1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = testdb_DGMGRL) ) ) failure of backup command on c3 channel at stdby = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=TCP)(HOST = localhost.'/vol1/oradata/stdby' log_file_name_convert='/app/oracle/admin/testdb/flash_recovery_area/TESTDB/onlin elog'.0' log_archive_config='DG_CONFIG=(testdb.ADR_BASE_LISTENER = /app/oracle tnsnames.

dat' db_flashback_retention_target=1440 dg_broker_start=TRUE [oracle@localhost ~]$ sqlplus /nolog SQL> conn sys/systestdb@testdb as sysdba SQL> startup pfile='/app/oracle/admin/testdb/pfile/inittestdb.dbf' size 50M reuse autoextend on maxsize unlimited logfile group 1 size 10M.dbf' size 400M reuse autoextend on next 10240K maxsize unlimited sysaux datafile '/vol1/oradata/testdb/sysaux01.dbf' size 300M reuse autoextend o n next 5M maxsize 2048M default tablespace users datafile '/vol1/oradata/testdb/users01.ora' nomount. SQL> archive log list.dg_broker_config_file2='/app/oracle/admin/testdb/dgbroker2/dg2. SQL> alter database add standby logfile group 4 size 10M. SQL> create tablespace tbsrman datafile '/vol1/oradata/proddb/tbsrman01. SQL> grant connect.dbf' siz e 50M autoextend on next 1M maxsize unlimited extent management local segment sp ace management auto. SQL> startup nomount. SQL> alter database open.dbf' size 20M re use autoextend on maxsize unlimited default temporary tablespace temp tempfile '/vol1/oradata/testdb/temp01. SQL> alter database flashback on.sql SQL> @?/rdbms/admin/catproc. SQL> startup mount. SQL> alter database add standby logfile group 5 size 10M. SQL> alter database add standby logfile group 7 size 10M.sql SQL> conn system/oracle@proddb SQL> @?/sqlplus/admin/pupbld. recovery_catalog_owner to rman. ******************************************************************************** ********************create database testdb user sys identified by systestdb user system identified by systestdb controlfile reuse force logging archivelog datafile '/vol1/oradata/testdb/system01. SQL> alter database add standby logfile group 6 size 10M. SQL> shu immediate. SQL> alter database enable block change tracking using file '/app/oracle/admin/p roddb/flash_recovery_area/block_change_tracking. SQL> create user rman identified by rman default tablespace tbsrman. . SQL> create spfile from pfile='/app/oracle/admin/testdb/pfile/inittestdb. SQL> @/app/oracle/admin/testdb/create_db.dbf' siz e 20M reuse autoextend on maxsize unlimited undo tablespace undotbs1 datafile '/vol1/oradata/testdb/undotbs01. ******************************************************************************** ********************SQL> @?/rdbms/admin/catalog.sql SQL> conn sys/oracle@proddb as sysdba SQL> shu immediate.log'. group 3 size 10M extent management local maxlogfiles 32 maxlogmembers 4 maxdatafiles 20show parameter log_archive_dest maxinstances 1. group 2 size 10M.sql. resource.ora'.

sql 'alter system archive log current'.0/db_1 [oracle@localhost ~]$ sqlplus /nolog initstdby. } ******************************************************************************** * Production database : proddb Calalog database : oeldb Standby database : stdby connect target sys/oracle@proddb connect catalog rman/rman@oeldb .ctl' set db_recovery_file_dest='/app/oracle/admin/stdby/flash_recovery_area' set db_recovery_file_dest_size='10248M' nofilenamecheck.stdby)' set db_file_name_convert='/vol1/oradata/testdb'.'/vol1/oradata/stdby' set log_file_name_convert='/app/oracle/admin/testdb/flash_recovery_area/TESTDB/o nlinelog'. allocate channel c2 type disk.ora ======================================> db_name='testdb' SQL> conn sys/systestdb@stdby as sysdba SQL> startup pfile='/app/oracle/admin/stdby/pfile/initstdby. RMAN> register database. allocate channel testdb2 type disk. SQL> host rman RMAN> c sys/systestdb@testdb RMAN> connect auxiliary sys/systestdb@stdby RMAN> run { allocate channel testdb1 type disk. backup full tag weekly_backup database format '%U'.} [oracle@localhost ~]$ export ORACLE_SID=stdby [oracle@localhost ~]$ export ORACLE_HOME=/app/oracle/product/11. } RMAN> run {execute script fullbackup . RMAN> configure backup optimization on.ora' nomount.show parameter log_archive_dest RMAN> create script fullbackup { allocate channel c1 type disk.SQL> host rman RMAN> connect target sys/oracle@proddb RMAN> connect catalog rman/rman@proddb RMAN> create catalog tablespace 'TBSRMAN'. duplicate target database for standby from active database spfile parameter_value_convert 'stdby'.'testdb' set log_archive_config='DG_CONFIG=(testdb. RMAN> resync catalog. backup archivelog all delete input. RMAN> configure controlfile autobackup on.1. allocate channel testdb3 type disk. allocate auxiliary channel stdby1 type disk. allocate channel c3 type disk.'/app/oracle/admin/stdby/flash_recovery_area/STDBY/onlinelog' set db_unique_name='stdby' set control_files='/vol1/oradata/stdby/control01.

ctl' db_block_size=8192 db_file_name_convert='/vol1/oradata/testdb'.arc' log_file_name_convert='/app/oracle/admin/testdb/flash_recovery_area/TESTDB/onlin elog'.stdby)' set db_file_name_convert='/vol1/oradata/proddb'. SQL> create pfile='/app/oracle/admin/stdby/pfile/initstdby_new. PRIMAR Y_ROLE) DB_UNIQUE_NAME=testdb' log_archive_dest_state_1='ENABLE' log_archive_dest_state_2='ENABLE' log_archive_format='%s_%t_%r.connect auxiliary sys/oracle@stdby run { allocate channel proddb1 type disk. SQL> archive log list. SQL> startup pfile='/app/oracle/admin/stdby/pfile/initstdby_new. database_role from v$database. open_mode.'proddb' set log_archive_config='DG_CONFIG=(proddb. SQL> alter system set "_log_deletion_policy"=ALL scope=spfile sid='*'. ALL_ROLES) DB_UNIQUE_NAME=stdby' log_archive_dest_2='SERVICE=testdb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES.ora' from spfile SQL> shu immediate. SQL> alter database flashback on.ora'.0' control_files='/vol1/oradata/stdby/control01. duplicate target database for standby from active database spfile parameter_value_convert 'stdby'.ora' nomount. SQL> shu immediate. SQL> create spfile from pfile='/app/oracle/admin/stdby/pfile/initstdby_new.'/vol1/oradata/stdby' set log_file_name_convert='/oracle/admin/proddb/flash_recovery_area/PRODDB/onlin elog'. ******************************************************************************** ********************compatible='11.stdby)' log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES. SQL> alter database recover managed standby database using current logfile disco nnect.1. allocate channel proddb2 type disk.ctl' set db_recovery_file_dest='/oracle/admin/stdby/flash_recovery_area' set db_recovery_file_dest_size='10248M' nofilenamecheck. } ******************************************************************************** * [oracle@localhost stdby]$ sqlplus /nolog SQL> conn sys/systestdb@stdby as sysdba SQL> select name. SQL> startup mount. allocate channel proddb3 type disk. allocate auxiliary channel stdby1 type disk.'/app/oracle/admin/testdb/flash_recovery_area/STDBY/onlinelog' .'/vol1/oradata/stdby' db_name='testdb' db_recovery_file_dest='/app/oracle/admin/stdby/flash_recovery_area' db_recovery_file_dest_size=10737418240 db_unique_name='stdby' diagnostic_dest='/app/oracle' dispatchers='(PROTOCOL=TCP)(SERVICE=stdbyXDB)' fal_client='STDBY' fal_server='TESTDB' log_archive_config='DG_CONFIG=(testdb.'/oracle/admin/stdby/flash_recovery_area/STDBY/onlinelog' set db_unique_name='stdby' set control_files='/vol1/oradata/stdby/control01.

DGMGRL> edit configuration set property FastStartFailoverLaglimit=60. backup controlfile : ================================================================STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "proddb" NORESETLOGS FORCE LOGGING . DGMGRL> switchover to stdby. DGMGRL> enable fast_start failover.bat' dg_broker_start=true ******************************************************************************** ******************** [oracle@localhost ~]$ export ORACLE_SID=testdb [oracle@localhost ~]$ export ORACLE_HOME=/app/oracle/product/11.1. DGMGRL> edit database proddb set property FastStartFailoverTarget='stddb1'. DGMGRL> enable fast_start failover. DGMGRL> convert database 'stdby' to physical standby. DGMGRL> show configuration. DGMGRL> enable configuration. [oracle@oel5 ~]$ export ORACLE_SID=stdby [oracle@oel5 ~]$ export ORACLE_HOME=/app/oracle/product/11. DGMGRL> enable database stdby.0/db_1 [oracle@oel5 ~]$ dgmgrl DGMGRL> connect sys/systestdb@stdby DGMGRL> switchover to testdb. DGMGRL> show configuration.bat' dg_broker_config_file2='/app/oracle/admin/stdby/dgbroker2/dg2. DGMGRL> edit database stddb1 set property FastStartFailoverTarget='stddb2'. [oracle@oel5 ~]$ export ORACLE_SID=stdby [oracle@oel5 ~]$ export ORACLE_HOME=/app/oracle/product/11.0/db_1 [oracle@localhost ~]$ dgmgrl -logfile /oracle/admin/dgmgrl.remote_login_passwordfile='EXCLUSIVE' sga_max_size=2048M sga_target=1536M standby_file_management='AUTO' undo_management='auto' undo_tablespace='undotbs1' db_flashback_retention_target=1440 dg_broker_config_file1='/app/oracle/admin/stdby/dgbroker1/dg1. DGMGRL> show site proddb DGMGRL> show site stdby DGMGRL> start observer. DGMGRL> enable database testdb. DGMGRL> show configuration.0/db_1 [oracle@oel5 ~]$ dgmgrl DGMGRL> connect sys/systestdb@stdby DGMGRL> disable fast_start failover. DGMGRL> edit configuration set property FastStartFailoverThreshold=45. DGMGRL> show configuration.1. DGMGRL> edit database stdby set property LogXptMode='SYNC'. DGMGRL> add database stdby as connect identifier is stdby maintained as physical . DGMGRL> edit database proddb set property LogXptMode='SYNC'. DGMGRL> edit configuration SET PROTECTION MODE AS MaxAvailability. DGMGRL> convert database 'stdby' to snapshot standby.1.log sys/systestdb@tes tdb DGMGRL> connect sys/systestdb@testdb DGMGRL> create configuration dg_project as primary database is testdb connect id entifier is testdb.

-. '/vol1/oradata/proddb/undotbs01.Commands to add tempfiles to temporary tablespaces.log' ) SIZE 50M. Use this only if online logs are damaged. '/vol1/oradata/proddb/redo02b.After mounting the created controlfile. ALTER TABLESPACE TEMP ADD TEMPFILE '/vol1/oradata/proddb/temp01. -. -.The contents of online logs will be lost and all backups will -.dbf' SIZE 262144 00 REUSE AUTOEXTEND ON NEXT 1048576 MAXSIZE 32767M. GROUP 2 ( . -. the following SQL -. -.be invalidated. GROUP 2 ( '/vol1/oradata/proddb/redo02a.dbf'.log'.Other tempfiles may require adjustment.protection mode: -.Data used by Recovery Manager will be lost.to open the database.log' ) SIZE 50M.ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "PRODDB" RESETLOGS FORCE LOGGING NOARCHIVELOG MAXLOGFILES 32 MAXLOGMEMBERS 4 MAXDATAFILES 100 MAXINSTANCES 1 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( '/vol1/oradata/proddb/redo01a. RESETLOGS case --. --Set #2.log'. '/vol1/oradata/proddb/users01. RECOVER DATABASE ALTER DATABASE OPEN.End of tempfile additions.statement will place the database in the appropriate -. '/vol1/oradata/proddb/redo03b.log' ) SIZE 50M DATAFILE '/vol1/oradata/proddb/system01. -.dbf'. GROUP 3 ( '/vol1/oradata/proddb/redo03a. -. '/vol1/oradata/proddb/redo01b.NOARCHIVELOG MAXLOGFILES 32 MAXLOGMEMBERS 4 MAXDATAFILES 100 MAXINSTANCES 1 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( '/vol1/oradata/proddb/redo01a.dbf'.log'.Online tempfiles have complete space information.log' ) SIZE 50M.dbf' CHARACTER SET US7ASCII .log'. '/vol1/oradata/proddb/redo01b.The following commands will create a new control file and use it -. '/vol1/oradata/proddb/sysaux01.

Other tempfiles may require adjustment. -. System altered.End of tempfile additions.re-create incarnation records.Commands to re-create incarnation table -.Below log names MUST be changed to existing filenames on -. '/vol1/oradata/proddb/undotbs01. -. ALTER DATABASE OPEN RESETLOGS.STANDBY LOGFILE DATAFILE '/vol1/oradata/proddb/system01.or if the last shutdown was not normal or immediate.log'. RECOVER DATABASE USING BACKUP CONTROLFILE -.dbf'. '/vol1/oradata/proddb/sysaux01. System altered.Commands to add tempfiles to temporary tablespaces.dbf'. -. -. -. '/vol1/oradata/proddb/redo03b.log' ) SIZE 50M -.log'. SQL> alter system set max_shared_servers=30 scope=both. SQL> show parameter shared_ NAME -----------------------------------max_shared_servers shared_memory_address TYPE ----------integer integer VALUE -----------------------------30 0 . -.ALTER DATABASE REGISTER LOGFILE '/oracle/admin/proddb/flash_recovery_area/PRO DDB/archivelog/2011_07_23/o1_mf_1_1_%u_.Database can now be opened zeroing the online logs. Any one log file from each branch can be used to -. SQL> show parameter shared_ NAME -----------------------------------max_shared_servers shared_memory_address shared_server_sessions shared_servers TYPE ----------integer integer integer integer VALUE ---------------------0 1 SQL> alter system set shared_servers=10 scope=both. System altered.dbf' CHARACTER SET US7ASCII .Recovery is required if any of the datafiles are restored backups. SQL> alter system set shared_server_sessions=100 scope=both. -.disk.dbf'. '/vol1/oradata/proddb/redo02b.arc'. SQL> alter system set sessions=300 scope=spfile.log' ) SIZE 50M. '/vol1/oradata/proddb/users01.Online tempfiles have complete space information. GROUP 3 ( '/vol1/oradata/proddb/redo03a.dbf' SIZE 26214400 REUSE AUTOEXTEND ON NEXT 1048576 MAXSIZE 32767M.'/vol1/oradata/proddb/redo02a. -. ALTER TABLESPACE TEMP ADD TEMPFILE '/vol1/oradata/proddb/temp01.

4)(PORT=152 6)(SERVICE=rmandb))(DISPATCHERS=3)" scope=both.'/app/oracle/adm in/stdby/flash_recovery_area/STDBY/onlinelog' SQL> shu immediate. System altered.ora : ============================ SID_LIST_LSNR2 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = rmandb) (ORACLE_HOME = /app/oracle/product/11. SQL> conn sys/oracle@rmandb_s as sysdba Connected. SQL> conn sys/oracle@rmandb_s as sysdba listener.0/db_1) (SID_NAME = rmandb) ) ) LSNR2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oel5.4)(PORT = 1526)) . '/app/oracle/admin/testdb/flash_recovery_area/TESTDB/onlinelog'.shared_server_sessions shared_servers SQL> show parameter dispa integer integer 100 10 NAME TYPE VALUE -----------------------------------. 2.4)(PORT=152 1))(DISPATCHERS=3)" scope=both. Connection should be 'rmandb_s' alias for rmandb it should be connected to 'rmandb' it should use 'lsnr2' listener and port '1526' using shared connection SQL> alter system set dispatchers="(ADDRESS=(PROTOCOL=TCP)(HOST=oel5. System altered. SQL> alter system set dispatchers="(ADDRESS=(PROTOCOL=TCP)(HOST=oel5.-----------------------------dispatchers string (PROTOCOL=TCP) (SERVICE=rmandb XDB) max_dispatchers integer SQL> alter system set max_dispatchers=10 scope=both. 3.1. SQL> alter system set local_listener="(ADDRESS=(PROTOCOL=TCP)(HOST=oel5. System altered.----------.4)(PORT= 1526))" scope=both. ORA-00106: cannot startup/shutdown database when connected to a dispatcher SQL> conn sys/oracle as sysdba SQL> startup. 4. System altered. Shared Side =====================> 1.

.. has 1 handler(s) for this service..ora : ============================ SID_LIST_LSNR2 = . Instance "rmandb". 3. 1. Service "rmandb" has 2 instance(s). Instance "rmandb"..) tnsnames..1. Connection should be 'rmandb' alias for rmandb it should be connected to 'rmandb' it should use 'lsnr2' listener and port '1526' using dedicated connection listener.0.1.Production Start Date 28-JUL-2011 11:48:38 Uptime 0 days 0 hr.. Service "rmandb_XPT" has 1 instance(s). 2. Instance "rmandb". The command completed successfully LSNRCTL> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dedicated Connection : ============================================== SQL> conn sys/oracle@rmandb as sysdba Connected. status UNKNOWN.4)(PORT=1526))) Services Summary. 10 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /app/oracle/product/11. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel5.xml Listening Endpoints Summary.4)(PORT = 1526)) ) (CONNECT_DATA = (SERVER = SHARED) (SERVICE_NAME = rmandb) ) ) SQL> conn sys/oracle@rmandb_s as sysdba Connected. Service "rmandbXDB" has 1 instance(s).. Instance "rmandb".. 4.. status READY. has 2 handler(s) for this service. has 2 handler(s) for this service..0/db_1/network/admin/listener .ora Listener Log File /app/oracle/diag/tnslsnr/oel5/lsnr2/alert/log. 4 min.0 . status READY.4)(PORT=1526))) STATUS of the LISTENER -----------------------Alias lsnr2 Version TNSLSNR for Linux: Version 11. status READY.. has 1 handler(s) for this service.7.ora: ================================ RMANDB_S = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oel5.. LSNRCTL> status lsnr2 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel5.

1. listener. SQL> conn sys/oracle@oel5.ora: ================================ RMANDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oel5.1. SQL> conn sys/oracle@rmandb_s as sysdba Connected. SQL> conn sys/oracle@rmandb as sysdba Connected.(SID_LIST = (SID_DESC = (GLOBAL_DBNAME = rmandb) (ORACLE_HOME = /app/oracle/product/11.ora ======================================== SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = rmandb) (ORACLE_HOME = /app/oracle/product/11.4)(PORT = 1526)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = rmandb) ) ) It connecting the below combinations : ===================================== SQL> conn sys/oracle@oel5.0/db_1) (SID_NAME = rmandb) ) ) LSNR2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oel5.4)(PORT = 1526)) ) tnsnames.0/db_1) (SID_NAME = rmandb) ) ) SID_LIST_LSNR2 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = rmandb) (ORACLE_HOME = /app/oracle/product/11.4:1526/rmandb as sysdba Connected.0/db_1) (SID_NAME = rmandb) ) ) LISTENER = (DESCRIPTION = .4:1521/rmandb as sysdba Connected.1.

The following code shows an example of a table using interval partitioning. The PARTITION BY RANGE clau se is used in the normal way to identify the transition point for the partition.4)(PORT = 1521)) ) LSNR2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oel5.'DD-MON-YYYY')) ).4)(PORT = 1526)) (ADDRESS = (PROTOCOL = TCP)(HOST = oel5. SQL> 2 3 4 5 6 7 8 9 10 CREATE TABLE INTERVAL_TAB ( ID NUMBER.(ADDRESS = (PROTOCOL = TCP)(HOST = oel5. CODE VARCHAR2(20).4)(PORT = 1526)) ) (CONNECT_DATA = (SERVER = SHARED) (SERVICE_NAME = rmandb) ) ) RMANDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oel5. where the system is able to create new partitions as they are required. Querying the USER_TAB_PARTITIONS view shows there is only a single partition.4)(PORT = 1526)) ) RMANDB_S = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oel5. DESCP VARCHAR2(20). CREATED_D DATE) PARTITION BY RANGE (CREATED_D) INTERVAL (NUMTOYMINTERVAL(1. . SQL> conn scott/tiger@testdb.4)(PORT = 1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = rmandb) ) ) Note : Only 'lsnr2' is running for above 4 combinations and 'listener' is not ru nning ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Interval Partitioning Interval partitioning is an extension of range partitioning. Table created.'MONTH')) ( PARTITION PART_01 VALUES LESS THAN (TO_DATE('01-NOV-2007'. then the new INTERVAL clause used to calculate the range for new partitions whe n the values go beyond the existing transition point.

SQL> INSERT INTO interval_tab VALUES (4. PL/SQL procedure successfully completed. 1 row created. 'FOUR'. 'THREE'. SQL> SELECT table_name. partition_name. 'TWO'. 'D D-MON-YYYY')). partition_name. TO_DATE('31-OCT-2007'. high_value. partition_name. Commit complete. partition_name. .SQL> EXEC DBMS_STATS. SQL> INSERT INTO interval_tab VALUES (2. SQL> COMMIT. 'One'. SQL> INSERT INTO interval_tab VALUES (3. a new partition is cr eated. 1 row created. 'INTERVAL_TAB'). If we add data beyond the range of the existing partition. SQL> COMMIT. TO_DATE('30-NOV-2007'. 'INTERVAL_TAB'). num_rows 2 FROM user_tab_partitions 3 ORDER BY table_name. Provided we insert data with a created_date value less than '01-NOV-2007' the da ta will be placed in the existing partition and no new partitions will be create d. high_value.gather_table_stats(USER. 'DD-MON-YYYY')). 1 row created. 'ONE'. PL/SQL procedure successfully completed. high_value. partition_name. TO_DATE('16-OCT-2007'. TO_DATE('01-NOV-2007' . SQL> SELECT table_name. 1 row created.gather_table_stats(USER. SQL> EXEC DBMS_STATS. 'Two'. 'DD-MON-YYYY')).gather_table_stats(USER. Commit complete. num_rows 2 FROM user_tab_partitions 3 ORDER BY table_name. 'Three'. SQL> COLUMN table_name FORMAT A20 SQL> COLUMN partition_name FORMAT A20 SQL> COLUMN high_value FORMAT A40 SQL> SELECT table_name. 'INTERVAL_TAB'). partition_name. num_rows 2 FROM user_tab_partitions 3 ORDER BY table_name. SQL> INSERT INTO interval_tab VALUES (1. SQL> EXEC DBMS_STATS. PL/SQL procedure successfully completed. 'Four'. 'D D-MON-YYYY')).

partition_name. 'NLS_CALENDAR=GREGORIA INTERVAL_TAB SYS_P22 2 TABLE_NAME PARTITION_NAME -------------------. onl y the required partition is created. SQL> INSERT INTO interval_tab VALUES (8. 'SYYYY-M M-DD HH24:MI:SS'. 'SYYYY-M 2 M-DD HH24:MI:SS'. 'Five'. 'SYYYY-M 2 M-DD HH24:MI:SS'. 'DD-MON-YYYY')). . SQL> INSERT INTO interval_tab VALUES (5. 'Eight'.---------INTERVAL_TAB PART_01 TO_DATE(' 2007-11-01 00:00:00'. 1 row created. TO_DATE('01-DEC-2007' . 1 row created. TABLE_NAME PARTITION_NAME -------------------. SQL> INSERT INTO interval_tab VALUES (7. Commit complete. 'DD-MON-YYYY')). 1 row created.---------TO_DATE(' 2008-02-01 00:00:00'. high_value. 'DD-MON-YYYY')). SQL> EXEC DBMS_STATS. 'SEVEN'. 'INTERVAL_TAB'). 'NLS_CALENDAR=GREGORIA INTERVAL_TAB SYS_P21 TO_DATE(' 2007-12-01 00:00:00'.gather_table_stats(USER. TO_DATE('01-JAN-2008'. num_rows 2 FROM user_tab_partitions 3 ORDER BY table_name. 'EIGHT'. SQL> INSERT INTO interval_tab VALUES (4.-------------------HIGH_VALUE NUM_ROWS ---------------------------------------. 'Four'. 'FOUR'.-------------------HIGH_VALUE NUM_ROWS ---------------------------------------. SQL> COMMIT. partition_name. 'NLS_CALENDAR=GREGORIA Notice that a partition to hold January 2008 data has not been created. 'Seven'. TO_DATE('31-DEC-2007' . not the intervening partitions. TO_DATE('31-JAN-2008'. the missing partition is created. PL/SQL procedure successfully completed. If we in sert data for this time period. 'FIVE'. 'DD-MON-YYYY')).If we insert data for two months after the current largest transition point. SQL> SELECT table_name.

high_value. 'INTERVAL_TAB'). 'SYYYY-M 2 M-DD HH24:MI:SS'. A MAXVALUE partition cannot be defined for an interval partitioned table.---------TO_DATE(' 2008-02-01 00:00:00'. You cannot create a domain index on an interval partitioned table.-------------------HIGH_VALUE NUM_ROWS ---------------------------------------. Global Index : SQL> CREATE INDEX PARENT_LOCAL_IDX ON PARENT_TAB(CREATED_D) GLOBAL PARTITION BY RANGE (CREATED_D) ( PARTITION LOCAL_1 VALUES LESS THAN (TO_DATE('01-AUG-2011'. 'NLS_CALENDAR=GREGORIA 2 The following restrictions apply to interval partitioned tables: Interval partitioning is restricted to a single partition key that must be a num erical or date range.-------------------HIGH_VALUE NUM_ROWS ---------------------------------------. PL/SQL procedure successfully completed. SQL> EXEC DBMS_STATS. Interval partitioning is not supported for index-organized tables. 'SYYYY-M 2 M-DD HH24:MI:SS'. Commit complete.'DD-MON-YYYY')) TABLESP ACE USERS. 'NLS_CALENDAR=GREGORIA INTERVAL_TAB SYS_P23 TO_DATE(' 2008-01-01 00:00:00'. 'SYYYY-M M-DD HH24:MI:SS'. NULL values are not allowed in the partition column. 'NLS_CALENDAR=GREGORIA INTERVAL_TAB SYS_P21 TO_DATE(' 2007-12-01 00:00:00'. partition_name. num_rows 2 FROM user_tab_partitions 3 ORDER BY table_name. partition_name.1 row created. 'SYYYY-M M-DD HH24:MI:SS'. . SQL> SELECT table_name. 'NLS_CALENDAR=GREGORIA INTERVAL_TAB SYS_P22 2 TABLE_NAME PARTITION_NAME -------------------. Interval partitioning can be used as the primary partitioning mechanism in compo site partitioning. SQL> COMMIT.---------INTERVAL_TAB PART_01 TO_DATE(' 2007-11-01 00:00:00'. At least one partition must be defined when the table is created. but it can't be used at the subpartition level.gather_table_stats(USER. TABLE_NAME PARTITION_NAME -------------------.

. The following code contains a partitioned parent table and a dependent reference partitioned child table. Table created. CONSTRAINT PARENT_TAB_PK PRIMARY KEY (ID) ) PARTITION BY RANGE (CREATED_D) ( PARTITION PART_2011 VALUES LESS THAN (TO_DATE('01-AUG-2011'. CONSTRAINT CHILD_PARENT_TAB_FK FOREIGN KEY (PARENT_TAB_ID) REFERENCES PARENT_TAB (ID) ) PARTITION BY REFERENCE (CHILD_PARENT_TAB_FK). Local Index : SQL> CREATE INDEX PARENT_LOCAL_IDX ON PARENT_TAB(CREATED_D) LOCAL ( PARTITION LOCAL_1 TABLESPACE USERS. Table created. Child records that foreign key to rows in the first partition of the parent tabl e should be placed in the first partition of the child table. CODE VARCHAR2(20) NOT NULL. DESCP VARCHAR2(50). CREATE TABLE PARENT_TAB ( ID NUMBER NOT NULL. Partition mainten ance operations performed on the parent table are reflected on the child table.PARTITION LOCAL_2 VALUES LESS THAN (MAXVALUE) TABLESPACE USERS). but no partition maintenance operations are allowed on the child table. DESCP VARCHAR2(50).'DD-MON-YYYY')) ). Index created. CREATED_D DATE. CONSTRAINT CHILD_TAB_PK PRIMARY KEY (ID). PARTITION LOCAL_2 TABLESPACE USERS). PARENT_TAB_ID NUMBER NOT NULL. Reference Partitioning Reference partitioning allows tables related by foreign keys to be logically equ i-partitioned. So we insert two r ows into the first partition and one row into the second of the parent table. Index created. The child table is partitioned using the same partitioning key as the parent table without having to duplicate the key columns. CREATED_D DATE. CREATE TABLE CHILD_TAB ( ID NUMBER NOT NULL.'DD-MON-YYYY')). CODE VARCHAR2(20) NOT NULL. PARTITION PART_2012 VALUES LESS THAN (TO_DATE('01-AUG-2012'.

'3 THREE'. All partition . SYSDATE). SYSDATE). The following query confirms out expectation . 3. We now expect the parent table to have 2 records in the 2011 partition and 1 in the 2012 partition. 1 row created. SQL> EXEC DBMS_STATS. SQL> INSERT INTO child_tab VALUES (2. with one foreign keyed to a row in the first partition and two foreign keyed to a row in the second partition of the master table. SQL> INSERT INTO child_tab VALUES (3. partition_name. num_rows FROM user_tab_partitions WHERE TABLE_NAME IN ('PARENT_TAB'. '3 3 THREE'. SQL> INSERT INTO child_tab VALUES (1.'CHILD_TAB') ORDER BY table_name. while the child table should have 1 row in the 2011 partitio n and 2 rows in the 2012 partition.12 )). The foreign key columns referenced in constraint must be NOT NULL. PL/SQL procedure successfully completed. ADD_MONTHS(SYSDATE. 1. 'THREE'. This constraint must be in ENABLE VALIDATE NOT DEFERRABLE st ate (the default) and refer to a primary or unique key on the parent table. SQL> INSERT INTO parent_tab VALUES (3.gather_table_stats(USER. 'ONE'.gather_table_stats(USER. 1 row created. 3. 'CHILD_TAB'). 'ONE'. PL/SQL procedure successfully completed. 1 row created. 1 row created. PARTITION_NAME NUM_ROWS -------------------. '1 ONE'. SQL> SQL> SQL> 2 3 4 COLUMN table_name FORMAT A25 COLUMN partition_name FORMAT A20 SELECT table_name. 'PARENT_TAB'). SYSDATE). SQL> INSERT INTO parent_tab VALUES (2. '2 3 TWO'. The constraint cannot use the ON DELETE SET NULL clause. SYSDATE). 1 row created. SQL> COMMIT.---------PART_2011 PART_2012 PART_2011 PART_2012 TABLE_NAME ------------------------CHILD_TAB CHILD_TAB PARENT_TAB PARENT_TAB 1 2 2 1 The following conditions and restrictions apply to reference partitioning: The child table must specify a referential integrity constraint defined on the t able being created. '1 1 ONE'. 'THREE'. 'TWO'. '2 TWO'. SQL> EXEC DBMS_STATS.We then insert three rows into the child table. 1 row created. Commit complete. partition_name. SQL> INSERT INTO parent_tab VALUES (1. 'TWO'. SYSDATE). The parent table referenced must be an existing partitioned table.

endian_format from v$transportable_platform a..a. Password: 230 User oracle logged in. AS SELECT state ment. 220 linuxdb FTP server (Version 5. but constraint used can' t be self-referencing. Transport Tablespace Using Cross Platform Transportable Tableaspace Linuxdb : Linux Opearating System tengr2 : Windows 2000 Opearting System ============================================================ LINUXDB>select a. LINUXDB>grant read. ftp> bin 200 Type set to I. grant read. LINUXDB>host expdp system/manager dumpfile=users.write on directory data_dump_dir to system.platform_name.platform_id. User (192.dbf) Connected to 192.ing methods except interval partitioning are supported.platform_id.1. The foreign key cannot contain any virtual columns. grant read. PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT ====================================================== 10 Linux IA (32-bit) Little LINUXDB>exec dbms_tts. or domain index storage tables.1. A chain of reference partitioned tables can be created. LINUXDB>create or replace directory dumplocation as '/oracle/product/102/db_1/li nuxdb/oradata'. LINUXDB>grant read. LINUXDB>alter tablespace users read only.endian_format 2 from v$transportable_platform a.168. Note : Copy the dumpfile (users.log directory =dumplocation transport_full_check=y transport_tablespaces=users SQL> select a.dmp) & datafile (users01.platform_id=b.transport_set_check ('USERS'. V$database b where a. external table s. The ROW MOVEMENT setting for both tables must match.TRUE). ftp> lcd d:\oradata\tengr2 . Reference partitioning cannot be used for index-organized tables.a.write on directory dumplocation to scott.4.platform_id=b.write on directory dumplocation to system.platform_id.. Reference partitioning cannot be specified in a CREATE TABLE .write on directory data_dump_dir to scott. The referenced primary key or unique constraint on the parent table cannot conta in any virtual columns.60) ready.dmp logfile=users. PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT ========================================================== 7 Microsoft Windows IA (32-bit) Little SQL> SQL> SQL> SQL> conn sys/systengr2 as sysdba create or replace directory data_dump_dir as 'D:\oradata\tengr2'.platform_id.platform_name.4:(none)): oracle 331 Password required for oracle.168. V$database b 3 where a.

tabname => 'EMP'. ftp> SQL> host impdp system/manager dumpfile=users. This makes working out the selectivity of the column group very difficult. Oracle uses workload analysis to generate column groups. mget users. -. mget users01.dbf (134225920 bytes).log directory=data_dump_dir transport_datafiles='D:\oradata\tengr2\users01. DECLARE l_cg_name VARCHAR2(30).dmp (126976 bytes). ftp: 126976 bytes received in 0.Create a columnn group based on EMP(JOB. The column group name is returned using the SHOW_EXTENDED_STATS_NAME function. The CREATE_EXTENDED_STATS proce dure is used to explicitly create multi-column statistics. ftp> cd /oracle/product/102/db_1/linuxdb/oradata 250 CWD command successful.dmp? y 200 PORT command successful. Multi-Column Statistics Individual column statistics are fine for working out the selectivity of a speci fic column in a where clause. 226 Transfer complete. extension => '(JOB.DEPTNO)'). but when the where clause includes multiple column s from the same table. the individual column statistics provide no indication of the relationship between the columns. 150 Opening BINARY mode data connection for users.82Kbytes/sec.dbf? y 200 PORT command successful.67Seconds 11499. tabname => 'EMP'.Local directory now D:\oradata\tengr2.dbf' SQL> connect scott/tiger SQL> select table_name from user_tables. / PL/SQL procedure successfully completed.Display the name of the columnn group. SQL> select * from org. LINUXDB>alter tablespace users read write. 226 Transfer complete. but they can also be ma nipulated manually using the DBMS_STATS package.create_extended_stats(ownname => 'SCOTT'. extension => '(JOB. -. ftp: 134225920 bytes received in 11. ftp> mget users01.dmp 200 Type set to I.show_extended_stats_name(ownname => 'SCOTT'.DEPTNO). 150 Opening BINARY mode data connection for users01.00Kbytes/sec.DEPTNO)') AS cg_na me FROM dual. SELECT DBMS_STATS.dmp logfile=users1.02Seconds 7936. END. BEGIN l_cg_name := DBMS_STATS. ftp> mget users.dbf 200 Type set to I. .

"MGR") using the DROP_EXTENDED_STATS proc 'SCOTT'.-----------. EXTENSION_NAME -----------------------------SYS_STU3VG629OEYG6FN0EKTGV_HQ6 SYS_STULPA1A#B6YL4KQ59DQO3OADQ EXTENSION -----------------------------("JOB". 'EMP'. BEGIN DBMS_STATS.table_name = 'EMP'.CG_NAME -----------------------------SYS_STU3VG629OEYG6FN0EKTGV_HQ6 1 row selected. / Alternatively. BEGIN DBMS_STATS. t.DEPTNO)').extension col_group. COLUMN extension FORMAT A30 SELECT extension_name.mgr)').gather_table_stats( 'SCOTT'.Drop the columnn group. method_opt => 'for all columns size auto').num_distinct.gather_table_stats( 'SCOTT'. SQL> Manually created column groups can be deleted edure. / The [DBA ALL USER]_STAT_EXTENSIONS views display information about the multi-col umn statistics. COL_GROUP NUM_DISTINCT HISTOGRAM -----------------------------. END. set the METHOD_OPT parameter to "FOR COLUMNS (column-list)" and t he group will automatically be created during the statistics gathering. COLUMN col_group FORMAT A30 SELECT e. / PL/SQL procedure successfully completed. extension FROM dba_stat_extensions WHERE table_name = 'EMP'. '(JOB. 'EMP'. t. BEGIN dbms_stats. -.column_name AND t."DEPTNO") ("JOB". 'EMP'."DEPTNO") 9 FREQUENCY . SQL> Setting the METHOD_OPT parameter to "FOR ALL COLUMNS SIZE AUTO" allows the GATHE R_% procedures to gather statistics on all existing column groups for the specif ied object.--------------("JOB". method_opt => 'for columns (job. END.extension_name= t.drop_extended_stats(ownname => tabname => extension => END.histogram FROM dba_stat_extensions e JOIN dba_tab_col_statistics t ON e.

grant_privileges=>true). queue_user=>'STRMADMIN')."MGR") 2 rows selected. queue_to_queue => TRUE). queue_name => 'strmadmin. source_database => 'db3'.ADD_TABLE_PROPAGATION_RULES( table_name => 'scott.Grant privilege to strmadmin in DB3 database: SQL> conn sys/sysdb3@db3 as sysdba SQL> grant connect. queue_user=>'STRMADMIN'). BEGIN DBMS_STREAMS_ADM.apply_queue'. DBMS_APPLY_ADM. 7(i).apply_queue@db4'. SQL> grant execute on dbms_file_transfer to strmadmin. source_database => 'db4').SET_UP_QUEUE( queue_name=>'capture_queue'.CREATE_APPLY( queue_name => 'strmadmin. Create database link to strmadmin in DB3 database: SQL> conn strmadmin/strmadmin@db3 SQL>create database link db4 connect to strmadmin identified by strmadmin using 'db4'.ADD_TABLE_RULES( table_name => 'scott.("JOB". streams_name => 'send_scott_emp'.grant_admin_privilege( grantee =>'strmadmin'. SQL>begin dbms_streams_auth.apply_queue'. destination_queue_name => 'strmadmin. streams_name => 'apply_scott_emp'. 8(i). DBMS_STREAMS_ADM.dba to strmadmin.ADD_TABLE_RULES( . DBMS_STREAMS_ADM. DBMS_STREAMS_ADM.SET_UP_QUEUE( queue_name=>'apply_queue'. DBMS_STREAMS_ADM.emp'. source_queue_name => 'strmadmin.emp'. streams_type => 'apply'. Streams : 8 FREQUENCY 6(i). Creating Procedure for STRMADMIN schema in DB3 database: SQL> conn strmadmin/strmadmin@db3 SQL>declare cscn NUMBER.resource. apply_captured => FALSE).capture_queue'. end. apply_name => 'apply_scott_emp'.

DBMS_APPLY_ADM. destination_queue_name => 'strmadmin. .SET_UP_QUEUE( queue_name=>'capture_queue'. queue_name => 'strmadmin. apply_name => 'apply_scott_emp'. DBMS_APPLY_ADM. streams_name => 'sync_capture'.SET_TABLE_INSTANTIATION_SCN@db3( source_object_name =>'scott. source_database => 'db4'. cscn :=DBMS_FLASHBACK. DBMS_STREAMS_ADM. source_database => 'db3'). source_queue_name => 'strmadmin.START_APPLY( apply_name => 'apply_scott_emp').apply_queue@db3'. / PL/SQL procedure successfully completed.ADD_TABLE_RULES( table_name => 'scott. cscn := DBMS_FLASHBACK. queue_user=>'STRMADMIN'). DBMS_APPLY_ADM. streams_name => 'send_scott_emp'.CREATE_APPLY( queue_name => 'strmadmin.table_name => 'scott. streams_name => 'sync_capture'. source_database_name => 'db3'. DBMS_APPLY_ADM. DBMS_STREAMS_ADM.emp'. DBMS_STREAMS_ADM. apply_captured => FALSE). source_database_name => 'db4'. END. 8(ii). queue_name => 'strmadmin. streams_type => 'sync_capture'.ADD_TABLE_RULES( table_name => 'scott.ADD_TABLE_PROPAGATION_RULES( table_name => 'scott. instantiation_scn => cscn).emp'.apply_queue'. DBMS_STREAMS_ADM.capture_queue'). streams_name => 'apply_scott_emp'.emp'.SET_UP_QUEUE( queue_name=>'apply_queue'. BEGIN DBMS_STREAMS_ADM. queue_user=>'STRMADMIN'). streams_type => 'sync_capture'.emp'.emp'. Creating Procedure for STRMADMIN schema in DB4 database: SQL> conn strmadmin/strmadmin@db4 SQL>declare cscn NUMBER. streams_type => 'apply'.SET_TABLE_INSTANTIATION_SCN@db4( source_object_name =>'scott.GET_SYSTEM_CHANGE_NUMBER().capture_queue'.capture_queue'). queue_to_queue => TRUE).emp'.apply_queue'. queue_name => 'strmadmin.GET_SYSTEM_CHANGE_NUMBER().

DBMS_APPLY_ADM. / PL/SQL procedure successfully completed. END.instantiation_scn => cscn). .START_APPLY( apply_name => 'apply_scott_emp').