Temporary Tablespace in Oracle


Temporary Tablespace in Oracle

Temporary tablespaces are used to manage space for database sort and joining operations and for storing global temporary tables. For joining two large tables or sorting a bigger result set, Oracle cannot do in memory by using SORT_AREA_SIZE in PGA (Programmable Global Area). Space will be allocated in a temporary tablespace for doing these types of operations. Other SQL operations that might require disk sorting are: CREATE INDEX, ANALYZE, SELECT DISTINCT, ORDER BY, GROUP BY, UNION, INTERSECT, MINUS, Sort-Merge joins, etc.

Note that a temporary tablespace cannot contain permanent objects and therefore doesn't need to be backed up. A temporary tablespace contains schema objects only for the duration of a session.

Creating Temporary Tablespace

e.g.
SQL> CREATE DATABASE oracular .....
DEFAULT TEMPORARY TABLESPACE temp_ts .....;

Tempfiles (Temporary Datafiles)
Unlike normal datafiles, tempfiles are not fully allocated. When you create a tempfiles, Oracle only writes to the header and last block of the file . This is why it is much quicker to create a tempfiles than to create a normal datafile.

Tempfiles are not recorded in the database's control file. This implies that just recreate them whenever you restore the database, or after deleting them by accident. You can have different tempfile configurations between primary and standby databases in dataguard environment, or configure tempfiles to be local instead of shared in a RAC environment.

One cannot remove datafiles from a tablespace until you drop the entire tablespace. However, one can remove a tempfile from a database. Look at this example:
SQL> alter database tempfile 'tempfile_name' drop including datafiles;
//If the file was created as tempfile

SQL> alter database datafile 'tempfile_name' drop;
//If the file was created as datafile

Dropping temp tablespace
SQL> drop tablespace temp_tbs;
SQL> drop tablespace temp_tbs including contents and datafiles;

If you remove all tempfiles from a temporary tablespace, you may encounter error:
ORA-25153: Temporary Tablespace is Empty.

Use the following statement to add a tempfile to a temporary tablespace:
SQL> ALTER TABLESPACE temp ADD TEMPFILE '/path/temp01.dbf' SIZE 512m
AUTOEXTEND ON NEXT 250m MAXSIZE UNLIMITED;

Except for adding a tempfile, you cannot use the ALTER TABLESPACE statement for a locally managed temporary tablespace (operations like rename, set to read only, recover, etc. will fail).

Locally managed temporary tablespaces have temporary datafiles (tempfiles), which are similar to ordinary datafiles except:

You cannot create a tempfile with the ALTER DATABASE statement.
You cannot rename a tempfile or set it to read-only.
Tempfiles are always set to NOLOGGING mode.
 

When you create or resize tempfiles, they are not always guaranteed allocation of disk space for the file size specified. On certain file systems (like UNIX) disk blocks are allocated not at file creation or resizing, but before the blocks are accessed.
Tempfile information is shown in the dictionary view DBA_TEMP_FILES and the dynamic performance view V$TEMPFILE.Note: This arrangement enables fast tempfile creation and resizing, however, the disk could run out of space later when the tempfiles are accessed.

Default Temporary Tablespaces

SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

By default, the default temporary tablespace is SYSTEM. Each database can be assigned one and only one default temporary tablespace. Using this feature, a temporary tablespace is automatically assigned to users.

The following restrictions apply to default temporary tablespaces:
-DEFAULT TEMPORARY TABLESPACE must be of type TEMPORARY.
-DEFAULT TEMPORARY TABLESPACE cannot be taken off-line.
-DEFAULT TEMPORARY TABLESPACE cannot be dropped until you create another one.

To see the default temporary tablespace for a database, execute the following query:
SQL> select PROPERTY_NAME,PROPERTY_VALUE from database_properties where property_name like '%TEMP%';

The DBA should assign a temporary tablespace to each user in the database to prevent them from allocating sort space in the SYSTEM tablespace. This can be done with one of the following commands:
SQL> CREATE USER scott TEMPORARY TABLESPACE temp;
SQL> ALTER USER scott TEMPORARY TABLESPACE temp;

To change a user account to use a non-default temp tablespace
SQL> ALTER USER user1 SET TEMPORARY TABLESPACE temp_tbs;

Assigning temporary tablespace group as default temporary tablespace:
Assigning temporary tablespace group to a user (same as assigning temporary tablespace to a user):


SQL> ALTER USER scott TEMPORARY TABLESPACE temp_grp;

All new users that are not explicitly assigned a TEMPORARY TABLESPACE will get the default temporary tablespace as its TEMPORARY TABLESPACE. Also, when you assign a TEMPORARY tablespace to a user, Oracle will not change this value next time you change the default temporary tablespace for the database.

Performance Considerations
Some performance considerations for temporary tablespaces:

Always use temporary tablespaces instead of permanent content tablespaces for sorting & joining (no logging and uses one large sort segment to reduce recursive SQL and ST space management enqueue contention).
Ensure that you create your temporary tablespaces as locally managed instead of dictionary managed (i.e. use sort space bitmap instead of sys.fet$ and sys.uet$ for allocating space).
Always use TEMPFILE instead of DATAFILE (reduce backup and recovery time).
Stripe your temporary tablespaces over multiple disks to alleviate possible disk contention and to speed-up operations (user processes can read/write to it directly).
 

The UNIFORM SIZE must be a multiple of the SORT_AREA_SIZE parameter.
Monitoring Temporary Tablespaces
Unlike datafiles, tempfiles are not listed in V$DATAFILE and DBA_DATA_FILES. Use V$TEMPFILE and DBA_TEMP_FILES instead.

SQL> SELECT tablespace_name, file_name, bytes FROM dba_temp_files WHERE tablespace_name = 'TEMP';
TABLESPACE_NAME FILE_NAME BYTES
----------------- -------------------------------- --------------
TEMP /../temp01.dbf 11,175,650,000

SQL> select file#, name, round(bytes/(1024*1024),2) "SIZE IN MB's" from v$tempfile;

One can monitor temporary segments from V$SORT_SEGMENT and V$SORT_USAGE.

DBA_FREE_SPACE does not record free space for temporary tablespaces. Use DBA_TEMP_FREE_SPACE or V$TEMP_SPACE_HEADER instead.

SQL> select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
TABLESPACE_NAME BYTES_USED BYTES_FREE
------------------------------ ---------- ----------
TEMPTBS 4214226944 80740352

From 11g, we can check free temp space in new view DBA_TEMP_FREE_SPACE.
SQL> select * from DBA_TEMP_FREE_SPACE;

Resizing tempfile
SQL> alter database tempfile temp-name resize integer K|M|G|T|P|E;
SQL> alter database tempfile '/path/temp01.dbf' resize 1000M;


Resizing temporary tablespace
SQL> alter tablespace temptbs resize 1000M;

Renaming (temporary) tablespace, this is from Oracle 10g
SQL> alter tablespace temp rename to temp2;

Shrinking
 In Oracle 11g, temporary tablespace or it's tempfiles can be shrinked, up to specified size.

Shrinking frees as much space as possible while maintaining the other attributes of the tablespace or temp files. The optional KEEP clause defines a minimum size for the tablespace or temp file.SQL> alter tablespace temp-tbs shrink space;
SQL> alter tablespace temp-tbs shrink space keep n{K|M|G|T|P|E};
SQL> alter tablespace temp-tbs shrink tempfile 'tempfile-name' ;
SQL> alter tablespace temp-tbs shrink tempfile 'tempfile-name' keep n{K|M|G|T|P|E};

The below script reports temporary tablespace usage (script was created for Oracle9i Database). With this script we can monitor the actual space used in a temporary tablespace and see HWM (High Water Mark) of the temporary tablespace. The script is designed to run when there is only one temporary tablespace in the database.

SQL> select sum( u.blocks * blk.block_size)/1024/1024 "MB. in sort segments", (hwm.max * blk.block_size)/1024/1024 "MB. High Water Mark"
from v$sort_usage u, (select block_size from dba_tablespaces where contents = 'TEMPORARY') blk, (select segblk#+blocks max from v$sort_usage where segblk# = (select max(segblk#) from v$sort_usage) ) hwm group by hwm.max * blk.block_size/1024/1024;

How to reclaim used space
Several methods existed to reclaim the space used for a larger than normal temporary tablespace.
(1) Restarting the database, if possible.
(2) The method that exists for all releases of Oracle is, simply drop and recreate the temporary tablespace back to its original (or another reasonable) size.
(3) If you are using Oracle9i or higher, drop the large tempfile (which will drop the tempfile from the data dictionary and the OS file system).


From 11g, while creating global temporary tables, we can specify TEMPORARY tablespaces.


Related Views:
DBA_TEMP_FILES
DBA_DATA_FILES
DBA_TABLESPACES
DBA_TEMP_FREE_SPACE (Oracle 11g)
V$TEMPFILE
V$TEMP_SPACE_HEADER
V$TEMPORARY_LOBS
V$TEMPSTAT
V$TEMPSEG_USAGE
SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp_grp;

Active Dataguard on RAC - Two node - Oracle 11gR2

Active Dataguard on RAC - Two node  - Oracle 11gR2

servers:
primary nodes: prim-serv1, prim-serv2
stadby nodes : stdby-serv1, stdby-serv2
scans: prim-scan-name
     : stdby-scan-name
VIPs : prim-serv1-vip, prim-serv2-vip
     : stdby-serv1-vip, stdby-serv2-vip
Primary DB: PRIM (PRIM1, PRIM2)
Standby DB: STDBY (STDBY1, STDBY2)
----------------------------------------------

<prim-serv1>
cd /u01/app/grid/11.2.0.3/network/admin
vi listener.ora
SID_LIST_LISTENER=
(SID_LIST=
  (SID_DESC=
   (GLOBAL_DBNAME=PRIM_DGMGRL)
   (SID_NAME=prim1)
   (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
  )
)
lsnrctl reload
lsnrctl status
<prim-serv2>
cd /u01/app/grid/11.2.0.3/network/admin
vi listener.ora
SID_LIST_LISTENER=
 (SID_LIST=
  (SID_DESC=
   (GLOBAL_DBNAME=PRIM_DGMGRL)
   (SID_NAME=PRIM2)
   (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
  )
 )
lsnrctl reload
lsnrctl status

<stdby-serv1>
cd /u01/app/grid/11.2.0.3/network/admin
vi listener.ora

SID_LIST_LISTENER=
 (SID_LIST=
  (SID_DESC=
   (GLOBAL_DBNAME=STDBY_DGMGRL)
   (SID_NAME=STDBY1)
   (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
  )
 )
lsnrctl reload
lsnrctl status
<stdby-serv2>
cd /u01/app/grid/11.2.0.3/network/admin
vi listener.ora
SID_LIST_LISTENER=
 (SID_LIST=
  (SID_DESC=
   (GLOBAL_DBNAME=STDBY_DGMGRL)
   (SID_NAME=STDBY2)
   (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
  )
 )
lsnrctl reload
lsnrctl status
-----------------
--logon to both primary and standby all nodes in both the clusters:

 cd /u01/app/oracle/product/11.2.0/db_1/network/admin
--add to tnsnames.ora:
PRIM_DGMGRL =
 (DESCRIPTION_LIST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <prim-serv1>-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = <prim-serv2>-vip)(PORT = 1521))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PRIM_DGMGRL))
  )
 )

PRIM =
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = <prim-scn-name>)(PORT = 1521))
  (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = <PRIM_SID>)
  )
 )
PRIM1 =
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = prim-serv1-vip)(PORT = 1521))
  (CONNECT_DATA =
   (SERVER = DEDICATED)
   (SERVICE_NAME = PRIM1)
   (SID = PRIM1)
  )
 )
PRIM2 =
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = prim-serv2-vip)(PORT = 1521))
  (CONNECT_DATA =
   (SERVER = DEDICATED)
   (SERVICE_NAME =PRIM2)
   (SID = PRIM2)
  )
 )
STDBY_DGMGRL =
(DESCRIPTION_LIST =
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-serv1-vip)(PORT = 1521))
  (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-serv2-vip)(PORT = 1521))
  (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = STDBY_DGMGRL))
 )
)

STDBY =
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-scan-name)(PORT = 1521))
  (CONNECT_DATA =
   (SERVER = DEDICATED)
   (SERVICE_NAME =STDBY)
  )
 )
STDBY1 =
(DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-serv1-vip)(PORT = 1521))
 (CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = STDBY1)
  (SID = STDBY1)
 )
)
STDBY1 =
(DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-serv2-vip)(PORT = 1521))
 (CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = STDBY2)
  (SID = STDBY2)
 )
)
--on prim-serv1
export ORACLE_SID=prim1
sqlplus as sysdba

SQL>create pfile='initPRIM.ora' from spfile;
SQL>alter system set log_archive_config = 'DG_CONFIG=(PRIM,STDBY)' scope=both sid='*';
SQL>alter system set log_archive_dest_1 = 'LOCATION=+<DG>FRA VALID_FOR=(ALL_LOGFILES,ALL_ROLES)' scope=both sid='*';
SQL>alter system set log_archive_dest_2 = 'SERVICE=STDBY VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDBY' scope=both sid='*';
SQL>alter system set log_archive_dest_state_1=enable scope=both;
SQL>alter system set log_archive_dest_state_2=enable scope=both;
SQL>alter system set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=spfile sid='*';
SQL>alter system set LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' scope=spfile sid='*';
SQL>alter system set standby_file_management=auto scope=both sid='*';
SQL>alter system set LOG_ARCHIVE_MAX_PROCESSES=5 scope=both sid='*';
SQL>alter system set db_block_checksum = typical scope=both sid='*';
SQL>alter system set db_block_checking=true scope=both sid='*';

--Stop database using srvctl
SQL>startup mount;
SQL>alter database archivelog;
SQL>alter database open;
SQL>archive log list
SQL>alter database force logging;
SQL>shutdown immediate;
Start database using srvctl
--Create standby redo logs: (# of logs vary) (same size as the online redo logs)
SQL>alter database add standby logfile group 7  ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 8  ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 9  ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 10 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 11 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 12 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 13 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 14 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 15 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 16 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 17 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 18 ('+REDO1','+REDO2') size 500M;
SQL>alter database add standby logfile group 19 ('+REDO1','+REDO2') size 500M;
SQL>select * from v$log;
SQL>select * from v$standby_log;

--ON PRIMARY
--Copy password files. Create pfile. Start standby instance.
% scp $ORACLE_HOME/dbs/orapwPRIM1 stdby-serv1:$ORACLE_HOME/dbs/orapwPRIM1
% scp $ORACLE_HOME/dbs/orapwPRIM1 stdby-serv2:$ORACLE_HOME/dbs/orapwPRIM2
--ON Both STANDBY nodes create adump directory
mkdir -p /u01/app/oracle/admin/STDBY/adump
--On first standby server create initSTDBY1.ora in /tmp with only db_name=STDBY
cd /tmp vi initSTDBY1.ora
db_name=STDBY
export ORACLE_SID=STDBYP1
sqlplus / as sysdba
SQL> startup nomount pfile='/tmp/initSTDBY1.ora;

--test connection:
sqlplus sys/mypasswd@<STDBY>_DGMGRL as sysdba
--ON PRIMARY
--Use RMAN to create standby database.
--on prim-serv1
cd to <scrpit-dir>
export ORACLE_SID=PRIM1
echo $ORACLE_SID
rman
connect target /
connect auxiliary sys/password@STDBY_DGMGRL
--- returns connected to (not started)
@create_phys_sby.cmd
----start create_phy_sby.cmd ----
run {
ALLOCATE CHANNEL c1 TYPE DISK;
ALLOCATE AUXILIARY CHANNEL sby TYPE DISK;
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE
  SPFILE
    parameter_value_convert 'PRIM','STDBY'
    SET db_unique_name='STDBY'
    SET LOG_ARCHIVE_MAX_PROCESSES='5'
    SET LOG_ARCHIVE_DEST_2='SERVICE=PRIM ASYNC VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE) DB_UNIQUE_NAME=PRIM'
    SET FAL_SERVER='PRIM'
    SET FAL_CLIENT='STDBY1'
    SET STANDBY_FILE_MANAGEMENT='AUTO'
    SET log_archive_config='DG_CONFIG=(PRIM,STDBY)'
--    set db_create_file_dest='+<STDBY-DG>' --if different DG is used
    set control_files='+STDBY-DG/STDBY/controlfile/control01.dbf'
    set instance_number='1'
    set audit_file_dest='/u01/app/oracle/admin/STDBY/adump'
;
}

----------end create_phy_sby.cmd --------------
--on STANDBY location create spfile for standby database from spfile created from rman
export ORACLE_SID=STDBY1
sqlplus / as sysdba
sqlplus> create pfile='/tmp/initSTDBY1.ora' from spfile;
--Edit the new pfile and replace every occurrence of PRIM, with STDBy, other than the db_name,
--which must stay the same. Pay attention to instance_number. Make sure the control file
--reflects the control file that was used in the rman duplicate ('+STDBY-DG/STDBY/controlfile/control01.dbf')
--Pay attention some enteries already have standby name so rename might mess up
--VERIFY adump sid is correct, db_unique_name is correct, etc
--*.db_name='PRIM' (VERIFY & DO NOT CHNGE)

SQL> create spfile='+STDBY-DG/STDBY/spfileSTDBY.ora' from pfile='/tmp/initSTDBY1.ora';

--Create a pointer pfile for each instance and copy to $ORACLE_HOME/dbs on the stanby hosts
--remove spfile created by rman
--on stdby-serv1
--create initSTDBY1.ora under $ORACLE_HOME/dbs with the following line:
spfile='+STDBY-DG/STDBY/spfileSTDBY.ora'
--on stdby-serv2
--create initSTDBY2.ora under $ORACLE_HOME/dbs with the following line:
spfile='+STDBY-DG/STDBY/spfileSTDBY.ora' 
--Create two new control files for stdby on REDO1 and 2 (which ever disk group you choose).
--On  stdby-serv1
SQL> shutdown immediate;
SQL> startup nomount;
SQL> alter system set control_files='+REDO1','+REDO2' scope=spfile;
SQL> shutdown immediate;
SQL> startup nomount;
rman target /
restore controlfile from '+STDBY-DG/STDBY/controlfile/control01.dbf';
SQL> startup mount;
select process,status,sequence# from v$managed_standby;
 alter database recover managed standby database cancel;
alter database open read only;
select status,instance_name,database_role,open_mode from v$database,v$instance;
alter database recover managed standby database USING CURRENT LOGFILE disconnect from session;
select process,status,sequence# from v$managed_standby;
-- Make sure this query return rows
SELECT 'Using Active Data Guard' ADG FROM V$MANAGED_STANDBY M, V$DATABASE D
WHERE M.PROCESS LIKE 'MRP%' AND D.OPEN_MODE like 'READ ONLY%';

--start stdby2 instance on node 2 also. We have the recovery on first node so just open on second
export ORACLE_SID=stdby2
sqlplus / as sysdba
startup mount;
alter database open read only;
select process,status,sequence# from v$managed_standby;
--Verify configuration parameters on both primary and standby databases, adjust if needed.
Standby
alter system set db_block_checksum=full scope=both sid='*';
alter system set db_block_checking=full scope=both sid='*';
alter system set fal_client='STDBY1' scope=both sid='STDBY1';
alter system set fal_client='STDBY2' scope=both sid='STDBY2';
alter system set fal_server='PRIM' scope=both sid='*';
alter system set log_archive_config='dg_config=(PRIM,STDBY)' scope=both sid='*';
alter system set log_archive_max_processes=5 scope=both sid='*';
alter system set log_archive_dest_2='service=PRIM ARCH db_unique_name=PRIM valid_for=(all_logfiles,primary_role)' scope=both sid='*';
--If using DG broker
alter system set dg_broker_config_file1='+REDO1/STDBY/parameterfile/dr1STDBY.dat' scope=both sid='*';
alter system set dg_broker_config_file2='+REDO2/STDBY/parameterfile/dr2STDBY.dat' scope=both sid='*';
--Primary
alter system set fal_client='PRIM1' scope=both sid='PRIM1';
alter system set fal_client='PRIM2' scope=both sid='PRIM2';
alter system set fal_server='STDBY' scope=both sid='*';
alter system set db_block_checksum=full scope=both sid='*';
alter system set db_block_checking=full scope=both sid='*';
alter system set log_archive_max_processes=5 scope=both sid='*';
alter system set dg_broker_config_file1='+REDO1/PRIM/parameterfile/dr1PRIM.dat' scope=both sid='*';
alter system set dg_broker_config_file2='+REDO2/PRIM/parameterfile/dr2PRIM.dat' scope=both sid='*';

use asmcmd to create
+REDO1/PRIM/parameterfile
+REDO2/PRIM/parameterfile
+REDO1/STDBY/parameterfile
+REDO2/STDBY/parameterfile
--on standby:
srvctl add database -d STDBY -o /u01/app/oracle/product/11.2.0/db_1 -p
'+STDBY-DG/STDBY/spfileSTDBY.ora' -n STDBY -r physical_standby -s 'READ ONLY'
srvctl add instance -d STDBY -i STDBY1 -n stdby-serv1
srvctl add instance -d STDBY -i STDBY2 -n stdby-serv2

--shutdown all standby instances via sqlplus and start database using srvctl
srvctl start database -d STDBY
*****start the managed recovery every time the standby is re-started as shown below ****
*****only on one node *******
--Logon to standby instance (STDBY1) as SYSDBA, and issue:
SBY SQL> alter database recover managed standby database USING CURRENT LOGFILE disconnect from session;
select process,status,sequence# from v$managed_standby;
-- Make sure this query return rows
SELECT 'Using Active Data Guard' ADG FROM V$MANAGED_STANDBY M, V$DATABASE D
WHERE M.PROCESS LIKE 'MRP%' AND D.OPEN_MODE like 'READ ONLY%';
ADG
--------------------------------
Using Active Data Guard

--On all other standby nodes run the following to see that it is open read only.
SQL> select status,instance_name,database_role,open_mode from v$database,v$instance;
STATUS       INSTANCE_NAME    DATABASE_ROLE    OPEN_MODE
------------ ---------------- ---------------- --------------------
OPEN         STDBY2          PHYSICAL STANDBY READ ONLY WITH APPLY
--on primary ( test if the DG is working)
PRI SQL> alter system switch logfile;
--Monitor alert logs, make sure logs are shipped and applied.
--Also make sure that the archived logs are applied on all standby destinations.
select process,status,sequence# from v$managed_standby; --- on both primary & standby
----IF DG Broker is used ----
Start Data Guard broker and create configuration.
FOR BOTH DATABASES
PRI SQL> alter system set DG_BROKER_START=TRUE scope=both;
SBY SQL> alter system set DG_BROKER_START=TRUE scope=both;
ON PRIMARY
> dgmgrl /
DGMGRL> create configuration 'DGConfigPRIM' as primary database is PRIM connect identifier is PRIM;
DGMGRL> add database STDBY as connect identifier is STDBY;
DGMGRL> show configuration verbose
DGMGRL> enable configuration;
DGMGRL> show configuration verbose
DGMGRL> show database verbose PRIM
DGMGRL> show database verbose STDBY
DGMGRL> show instance verbose <all instances>
ie: show instance verbose PRIM1
Check StaticConnectIdentifier,
StandbyArchiveLocation, ...
Following is the sample how to modify Data Guard parameters.
DGMGRL> EDIT DATABASE <dbname> SET PROPERTY StandbyArchiveLocation =
'<location>';

RC-50221: Warning: Port Pool 50 is not free.


RC-50221: Warning: Port Pool 50 is not free.

Means the port is used by some other program on your host. Use a different port pool number, or try to release the port which is already reserved
$ netstat -a | grep <port number>
Kill the process that use that port using "kill -9 <process id>" command or simply reboot the box (if possible).

FRM-92120 Registry file http://xxxx/forms/java/oracle/forms/registry? Registry.dat is missing.

FRM-92120 Registry file http://xxxx/forms/java/oracle/forms/registry?

Registry.dat is missing.

Please clear both Java and Browser cache:

Clearing Java cache:
Go to Control Panel |Java | General Tab | Temporary Internet Files > Settings…. > Delete Files… A popup with two item should be checked (Applications and Applets and Trace and Logfiles).  Leave the items selected and click OK.

Clearing IE cache:
Go to Tools | Internet Options > in the General tab under Browsing history, select Delete... and delete Temporary Internet files, Cookies and History.

Retry Banner.

Generate AWR report manually



Generate AWR report manually

1. Creating Snapshot
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
END;
/
The list of the snapshot Ids along with database Ids is availabe in the view DBA_HIST_SNAPSHOT.
2. Dropping a Range of Snapshots.Refer to the DBA_HIST_SNAPSHOT view column SNAP_ID to view available snapshots. To delete contain SNAP_ID from from 102 to 122,
BEGIN
DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE (low_snap_id => 102, high_snap_id => 122, dbid => 8187786345);
END;
/
3. Modifying Snapshot SettingsIf you want to modify the retention period as 43200 minutes (30 days), the interval between each snapshot is specified as 30 minutes, and the number of Top SQL to flush for each SQL criteria as 100 then use following:
BEGIN
DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 43200,
interval => 30, topnsql => 100, dbid => 7123356265);
END;
/
The dbid is optional.
4. Extract the AWR DataThe awrextr.sql script extracts the AWR data for a range of snapshots from the database into a Data Pump export file. Once created, this dump file can be transported to another system where the extracted data can be loaded. To run the awrextr.sql script, you need to be connected to the database as the SYS user.
To extract AWR data at the SQL prompt, enter:
SQL> @$ORACLE_HOME/rdbms/admin/awrextr.sql
5. Load the AWR DataOnce the export dump file is transported to the target system, you can load the extracted AWR data using the awrload.sql script. The awrload.sql script will first create a staging schema where the snapshot data is transferred from the Data Pump file into the database. The data is then transferred from the staging schema into the appropriate AWR tables. To run the awrload.sql script, you need to be connected to the database as the SYS user.
To load AWR data at the SQL prompt, enter:
SQL> @$ORACLE_HOME/rdbms/admin/awrload.sql
6. Generate AWR ReportsThe awrrpt.sql SQL script generates an HTML or text report that displays statistics for a range of snapshot Ids.
To generate an HTML or text report for a range of snapshot Ids, run the awrrpt.sql script at the SQL prompt:
SQL> @$ORACLE_HOME/rdbms/admin/awrrpt.sql
First, you need to specify whether you want an HTML or a text report.
Enter value for report_type: text
Specify the number of days for which you want to list snapshot Ids.
Enter value for num_days: 2
After the list displays, you are prompted for the beginning and ending snapshot Id for the workload repository report.
Enter value for begin_snap: 95
Enter value for end_snap: 97
Next, accept the default report name or enter a report name. The default name is accepted in the following example:
Enter value for report_name:
Using the report name awrrpt_1_95_97
The workload repository report is generated.
awrrpt.sql
The awrrpt.sql SQL script generates an HTML or text report that displays statistics for a range of snapshot Ids.
awrrpti.sql
The awrrpti.sql SQL script generates an HTML or text report that displays statistics for a range of snapshot Ids on a specified database and instance.
awrsqrpt.sql
The awrsqrpt.sql SQL script generates an HTML or text report that displays statistics of a particular SQL statement for a range of snapshot Ids. Run this report to inspect or debug the performance of a SQL statement.
awrsqrpi.sql
The awrsqrpi.sql SQL script generates an HTML or text report that displays statistics of a particular SQL statement for a range of snapshot Ids on a specified database and instance. Run this report to inspect or debug the performance of a SQL statement on a specific database and instance.
awrddrpt.sql
The awrddrpt.sql SQL script generates an HTML or text report that compares detailed performance attributes and configuration settings between two selected time periods.
awrddrpi.sql
The awrddrpi.sql SQL script generates an HTML or text report that compares detailed performance attributes and configuration settings between two selected time periods on a specific database and instance.