ORA-16047: DGID mismatch between destination setting and target sol:check the service name in log_archive_dest_2 and check fal and defer and enable the dest state
********************************************************************************
./runInstaller -ignorePrereq -J"-Doracle.install.db.validate.supportedOSCheck=false" -ignorePrereq "-ignoreInternalDriverError"
***********************************************************************************************************************************
PMON failed to acquire latch, see PMON dump sol:kill smon and start the instance or sqlplus -prelim / as sysdba shut abort then start
ORA-07445: Message 7445 not found; No message file for product=RDBMS, facility=ORA;
*********************************************************************************************
ORA-29701: unable to connect to Cluster Synchronization Service RESOLVABLE GAP
**************************************************************
Failed to open service <OracleOraDb11g_home2TNSListenerLISTENER1
*********************************************************
RMAN> sql 'alter database open resetlogs';
sql statement: alter database open resetlogs
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 09/07/2017 13:41:14
RMAN-11003: failure during parse/execution of SQL statement: alter database open resetlogs
ORA-00349: failure obtaining block size for '+REDO/etlprod/redo01.lo
sol: ALTER DATABASE RENAME FILE '+REDO/etlprod/redo03.log' to '/home/oracle/app/oracle/oradata/ETLPROD/redo03.log';
***********************************************************************************************************************************
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00392: log 1 of thread 1 is being cleared, operation not allowed
ORA-00312: online log 1 thread 1: ------sol: alter database clear logfile group 1;
'/home/oracle/app/oracle/oradata/ETLPROD/redo01.log'
ORA-00312: online log 1 thread 1:
'/home/oracle/app/oracle/oradata/ETLPROD/redo01a.log'
***********************************************************************************************************************************
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== check the file permission
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/05/2016 10:37:31
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
***********************************************************************************************************************************
ORA-12547: TNS:lost contact ---https://oracledbamasters.wordpress.com/2014/02/25/ora-12547-tns-lost-contact/ -- check the permission on birnaries
***********************************************************************************************************************************
ERROR at line 1:
ORA-00376: file 4 cannot be read at this time --tablespace or datafile might be offline --make it as online
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/DB01/users01.dbf'
***********************************************************************************************************************************
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ---
setup.exe -ignorePrereq -ignorePrereq -J"-Doracle.install.db.validate.supportedOSCheck=false --windows
chmod +R 777 CVU_11.2.0.4.0_oracle in /tmp/ -- Linux
ora-2048 9i client trying to connect -- 11g database
***********************************************************************************************************************************
@casesensitive
sec_case_sensitive_logon=true default passwork case sensitive
***********************************************************************************************************************************
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set windows db sever --> linux client export
erver uses AL32UTF8 character set (possible charset conversion)
***********************************************************************************************************************************
ORA-19502: write error on file "/backup/RMAN_BKP/25Apr17230001/smsdb_rmanbkp_u48s2kcu5_s38024_p1_t20170426", block number 1418113 (block size=8192)
ORA-27061: waiting for async I/Os failed
Linux-x86_64 Error: 5: Input/output error reason:Filesystem error
***********************************************************************************************************************************
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=429723768106311&id=1630653.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=7jctwvisz_114#SYMPTOM
postupg:
The Database has been upgraded from 11.2.0.2 to 11.2.0.4. Upgrade completed successfully but the OWB component is not upgraded and showing version 11.2.0.4
Solution:
Login as sysdba and execute below scripts
execute the script $ORACLE_HOME\owb\UnifiedRepos\clean_owbsys.sql
execute the script $ORACLE_HOME\owb\UnifiedRepos\cat_owb.sql
***********************************************************************************************************************************
SQL> alter database open;
alter database open
*
ERROR at line 1: --> create textcontrolfile
ORA-01190: control file or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '+DATA/t1/datafile/system_01.dbf'
***********************************************************************************************************************************
ERROR at line 1:
ORA-38784: Cannot create restore point 'SNAPSHOT_STANDBY_REQUIRED_11/13/2009
11:18:18'.
ORA-38786: Flash recovery area is not enabled.
To enable the Flash Recovery area
QL> alter system set db_recovery_file_dest_size = 2G;
System altered.
SQL> alter system set db_recovery_file_dest='/u01/Stage11g/flash_recovery_area/STANDBY11g';
System altered.
***********************************************************************************************************************************
RMAN-06094: datafile 1 must be restored
SQL> startup nomount
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device
Additional information: -1895825408
Additional information: 1
sol:increaase kernel.shmall = 4194304
sysctl -p
http://padmavyuha.blogspot.in/2010/12/configuring-shmmax-and-shmall-for.html
***********************************************************************************************************************************
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORA-15097: cannot SHUTDOWN ASM instance with connected client (process 5476) --> shut down the database instance first
http://dbasoumya.blogspot.in/2015/02/alert-mail-script-for-checking-oracle.html
https://communities.bmc.com/docs/DOC-9942 --shell
http://tutorial-sql-databases.blogspot.in/2014/09/manual-upgrades-to-oracle-database-12c.html --Manual upgradation
http://allthingsoracle.com/upgrading-a-database-using-recovery-manager-rman-duplicate-command-in-oracle-12c/ -- Manual upgradation
http://sandeepnandhadba.blogspot.in/2014/12/oracle-golden-gate-12-bidirectional.html
http://orcltechnology.blogspot.in/2016/03/upgrading-oracle-database-11204-to-12101.html --upgradation
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory --> cd $ORACLE_HOME/bin/ -->relink
inhttp://localhost:5500/em
OC4J Configuration issue. /opt/oracle/prod -->#127.0.0.2 myhost.domain.local myhost
http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/241652.htm#o --emctl
*ORA-01078: failure in processing system parameters -->
*ORA-29701: unable to connect to Cluster Synchronization Service --> ./crsctl start resource ora.cssd (or) https://dbamind.wordpress.com/2014/01/29/ora-29701-unable-to-connect-to-cluster-synchronization-service/
http://myoracleproduct.blogspot.in/2013/11/oracle-goldengate-replication-oracle-to.html --goldengate
Listerner purge --https://samadhandba.wordpress.com/2011/03/07/emptyremove-oracle-listener-log-files/
http://allappsdba.blogspot.in/2012/04/scripts-related-to-temp-tablespace.html --temp
12c--http://db12c.blogspot.in/2013/10/clone-pluggable-database-to-remote.html
12c--https://yasinyazici.wordpress.com/2014/11/19/clone-pluggable-database-to-another-container-database-over-the-network/
http://www.pro-oracle.com/2014/10/oracle-database-resolving-library-cache.html
https://orainternals.wordpress.com/2009/06/02/library-cache-lock-and-library-cache-pin-waits/
https://dbacatalog.wordpress.com/2014/10/20/ora-04021-timeout-occurred-while-waiting-to-lock-object/
ORA-00059: maximum number of DB_FILES exceeded ---> alter system set db_files=150 scope=spfile;
https://sachinichake.wordpress.com/2013/05/08/step-by-step-golden-gate-configuration/
ORA-12162: TNS:net service name is incorrectly specified --> export ORACLE SID
ORA-04021: timeout occured while to lock object
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor -->reason for this is that the database instance has not been started
ORA-12541: TNS:no listener -->start the listener
ORA-12154: TNS: could not resolve the connect identifier specified --> reson user entered the wrong connect identifier
ORA-01555: snapshot too old: rollback segment number --> ALTER system SET undo_retention=10800;
*ORA-01194: file 1 needs more recovery to be consistent --->
*ORA-01110: data file 1: ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\DBTEST\SYSTEM01.DBF’ -->recover database using backup controlfile until cancel; -->ALTER SYSTEM SET "_allow_resetlogs_corruption"= TRUE SCOPE = SPFILE; & ALTER SYSTEM SET undo_management=MANUAL SCOPE = SPFILE; & alter database datafile 7 offline drop;
https://blogs.oracle.com/optimizer/entry/explain_adaptive_cursor_sharing_behavior_with_cursor_sharing_similar_and_force
ORA-03135: connection lost contact
ORA-01178: file 6 created before last CREATE CONTROLFILE, cannot recreate
ORA-01190: control file or data file 1 is from before the last RESETLOGS
ORA-01152: file 1 was not restored from a sufficiently old backup -->recover database using backup controlfile until cancel or recover database until cancel using backup controlfile;
-->aply-->alter database open resetlogs;
ORA-01034: ORACLE not available
sampletns:
---------
@tnsfile
RDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.32.128)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = rdb)
)
)
###############################
samplelistener:
--------------
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = rdb)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
)
)
RDB =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = sample.com)(PORT = 1521))
)
)
##############################
11gpfile:
---------
cpr.__db_cache_size=197132288
cpr.__java_pool_size=4194304
cpr.__large_pool_size=4194304
cpr.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
cpr.__pga_aggregate_target=251658240
cpr.__sga_target=369098752
cpr.__shared_io_pool_size=0
cpr.__shared_pool_size=155189248
cpr.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/cpr/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/cpr/control01.ctl','/u01/app/oracle/fast_recovery_area/cpr/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='cpr'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4196401152
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=cprXDB)'
*.memory_target=620756992
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
##########################################
sfms.__db_cache_size=1224736768
sfms.__java_pool_size=16777216
sfms.__large_pool_size=16777216
sfms.__oracle_base='E:\app\administrator'#ORACLE_BASE set from environment
sfms.__pga_aggregate_target=587202560
sfms.__sga_target=1627389952
sfms.__shared_io_pool_size=0
sfms.__shared_pool_size=335544320
sfms.__streams_pool_size=16777216
*.audit_file_dest='E:\app\Administrator\admin\SFMS\adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='E:\app\Administrator\oradata\SFMS\control01.ctl','E:\app\Administrator\oradata\SFMS\control02.ctl','E:\app\Administrator\oradata\SFMS\control03.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='SFMS'
*.db_recovery_file_dest='E:\app\Administrator\flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.db_unique_name='SFMS_KHAR'
*.diagnostic_dest='E:\app\Administrator'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=sfmsXDB)'
*.fal_client='SFMS_KHAR'
*.fal_server='SFMS_BEL'
*.log_archive_config='DG_CONFIG=(SFMS_BEL,SFMS_KHAR,SFMS_NAG,SFMS_KHR)'
*.log_archive_dest_1='LOCATION=G:\archives\sfms VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=SFMS_KHAR'
*.log_archive_dest_2='SERVICE=SFMS_BEL LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_BEL'
*.log_archive_dest_3='SERVICE=SFMS_NAG LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_NAG'
*.log_archive_dest_4='SERVICE=SFMS_KHR LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_KHR'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_dest_state_3='DEFER'
*.log_archive_dest_state_4='DEFER'
*.log_archive_format='%s_%r.%t'
*.memory_target=2204106752
###############################################################
10gpfile:
---------
*.audit_file_dest='/u01/app/oracle/product/10.2.0/db_1/admin/rdb/adump'
*.background_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/rdb/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/control01.ctl','/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/control02.ctl'
*.core_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/rdb/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='rdb'
*.db_recovery_file_dest='/u01/app/oracle/product/10.2.0/db_1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/rdb/udump'
#######################################################
@logfilesize:
-----------
SET LINESIZE 200
COLUMN member FORMAT A50
COLUMN first_change# FORMAT 99999999999999999999
COLUMN next_change# FORMAT 99999999999999999999
col GROUP# for 9
col THREAD# for 9
SELECT l.thread#,
lf.group#,
lf.member,
TRUNC(l.bytes/1024/1024) AS size_mb,
l.status,
l.archived,
lf.type,
lf.is_recovery_dest_file AS rdf,
l.sequence#,
l.first_change#,
l.next_change#
FROM v$logfile lf
JOIN v$log l ON l.group# = lf.group#
ORDER BY l.thread#,lf.group#, lf.member;
##############################################################################
crdb.sql:
--------
create database rdb
datafile '/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/system.dbf' size 400M
sysaux datafile '/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/sysaux.dbf' size 400M
undo tablespace undotbs1 datafile '/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/undo.dbf' size 400M
default temporary tablespace temp tempfile '/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/temp.dbf' size 300M
logfile group 1('/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/redo1.log') size 30M,
group 2('/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/redo2.log') size 30M,
group 3('/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/redo3.log') size 30M;
########################################################
expimp:
-------
1.TRANFER THE DATA FROM ORACLE TO ORACLE
DATABASE LEVEL ENTIRE TO ANTHOER DATABASE
SCHEMA
TABLE
ROW
X SCHEMA WANT TO DUPLICATE IN THE SAME SCHEMA SO CREATE Y EXP X AND IMPORT
$ exp file=full_devdb_sysdate.dump log=full_devdb_sysdate_log.log full=y
exp file=scott_prd_sysdate.dmp log=scott_prd_sysdate.log owner='SCOTT'
exp file=emp_prd_sysdate.dmp log=emp_prd_sysdate.log tables='SCOTT.EMP' statistics=none
exp file=emp_dept10_sysdate.dmp log=emp_dept10_sysdate.log tables='scott.emp' query=\"where deptno=10 \" statistics=none
desired loc file=/u02/emp_prod
buffer to speed up export porcess
it should be 10*avg row level
prafile: list of commanads
new file 1.parfile
userid='/ as sysdba'
file=proddb.dmp
log=prodb.log
full=y
direct=y
buffer=5000
indexes=n
exp parfile=1.parfile
consistent no better to make s ?
=========
reading updation is take placess it will take the data from undo tablespaces
=================================================================IMPORT======================================================================
Take the export and transfer it to another server
scp kanna.dmp oracle@192.168.1.120:/u02
schema
create new user with same name
imp file=kanna.dmp log=imp_kanna.log fromuser='kanna' touser 'kanna2'
table
imp file=kanna.dmp log=kanna.log fromuser='scott' touser='kanna' opt(tables='scott.emp' or tables='emp')
rows
imp file=emp.dmp log=emp_kanna.log fromuser='scott' touser='kanna' tables='emp'
options
======
show=y
imp file=emp_row.dmp log=1.log show=y fromuser='scott' touser='kanna'
if table is already exists
ignore=y
imp file=emp_row.dmp log=2.log fromuser='scott', touser='kanna' ignore=y
oracle skip and continue further
commit=y
=====
AFTER IMPORTING COMMIT WILL ISSUED 30 DATAPUMP
need to understand the error:
ORA-01102: cannot mount database in EXCLUSIVE mode
***********************************export multiple table and imp multiple tables************************
exp file=f1.dmp log=f1.log tables='SYS.T1','SYS.T2'
imp file=f1.dmp log=f1.log fromuser='SYS' touser='PUSR'
datapump:
---------
col owner for a20
col directory_path for a60
set lines 150
set pages 999
select * from dba_directories;
@objcount:
------------
select owner,object_type , count(*) from dba_objects where status='INVALID' group by object_type,owner;
select distinct object_type,count(*),status from dba_objects where owner='<>' group by object_type,status;
sql> !mkdir /u02/dpdir
sql> create directory dpdir as /u02/dpdir
$expdp directory=dpdir dumpfile=1.dmp logfile=1.log full=y
sysdba
SQL>grant read,wirte on directory dpdir to kanna
tablspace leve posible
select * from dba_datapump_jobs;
expdp help=y
attach:
expdp directory=dpdir dumpfile=1.dmp logfile=1.log full=y
expdp attach=sys_export_full_01
/ as sysdab
contl+c
export> exit
expdp attach='jobname'
export>status
compression:
======
content data and metadata
======
estimate: calate and perform exp
========
estimate only only calculate
============
exclude: shema having 100 tables u dont want to exp so u can use even view etc
=====
parlel: 10 process will take care of u r exp
======
version:
=======
9i exp imp on 10g lower to higher
normal exp imp not possible the above
exp 11g imp into 10g
addfile:
======
we can add anthoer dumpfile
continue
=======
kill_job
========
expdp: u can pauase the job continue later
networklink:
------------
- Create user on SOURCE db to use for network link in TARGET database.
CREATE USER ARTISDBA IDENTIFIED BY "Password123$";
GRANT DBA TO ARTISDBA;
- Create Database link on target
CREATE DATABASE LINK SERVICE_NAME CONNECT TO ARTISDBA IDENTIFIED BY "Password123$" USING 'SERVICE_NAME';
- Copy TNSNAMES entry for source database to target's tnsnames.ora file.
- Create directory in TARGET to use for your logfiles.
CREATE DIRECTORY dumpdir AS '/orabkup/expdp';
GRANT READ,WRITE ON DIRECTORY dumpdir to PUBLIC;
- Run import job on TARGET. You parallelize the job to make it faster.
impdp parfile=impdp.par
PARFILE contents:
DIRECTORY=dumpdir
NETWORK_LINK=SERVICE_NAME
SCHEMAS='TEST'
PARALLEL=4
LOGFILE=impdp_from_service_name.log
TABLE_EXISTS_ACTION = {SKIP | APPEND | TRUNCATE | REPLACE}
As the name implies, table_exists_action is used in impdp when the table already exists in the database where the import is being executed.
table_exists_action=skip: This says to ignore the data in the import file and leave the existing table untouched. This is the default and it is not a valid argument if you set content=data_only.
table_exists_action=append: This says to append the export data onto the existing table, leaving the existing rows and adding the new rows from the dmp file. Of course, the number and types of the data columns must match to use the append option. Just like the append hint, Oracle will not re-user any space on the freelists and the high-water mark for the table will be raised to accommodate the incoming rows.
table_exists_action=truncate: This says to truncate the existing table rows, leaving the table definition and replacing the rows from the expdp dmp file being imported. To use this option you must not have any referential integrity (constraints) on the target table. You use the table_exists_action=truncate when the existing table columns match the import table columns. The truncate option cannot be used over a db link or with a cluster table.
table_exists_action=replace: This says to delete the whole table and replace both the table definition and rows from the import dmp file. To use this option you must not have any referential integrity (constraints) on the target table. You use the table_exists_action=replace when the existing table columns do not match the import table columns.
expdp directory=EXP_IMP_DIR dumpfile=expdp_BR_%u.dmp logfile=expdp_BR.log tables=SFMSBR.MTB_MSG_TXT_BR filesize=2G parallel=4
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL.log filesize=2G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL_1.log filesize=10G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL_1.log filesize=10G FULL=Y
http://artisdba.blogspot.in/2011/04/data-pump-impdp-via-network-link.html
expmultipledir:
---------------
CREATE OR REPLACE DIRECTORY TEST_DIR1 AS '/software_dump/11gR204/dbbackup/mpesa_platform_bkp/test1';
CREATE OR REPLACE DIRECTORY TEST_DIR2 AS '/software_dump/11gR204/dbbackup/mpesa_platform_bkp/test2';
expdp SCHEMAS=MPESA_PLATFORM DUMPFILE=TEST_DIR1:MPESA_PLATFORM_1%u.dmp,TEST_DIR2:MPESA_PLATFORM_2%u.dmp FILESIZE=100M LOGFILE=TEST_DIR1:expdp_log JOB_NAME=expdp_Mpesa parallel=2
http://www.linkedin.com/groups/Multiple-EXPDP-Directories-77941.S.5849421326418194436
@expcheck
----------
select sid, serial#, sofar, totalwork,(sofar/totalwork) * 100 done,
dp.owner_name, dp.state, dp.job_mode
from gv$session_longops sl, gv$datapump_job dp
where sl.opname = dp.job_name and sofar != totalwork;
##################################################################################
@catalog:
--------
RECOVERY CATALOG
Is is a separte database in which u r going maintain rman backup information this info will store in control file. backup info of multiple db will store
and if u lost control file of target db it will help to recover db
Backup information of multiple database will store
back color is target white is recovery catlog db
1.create tablespace rmantbs datafile '/u01/ora10g/rcatdb/rmantbs01.dbf' size 100m
2.create user rman_rc identified by rman_rc default tablespace rmantbs temporary tablespace temp;
3.Grant connect,resource,recovery_catalog_owner to rman_rc
4.$ rman catalog rman_rc/rman_rc
5.create catalog; =====>once u issue tables view will be created we can see those after connecting to rman_rc user. back up info store in these tables
6.conn rman_rc/rman_rc
===========
to target database block color
cd oracle_home/network/admin/tnsname.ora
service_name =listername(rcatdb)
tnsping rcatdb 10:mis
configure the tns names.ora
rman target /catlog rman_rc/rman_rc@rcatdb
RMAN>register database (this info will store in rcatdb)
waytotakebkp:
------------
rman target /catlog rman_rc/rman_rc@rcatdb
RMAN> backup database plus archive;
========From catdb side to we can connect to target db===========
rman target sys/oracle@ROD catalog pusr/pusr@OD
RMAN>BACKUP DATABASE PLUS ARCHIVELOG;
#########################################################################################
RMAN CLOING:
COLOING IS PROCESS OR REPLICATING EXISTS DATABASE IN ANOTHER SERVERS
dp or exp imp smaller database if u r db is 10 tb or 20 tb in case we need to go rman cloning
refreshing vs cloning
some set of scheman or tables copying entire db it is cloning
NOTE:The server os vesion the databse version should be same
aix 64 aix 64
10g 10g
1 db white(prod)
2.test black (test)
test block (prod) 8
==================
#install 11 g
white:
=====
1.create pfile from spfile
$ scp initprod.ora oracle@192.1.23.34: /u01/oacle_home/dbs/inittestdb.ora black: change the name in in pfile in testdb
add 2 perameters
1.db_file_name_convert
2.log_file_name_convert
log_archive_dest crated directry also
create nessary directories
on the production server where redo,data exsits /u01/oradata/prod
/u01/oradata/test
orapwd file=orapwprodb password=sys123 force=y
$scp orapwprodb oracl@192.1.23.34: /u01/oacle_home/dbs/orapwtestdb
both side configure lister and tnsnames
creating lister and tns
invoke vnc create listner
tns : testdb
tns :prodb
vnc invoke
$ps -ef | grep tns
if listner not up and running start listner
lsnctl stop listner
vi listner
sid =proddb
tnsping prodb tnsping prodb
tnsping tesdb tnsping testdb
shut immediate
startup mount
rman target /
RMAN> backup database plus archivelog;
store backup peices in some location create same direcories same location 40
TAKE FULL RMAN BACKUP
Pieces handled /u01/jdld/ mkdir -p /u01/jdld/
scp *.bkp oracle@192.168.120 test side invoke rman
export oracle_sid=testdb
sqlplus / as sysdba
SQL>STARTUP NOMOUNT
rman target sys/sys@123@test auxiliary sys/sys123@testdb
RMAN>duplicate target database to testdb nofilenamecheck
V$BACKUP_SET
RC_BACKUP_SET
#############################################################################################################
CREATE TABLESPACE:
=================
create tablespace mytbs
datafile '/u02/ora10g/prod/mytbs01.dbf' size 50m
autoextend on maxsize 200m
extent management local / dictionary
segment space management auto / manual
inittrans 1 maxtrans 255
pctfree 20 pctused 40
initial 1m next 5m
pctincrease / uniform / autoallocate
minextents 1 maxextents 500
logging / nologging
blocksize 8k; - this is optional
CHECK TABLESPACE INFO:
=====================
select allocation_type,extent_management,contents from dba_tablespaces where tablespace_name='MYDATA';
@freedata:
---------
col file_name for a50
select file_name,sum(bytes)/1024/1024 "ACTU",autoextensible,sum(maxbytes)/1024/1024 "MAX" from dba_data_files where tablespace_name='&tbs' group by file_name,autoextensible order by 1;
DATABASE SIZE:
=============
1 - The size of the Oracle database files can be computed several ways:
-- get database size from v$datafile:
select round((sum(bytes)/1048576/1024),2) from v$datafile;
-- get Oracle database size from dba_data_files:
select
"Reserved_Space(MB)", "Reserved_Space(MB)" - "Free_Space(MB)" "Used_Space(MB)","Free_Space(MB)"
from(
select
(select sum(bytes/(1014*1024)) from dba_data_files) "Reserved_Space(MB)",
(select sum(bytes/(1024*1024)) from dba_free_space) "Free_Space(MB)"
from dual
);
TABLE_SIZE:
===========
2 - The size of the sum of table extents
select
segment_name table_name,
sum(bytes)/(1024*1024) table_size_meg
from
user_extents
where
segment_type='TABLE'
and
segment_name = 'MYTAB'
=====================
select sum(bytes/1024/1024/1024) from dba_data_files;
ENABLE/DISABLE AUTOEXTEND:
=========================
alter database datafile ‘/u02/prod/mytbs01.dbf’ autoextend on maxsize 100m;
alter database datafile ‘/u02/prod/mytbs01.dbf’ autoextend off;
RESIZE DATAFILE:
===============
alter database datafile ‘/u02/prod/mytbs01.dbf’ resize 20m;
ADD DATAFILE:
============
alter tablespace mytbs add datafile ‘/u02/prod/mytbs02.dbf’ size 10m;
RENAME TABLESPACE:
=================
alter tablespace mytbs rename to mydata;
========
FREE
COLUMN pct_free FORMAT 999.99 HEADING "% Free"
COLUMN name FORMAT A16 HEADING "Tablespace Name"
COLUMN mbytes FORMAT 99,999,999 HEADING "Total MBytes"
COLUMN used FORMAT 99,999,999 HEADING "Used Mbytes"
COLUMN free FORMAT 99,999,999 HEADING "Free Mbytes"
BREAK ON REPORT
COMPUTE SUM OF mbytes ON REPORT
COMPUTE SUM OF free ON REPORT
COMPUTE SUM OF used ON REPORT
SELECT fs.tablespace_name name, df.totalspace mbytes, (df.totalspace - fs.freespace) used,
fs.freespace free, 100 * (fs.freespace / df.totalspace) pct_free
FROM (SELECT tablespace_name, ROUND(SUM(bytes) / 1048576) TotalSpace FROM dba_data_files GROUP BY tablespace_name ) df,
(SELECT tablespace_name, ROUND(SUM(bytes) / 1048576) FreeSpace FROM dba_free_space GROUP BY tablespace_name ) fs
WHERE df.tablespace_name = fs.tablespace_name(+);
==========
.201
SQL> select file_name,sum(bytes)/1024/1024/1024,sum(maxbytes)/1024/1024/1024 from dba_data_files group by tablespace_name,file_name having tablespace_name='NEFT_ARCH_NDX';
========================
chktbs:
-------
col "NAME" format a30
set lines 140
set pages 1000
select a.tablespace_name "NAME",(b.totalspace - a.freespace)"USED SPACE",
a.freespace "FREE SPACE",b.totalspace "TOTAL SPACE",round(100 * (a.freespace / b.totalspace)) "% FREE"
from
(select tablespace_name,sum(bytes)/1024/1024 TotalSpace
from dba_data_files
group by tablespace_name) b,
(select tablespace_name,sum(bytes)/1024/1024 FreeSpace
from dba_free_space
group by tablespace_name) a
where b.tablespace_name = a.tablespace_name(+)
and b.tablespace_name like upper('%&tablespace_name%')
order by 5
/
=================
@alltbs
SELECT /* + RULE */ df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;
========================
@temptbs
select FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE from dba_temp_files where TABLESPACE_NAME='TEMP';
=============freetbs====================
@privs
=========
SEE PERMANENT DEFAUT TABLESPACE:
===============================
select default_tablespace,temporary_tablespace from dba_users where username=’SCOTT’;
# To check default permanent tablespace and temporary tablespace
================================================================
select property_name,property_value from database_properties where property_name like ‘DEFAULT%’;
# To change default permanent tablespace
========================================
alter database default tablespace mydata;
# To change default temporary tablespace
========================================
alter database default temporary tablespace mytemp;
# To check system privileges for a user:
========================================
select privilege from dba_sys_privs where grantee='&SCOTT';
# To check object level privileges
==================================
select owner,table_name,privilege from dba_tab_privs where grantee='&SCOTT';
# To check roles assigned to a user
===================================
select granted_role from dba_role_privs where grantee='&SCOTT';
# To check permissions assigned to role
=======================================
select privilege from role_sys_privs where role='&MYROLE';
select owner,table_name,privilege from role_tab_privs where role=’MYROLE’;
select granted_role from role_role_privs where role='MYROLE';
RMAN BACKUP:
===========
23:00
cold and hot ==>file level
export ====>table level
rman ===>block level
adv ===> speed,size reduced
contact bit map in datafile header
parallelsim: 10 process datafile scan across
duplexing archive: if want to maintain two location if one corrupted oracle take care
detection : if data file curupted
validating : validation will give rman
controlfile autobackup on :
along with database back if u want to take control file backup
autoback up: will go in to tap or disk
DISK PARLLELISM: at a time 3 data file will scan
components of rman:
1. RMAN executable file ===> rman prompt
2.target : abc is my database if want to take backup of abc it will become target database
3. auxillary database: colnned copy of target
4. recovery catalog :repository of it will store the backup of database
5. media manger layer:
configuration parameters:
========================
show all; (; mandatory)
1. retention pocily:
redundency: how many back to there def 1
recovery window: how many days
RMAN> CONFIGURE RETENTION POLIICY TO RECOVERY WINDOW OF 90days
RMAN> configure channel device type disk format '/u01/rman_bkp/%T_%D_%U';
redundency 3
2. configure backup optimization defalut off:
file level bkp 10 gb back of yesterday. today datafile not changed (not use realtime)
300 5 par
sbt_tape
flash recovery area: it is a area when recovery req file will be there
backup piece: it is a file phy
backup set: group of backup pieces logical
how to increse the size of flash recovery:
SQL> show parameter db_recovery_file_dest_size
name type value
db_recovery_file_dest_size big interger 2G
SQL> alter system set db_recovery_file_dest_size=10G scope=both;
@archdestination
----------------
mkdir /u02/archives
SQL> alter system set log_archive_dest_1='location=/u02/archives' scope=both;
alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST';
------------------------------------------------------------------------------------
RMAN> BACKUP FORMAT='/U02/FULL_PRODB_%T.BKP' DATABASE PLUS ARCHIVELOG T IS THE REFERENCE NUMBER IT STORES THE TIMESTAMP WHAT TIME BACKUP TAKEN
10g compressed backup:
size of the backup peice reduced
RMAN>backup as compressed backupset database plus archivelog
14 to 2 gb
RMAN> list backup
the info stored in control files from control file this info will get
bskey typeofbackup size disk howmuchtimetaken(elapased) completedtime
due to some space issue u delted os level
rm yesterday directory
even u tho u deleted but rman dont' know if u list backup it will give u deleted backup all so
RMAN>Crosscheck backup ======verification of cmparing to 2 os level and db level
it make as expired
RMAN> delete expired backup;
it will ask promt
RMAN>delete noprompt expired backup;
RMAN>CROSSCHECK ARCHIVELOG ALL;
RMAN> DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
RMAN> REPORT OBSOLETE;
RMAN> DELETE NOPROMPT OBSOLETE;
delete expired archivelog all;
RMAN> BACKUP AS COPY DATABASE; FILE LEVEL BACKUP SIMILER TO HOT AND COLDBACKUP
AFTER TAKING BACKUP
RMAN>RESTORE DATABSAE VALIDATE;
LAST BACKUP OF THE PEICES WILL BE VALIDATED
RMAN> VALIDATE BACKUPSET 23;
BEFORE BACKUP ONLY WE CAN CHECK THE DATABSE
==========
RMAN>BACKUP VALIDATE DATABASE ARCHIVELOG ALL; DONT TAKE BACKUP JUST VALIDATE
LIST BACKUP BY FILE; # shows backup sets, proxy copies, and image copies
LIST COPY; # shows only disk copies
******************************************************** RECOVERY *****************************************************************
******************************************************** *****************************************************************
remove datafile at os level
run block series of steps execution
RMAN> run
{
sql 'alter tablespace users offline';
restore tabelspace users;
recover tablespace users;
sql 'alter tablespace users online';
}
******************************************************** incremental *******************************************************
today 100 gb tomorw 110 next 120
today 1 hr taken
tomorrow more then one hour
level 0 full backup
rest of days incremental backup
sunday full backup
every day incremental backup
*****************************************
today 500
tomorr 510 i take only 10 of backup
1. diffential
2. cumilative
both have level 0 and 1
fist time level 0
backup incremetal levelo 0 database plus archivelog; differntial by default
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE PLUS ARCHIVELOG; FAST
T
RMAN> BACKUP CUMULATIVE INCRENTAL LEVEL 0 DATABSAE PLUS ARCHVIVELOG;
10G BLOCK CHAGE TRACING
IF BLOCK CHANGE IT PLACE IN A FILE WHEN U INITIATE RMAN TO GO TO THAT FILE
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/U02/TRACK.F';
CTWR BACKGROUND PROCESS
===========SHOW=================
SHOW CHANNEL
SHOW DEFAULT DEVICE TYPE
SHOW BACKUP OPTIMIZATION
============MONITERING RMAN======================
V$PROCESS Identifies currently active processes.
V$SESSION Identifies currently active sessions. Use this view to determine
which database server sessions correspond to which RMAN allocated channels.
V$SESSION_LONGOPS Provides progress reports on RMAN backup and restore jobs.
V$SESSION_WAIT Lists the events or resources for which sessions are waiting.
V$BACKUP_SYNC_IO Displays rows when the I/O is synchronous to the process (or thread on some platforms) performing the backup
v$DATABASE_BLOCK_CURRPUTION : will update the rman errors
=================CHANGE THE LOCATION========================
=================****************==================
You can view the current configuration values of all the RMAN parameters that you change from
their default values by using the V$RMAN_CONFIGURATION view
======================================================@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@===============================================================
@level1
==============
run
{
sql 'alter system switch logfile';
sql 'alter system switch logfile';
sql 'alter system switch logfile';
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
allocate channel c5 device type disk;
allocate channel c6 device type disk;
allocate channel c7 device type disk;
allocate channel c8 device type disk;
backup as compressed backupset incremental level 1 database format '/u01/rman_bkp/level1_%d_%T_%s_%p' TAG='level1D';
####backup format '/u01/rman_bkp/level1_arch_%d_%T_%s_%p' archivelog all delete input TAG='level1_arch_bkp';
backup format '/u01/rman_bkp/level1_arch_%d_%T_%s_%p' archivelog all TAG='level1_arch_bkp';
delete noprompt archivelog all completed before 'sysdate-6';
backup current controlfile format '/u01/rman_bkp/ctrl_%d_%s.ctl';
}
==================================
rman is a server manged backup
RMAN> backup tablespace system;
it will take backup of backup set control&spfile even control file auto backup off;
RMAN> backup tablespace sysaux;
it will take only one backup piece genarated. but if you make control file auto backup on then it takes control&spfile;
if the control file autobackup is on and if you change any strutural change to db it take backup automatically.
controfile autobackup off;
RMAN>backup database plus archivelog; it take cotrol&spfile bcz we included system tablespace;
crash database
shut abort;
remove file at physical localtions CRD
SQL>startup
error 205 error identifying control file check alert log
SQL>shutdown abort
RMAN> startup nomount;
RMAN> restore controlfile form '004LM'; ---YOU MUST KNOW THE PIECE NAME
RMAN> alter database mount;
rman> restore database;
RMAN>recover database;
RMAN>alter database open resetlogs;
configure control file autobackup on:
RMAN>backup database plus archivelog; --control&spfile takes
quit
SQL>shutdown abort;
delete RCD FILE
SQL> startup
error
HERE DBID REQ
RMAN> SET DBID 234546 ---FROM BACKUP U GET DBID APPENDS
RMAN>startup nomount;
Oracle instance started
RMAN> restore controlfile from autobackup;
RMAN> alter database mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open resetlogs;
RMANBACKUP SCRIPTS:
==============
BACKUP VALIDATE:
===============
connect target /
run
{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
BACKUP VALIDATE CHECK LOGICAL database;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
BACKUP ARCH:
===========
connect target /
run
{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
backup as compressed backupset
format '/ora_backup/%d_arc_t%t_s%s_p%p.bkp'
filesperset=8
(archivelog all delete input);
release channel ch1;
release channel ch2;
release channel ch3;
}
BACKUP FULL:
===========
connect target /
set snapshot controlfile name to '/oracle/bkp/controlfile_snapshot.ctl';
run
{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
allocate channel ch5 type disk;
backup as compressed backupset
format '/ora_backup/%d_dbf_t%t_s%s_p%p.bkp'
filesperset=4
database;
sql 'alter system archive log current';
release channel ch1;
release channel ch2;
allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup as compressed backupset
format '/ora_backup/%d_arc_t%t_s%s_p%p.bkp'
filesperset=4
(archivelog all delete input);
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
}
run
{
crosscheck backup;
delete noprompt obsolete;
}
BACKUP INCR_DIFF:
================
connect target /
set snapshot controlfile name to '/oracle/bkp/controlfile_snapshot.ctl';
run
{
crosscheck backup;
delete noprompt obsolete;
}
run
{ allocate channel ch1 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch2 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch3 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch4 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch5 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch6 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
BACKUP as compressed backupset INCREMENTAL LEVEL 1 DATABASE include current controlfile filesperset=8;
sql 'alter system archive log current';
backup as compressed backupset
format '/ora_backup/%d_arc_t%t_s%s_p%p.bkp'
filesperset=6
(archivelog all delete input);
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;
}
@DATAGAURD:
==========
DATA GAURD CONFIGURATION :
====================================
1. check archive log is on
SELECT force_logging FROM v$database;
2. SQL>alter database force logging; {redo entries will genarated} if the user connected issued dml and nologging
3. SQL>select group#,members,sum(bytes/1024/1024) from v$log group by group#,members
4. SQL>alter database add standby logfile group 4 '/u01/oradata/prodb/redo04.log' size 50m;
SQL>alter database add standby logfile group 5 '/u01/oradata/prodb/redo05.log' size 50m;
SQL>alter database add standby logfile group 6 '/u01/oradata/prodb/redo06.log' size 50m;
5. SQL>select type from v$logfile;
6. SQL>show parameter db_unique_name ===========>should show the instance name {database name should same in both primary and stand by}
7. SQL>alter system set log_archive_config='DG_CONFIG=(proddb,standb)' scope=both;
8. SQL>alter system set log_archvive_dest_1='location=/u02/archive VALID_FOR(ALL_LOGFILES,ALL_ROLES) db_unique_name=prodb' scope=both
9. SQL>alter system set log_archive_dest_2='SERVICE=standb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=stndb' scope=both
10.show paramter log_archive_dest_state_1
11.show paramter log_archive_dest_state_2 should be enable both if not alter system set log_archive_dest_1 eable
12. alter system set fal_server='standb' scope=both
13. alter system set fal_client='prodb' scope=both
14.alter system set standby_file_management=auto scope=both
15.create pfile from spfile
16. scp /u01/dbs/initprodb.ora oracle@19.168.1.11:/u01/initstandb.ora ======>check pfile copied or not
17. open pfile
18 above audit not required
19. a dump and control file, flash recovery
dbname same
servicename, db_unique_name prodb
add db_file_name_convert='/u01/oradata/proddb','/u01/oradata/standb'
log_file_name_convert='/u01/oradata/proddb','/u01/oradata/standb'
db_unique_name='standb'
create nesseary direcoties
configure listner
====
configure tnsnames
export oracle_sid=standb
startup nomount
RMAN> duplicate target database for standby from active database nofilenamecheck;
select name,open_mode from v$database;
ps -ef|grep mrp
alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;
select max(sequence#) from v$log_history =========> sink where both r
select name,database_role from v$database evn instace name also\
show parameter log_archive_dest2
and
select name,database_role,protection_level from v$database
alter database recovery managed standby database cancel
alter database recover managed standby database using current logfile disconnect from session; ========>realy time apply
suppose primary side i recreated passwordfile sys123 with out inform created then not scp
select sequence#,archived,applied from v$archived_log achive=== logshipping applied===mrp
Q;how to check logship and logapply are runing
what to do if logshipping not applied (1.set alert log file both primary and secondery)
2.if alter log 1034 show error in alert log file then copy the possword file primary to stand by
3.if alter log show any error related to network then check listners are up and runing both sides and check the tnsping both side
if alter log shows heart beat fail error then check the value of db_unique_name paramer both primary and standby
what to do if log apply not done?
check mrp process is up and running or not
some time even mrp upandrunnig apply not work in both cases stop and start mrp
@drill
swithover:
+++++++++
select database_role,switchover_status from v$database
AT PDC SITE:
===========
1) alter database commit to swithover to physical standy with session shutdown
2) shut immediate;
3) startup mount;
AT ODC SITE:
============
1)alter database recover managed standby cancel;
2)alter database commit to switchover to primary
3)shut immediate;
4)startup
5)alter database recover managed standby database disconnect from session;
2:29
V$DATAGUARD_STATS
=================
displays how much redo data generated by the primary database is not yet available on the standby database,
showing how much redo data could be lost if the primary database were to crash at the time you queried this view.
You can query this view on any instance of a standby database in a Data Guard configuration. If you query this view on a primary database,
then the column values are cleared.
v$recovery_progress can be used to monitoring database recovery operations, and gives us access to information
like: Last Applied Redo, Active Apply Rate, Average Apply Rate, Apply Time per Log and a few more.
The item we are interested in is “Last Applied Redo” and the value of the “TIMESTAMP” column.
The value should be very close to or match the value of LAST_TIME column from v$standby_log view.
SQL> select START_TIME,TYPE, ITEM,UNITS,SOFAR,TIMESTAMP
2 from v$recovery_progress where ITEM='Last Applied Redo';
START_TIME TYPE ITEM UNITS TIMESTAMP
------------------- ---------------- ------------------- --------- -------------------
2013-04-17 22:46:26 Media Recovery Last Applied Redo SCN+Time 2013-04-18 20:26:16
v$Managed_standby
=================
V$MANAGED_STANDBY displays current status information for some Oracle Database processes related to physical standby databases in the Data Guard environment.
This view does not persist after an instance shutdown.
v$datagaurd_config
=================
Lists the unique database names defined with the DB_UNIQUE_NAME and LOG_ARCHIVE_CONFIG initialization parameters.
v$log_history
=============
V$LOG_HISTORY displays log history information from the control file.
v$archive_dest_status
=====================
V$ARCHIVE_DEST_STATUS displays runtime and configuration information for the archived redo log destinations.
The information in this view does not persist across an instance shutdown.
=======================convert snapshto database to physical standby============
alter database convert to physical standby;
alter database convert to snapshot standby
======================prerequests============================
1. Ensure Dbvisit Standby is no longer scheduled on the primary and standby servers.
2. Ensure there is enough space on the standby server to receive the primary redo logs, and any new archive logs created.
3. Ensure that the standby database is in archive log mode.
4. Ensure there is sufficient space on the primary server for complete backups of the redo logs. Required space will be double the current redo log space requirements.
5. The standby database must be up to date before starting the switchover process. Dbvisit Standby will check if this is the case and will not initiate the switchover if the standby database is not up to date.
6. Oracle database parameters db_file_name_convert and log_file_name_convert must be set to default values (null strings) in the primary database prior to switchover.
If either of the parameters are set to non null values in an Oracle database version 11 and higher that uses an spfile (not pfile), Dbvisit will automatically reset both parameters to default values during Graceful Switchover so no action is required.
In case a primary database has version is 10 or lower, or a database uses a pfile, Graceful Switchover will terminate, and instructions to reset both parameters and restart the primary database will be displayed.
4.ALLOCATE CHANEL C1 DEVICE TYPE DISK FORMAT '/U01/RMANBKP';
BACKUP INCREMENT FROM SCN 102;
5.ALTER DATABSAE CREATE STANDBY CONTROLFILE AS ='/PATH';
6.SCP BACKUP AND CONTROL TO STAND BY 1.SELECT CURRENT_SCN FROM V$DATABASE
2.ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
3.SHUT IMMEIDATE
7.REPLACE CURRENT CONTROLFILE WITH 'PATH';
8.STARTUP MOUNT
9.ALTER DATABASE MOUNT STANDBY DATABASE
10.CATALOG STARTWITH 'PATH'
11.RECOVER DATABASE;
12.ALTER DATABASE RECOVER MANAGED STANDBY DATABSAE DISCONNECT FROM SESSION
REGISTER REDOLOGS AT STANDBY:
============================
ALTER DATABASE REGISTER LOGFILE '/physical_standby1/thread1_dest/arcr_1_7.arc';
standby side:
============
dbname our primary
dbfilename convert pri to stand
falclient=stand
falserver=primay
controlfile change to stand
dst1 dst2 unique name change
========================================================@zip@=====================================
1.compress
compress abc ===>abc.z
uncompress abc.z
2. zip <filename.zip> actfile ===>abc.zip
unzip abc.zp
3.gzip abc ===>abc.gz
gunzip abc.gz
gzip `ls -ltr | grep -w "Feb" | awk '{print $NF}'`
4.tar -cvf abc.tar foldername ===>abc.tar
tar -czvf archive.tar.gz
tar -xvf abc.tar for 3&4 you can give the destination
===============================================STATISTICS====================================================
analyze table emp estimate statistics;
exec dbms_stats.gather_table_stats('SCOTT','EMP',’’,40);
INDEX
=====
analyze index pk_emp compute statistics;
exec dbms_stats.gather_index_stats(‘SCOTT’,’PK_EMP’);
SCHEMA
=====
exec dbms_stats.gather_schema_stats(‘SCOTT’);
FULLDB
=====
exec dbms_stats.gather_database_stats;
=============================================TUNING================================================
if palntable not available execute below script
@?/rdbms/admin/utlxplan.sql
explain plan set statement_id='abc'
for select *from tablename;
@?/rdbms/admin/utlxpls.sql
explain_plan==
AWR:
===
SQL>@?/rdbms/admin/awrrpt.sql
report type: html
no of days:2
begin snapid
end snapid
reportname: /home/oracle/abc_awrrpt.html
=========================================@ADMIN RAC=============================
srvctl
======
#to see configuration
$srvctl config database -d hrms
#to see status of all instances
$srvctl status database -d hrms -- start or stop
#to see status of specific instance
$srvctl status instance -i hrms -d hrms
#to see all services of database
$srvctl status service -d hrms -- start or stop
#to see status of asm
$srvctl status asm -n lnx01 -- start or stop
#to see status of nodeapps
$srvctl status nodeapps -n lnx01 --start or stop
#to stop listner
$srvctl stop listner -n linx01 --stat or stop
racservice
$srvctl add service -s test -d hrms -r hrms1 -a hrms2 -P basic r=prefer
#to see status of specific service
$srvctl status service -s test -d hrms
#to delete service
$srvctl remove service -s test -d hrms
#to disable enable instance
$srvctl disable instance -d hrms
#to register the database with cluster
$srvctl add database -d crm -o $ORACLE_HOME
#to register the instance with cluster
$srvctl add instance -i crm -d crm -n lnx01
#to ungister the entries
$srvctl remove database -d crm
#to know the configuration of scan listner
$srvctl config scan_listner
#to know the status of scan listner
$srvctl status scan_listner
---------------------------------------------
@racsessions
-----------
select
inst_id,
count(*)
from
gv$session
where
username is not null
group by
inst_id;
----------------------------------------------
crsctl:
======
#to see version of cluster
$crsctl query crs softwareversion
$crsctl query crs activeversion
#to stop cluster
#cd /etc/init.d
#./int.crs stop
or
cd $ORACLE_CRS_HOME/bin
#./crsctl stop cluster
in 11g ./crsctl stop cluster -all
#to know the location of votiong disk
$crsctl query crs votedisk
#to know the location of ocr file
$ocrcheck
#to know olr
$ocrcheck -local
#to disable cluster
$crsctl disable crs
#to know the master node
$ocrconfig -showbackup
#to know the status of all resources that register with cluster
$crs_stat -d
#to dump the content of ocr into a text file
#ocrdump
#to know the number of nodes participating in cluster
#olsnode
#to check the status of cluster
$crsctl check crs
11g $crsctl check crs -all
----------------------------------------
$ crsctl get css disktimeout
CRS -4678: Successful get disktimeout 200 for Cluster Synchronization Services
$ crsctl get css misscount
CRS-4678: Successful get misscount 30 for Cluster Synchronization Services
-------------------------------------------
BACKUP IN RAC:
=============
OCR
$ocrconfig -showbackup
defalut will be $ORA_CRS_HOME/cdata/lnx02/ocr001.ocr
/day.ocr
/week.ocr
ocrconfig -restore $ORA_CRS_HOME/cdata/lnx02/ocr001.ocr
#to take ocrbackup manuall
$ocrconfig -export /opt/ocr.bkp
#to restore ocrbackup manuall
$ocrconfig -import /opt/ocr.bkp
VOTING FILE
===========
#dd if =/dev/sdb5 of=/opt/vote.bkp
#to restore votefile
#dd if=/opt/vote.bkp of=/dev/sdb5
OLR
===
$ocrconfig -showbackup -local
#to take backup of olr
$ocrconfig -local -manualbakup
#to restore olr
$ocrconfig -local -restore <filepath>
===================================DBSIZE===================================
select
"Reserved_Space(MB)", "Reserved_Space(MB)" - "Free_Space(MB)" "Used_Space(MB)","Free_Space(MB)"
from(
select
(select sum(bytes/(1014*1024)) from dba_data_files) "Reserved_Space(MB)",
(select sum(bytes/(1024*1024)) from dba_free_space) "Free_Space(MB)"
from dual
);
==========================KILL===============
alter system kill session '815,4221';
PATH=$PATH:$HOME/bin
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_home
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
==========multipledumps==========
expdp directory=EXP_IMP_DIR dumpfile=expdp_BR_%u.dmp logfile=expdp_BR.log tables=SFMSBR.MTB_MSG_TXT_BR filesize=2G parallel=4
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL.log filesize=2G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_1%u.dmp logfile=expdp_FULL_1.log filesize=10G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL_1.log filesize=10G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL_1.log filesize=10G FULL=Y
=====================
RMANR
set lines 100 pages 100
col STATUS format a9
col min format 999.99
select SESSION_KEY, INPUT_TYPE, STATUS,to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,to_char(END_TIME,'mm/dd/yy hh24:mi')
end_time, round(elapsed_seconds/60,2) mis,round(OUTPUT_BYTES/1024/1024,2) "SizeMB" from V$RMAN_BACKUP_JOB_DETAILS order by session_key;
============
PAD WINDOWS
run
{
shutdown immediate;
startup mount;
allocate channel c1 device type disk;
backup as compressed backupset database format 'G:\Rman_Cold_bkp\SFMS\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'G:\Rman_Cold_bkp\SFMS\ctl_%d_%D_%M_%Y_%s.bkp';
alter database open;
}
======
run
{
shutdown immediate;
startup mount;
allocate channel c1 device type disk;
backup as compressed backupset database format 'G:\Rman_Cold_bkp\NEFT\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'G:\Rman_Cold_bkp\NEFT\ctl_%d_%D_%M_%Y_%s.bkp';
alter database open;
}
run
{
allocate channel c1 device type disk;
backup as compressed backupset database format 'G:\Rman_Cold_bkp\SFMS\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'G:\Rman_Cold_bkp\SFMS\ctl_%d_%D_%M_%Y_%s.bkp';
}
run
{
allocate channel c1 device type disk;
backup as compressed backupset database format 'G:\Rman_Cold_bkp\NEFT\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'G:\Rman_Cold_bkp\NEFT\ctl_%d_%D_%M_%Y_%s.bkp';
}
=============RMANCHECK====================
set lines 100 pages 100
col STATUS format a9
col min format 999.99
select SESSION_KEY, INPUT_TYPE, STATUS,to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,to_char(END_TIME,'mm/dd/yy hh24:mi')
end_time, round(elapsed_seconds/60,2) mis,round(OUTPUT_BYTES/1024/1024,2) "SizeMB" from V$RMAN_BACKUP_JOB_DETAILS order by session_key;
===========================================================
set lines 100 pages 100
col STATUS format a9
col min format 999.99
select SESSION_KEY, INPUT_TYPE, STATUS,to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,to_char(END_TIME,'mm/dd/yy hh24:mi') end_time, round(elapsed_seconds/60,2) mis,round(OUTPUT_BYTES/1024/1024,2) "SizeMB" from V$RMAN_BACKUP_JOB_DETAILS order by session_key;
PDCS3V3:/app/scr #
PDCS3V3:/app/scr #
PDCS3V3:/app/scr #
PDCS3V3:/app/scr # cat long.sql
=========================
set lines 150
select SID, SERIAL#, opname, START_TIME,TOTALWORK, sofar, (sofar/totalwork) * 100 done,
TIME_REMAINING/60 "Re Minute"
from v$session_longops
where totalwork > sofar
AND opname NOT LIKE '%aggregate%';
==================$$$$$$$$$$$$$$$$$$=============
SELECT
opname,
target,
ROUND((sofar/totalwork),4)*100 Percentage_Complete,
start_time,
CEIL(time_remaining/60) Max_Time_Remaining_In_Min,
FLOOR(elapsed_seconds/60) Time_Spent_In_Min
FROM v$session_longops
WHERE sofar != totalwork;
================0000000000000000000 PAD BACKUP 00000000000000000000=================
@echo OFF
set host=%COMPUTERNAME%
set oracle_home=E:\app\Administrator\product\11.2.0\db_1
#set backupstr="SFMS_%host%_%pdate%_%ptime%"
#set backupstr=%backupstr:/=-%
set dirname=Y:\EXPORTBKP
set dirname1=Y:\RMANCOLDBKP
md %dirname1%\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%
set oracle_sid=sfms
expdp 'sys/sys@SFMS as sysdba' DIRECTORY=DATA_PUMP_DIRECTORY DUMPFILE=SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%.dmp LOGFILE=SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%.log full=y
rman target 'sys/sys as sysdba' cmdfile 'H:\RMAN_COLD_BKP_RP\rmancold_sfms' log=Y:\RMANCOLDBKP\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%_rmancold.log
echo User exeuting backup is: %DB_USERNAME% >> Y:\RMANCOLDBKP\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%_rmancold.log
move H:\Rman_Cold_bkp\SFMS\*.BKP Y:\RMANCOLDBKP\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%\
move H:\Rman_Cold_bkp\dpdump\*.DMP Y:\EXPORTBKP\
move H:\Rman_Cold_bkp\dpdump\*.log Y:\EXPORTBKP\
=========^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^================================
@snapshot standby
Steps to convert physical standby to snapshot standby and then again revert it to physical standby
If below parameters are already set then no need for below changes or else set below parameters before start as it should be required for snapshot standby
alter system set db_recovery_file_dest_size=4GB;
alter system set db_recovery_file_dest='PATH;
alter database recover managed standby database cancel;
shutdown immediate;
startup mount;
alter database convert to snapshot standby;
shutdown immediate;
startup;
*/ ----Ash Application team to do their testing once they will finish with their testing follow below step for converting snapshot standby to physical standby ---*/
shutdown immediate;
startup mount;
alter database convert to physical standby;
Shutdown immediate;
startup mount;
alter database recover managed standby database disconnect from session;
catalog device type 'SBT_TAPE' backuppiece 'NEFTDB_03_01_2015_1765.bkp';
=======
RMAN ARCHIVE DELETIONS
delete archivelog until time = 'sysdate-12' backed up 1 times to disk ;
delete archivelog all backed up 1 times to device type SBT;
delete archivelog all completed before 'sysdate';
delete archivelog all backed up 2 times to DEVICE TYPE disk; completed before 'sysdate-1';
delete archivelog all backed up 1 times to DEVICE TYPE disk completed before 'sysdate';
delete archivelog until time 'sysdate' backed up 1 times to disk;
delete archivelog all backed up 2 times to sbt;
run
{
allocate channel t1 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo-MWF.opt)';
delete archivelog all backed up 2 times to device type sbt;
release channel t1;
}
run
{
allocate channel t1 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo-TTS.opt)';
catalog backuppiece 'SFMSDBRPT_04_04_2015_242.bkp';
release channel t1;
}
alter system set log_archive_dest_state_2=DEFER scope=both;
alter system set log_archive_dest_state_3=DEFER scope=both;
============================================
CONVERTING PHYSICAL STANDBY DATABASE TO SNAPSHOT STANDBY DATABASE
http://www.orafaq.com/node/2505
alter system set log_archive_config='DG_CONFIG=(SFMS_BEL,SFMS_KHAR,SFMS_NAG,SFMS_KHR)' scope=both;
alter system set log_archive_dest_4='SERVICE=SFMS_KHR LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_KHR' scope=both;
alter system set log_archive_dest_state_4=DEFER scope=both;
alter system set log_archive_dest_state_4=ENABLE scope=both;
alter database recover managed standby database cancel;
shut immediate;
startup nomount;
alter database mount standby database;
alter database convert to snapshot standby;
alter database open;
shut immediate;
startup nomount;
alter database mount;
alter database convert to physical standby;
shut immediate;
startup nomount;
alter database mount standby database;
NORMAL Standby : ALTER DATABASE RECOVER managed standby database disconnect from session;
REAL-TIME APPLY : ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
SELECT dest_id,max(SEQUENCE#) FROM V$ARCHIVED_LOG where applied='YES' group by dest_id;
select name,open_mode,controlfile_type,database_role from v$database;
SELECT PROCESS, STATUS,sequence# FROM V$MANAGED_STANDBY;
set lines 200
set pages 200
col DEST_NAME for a30
PROD : select dest_id,DEST_NAME,STATUS,DB_UNIQUE_NAME,RECOVERY_MODE,DATABASE_MODE,error from v$archive_dest_status;
PROD : SELECT dest_id,max(SEQUENCE#) FROM V$ARCHIVED_LOG where applied='YES' group by dest_id;
STANDBY : select * from v$dataguard_stats;
=====
DATAGAURD Stopping & Starting Process:
Stopping
1)SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;
Canceling recover operation.
2)ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
3)SELECT NAME, SEQUENCE#, ARCHIVED, APPLIED FROM V$ARCHIVED_LOG;
4)SHUTDOWN IMMEDIATE;
------
Starting
1)STARTUP NOMOUNT;
2)ALTER DATABASE MOUNT STANDBY DATABASE;
3)ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
ALTER DATABASE RECOVER managed standby database disconnect from session;
alter database recover managed standby database cancel;
SELECT dest_id,max(SEQUENCE#) FROM V$ARCHIVED_LOG where applied='YES' group by dest_id;
select DEST_ID,DATABASE_MODE,ERROR,DB_UNIQUE_NAME from v$archive_dest_status;
=================================================
@drerror
set lines 200
set pages 200
col DEST_NAME for a30
select dest_id,DEST_NAME,STATUS,DB_UNIQUE_NAME,RECOVERY_MODE,DATABASE_MODE,error from v$archive_dest_status;
=====================================================
@DRDrill Swicthover
@switchover:
+++++++++
set lines 200
set pages 200
col host_name for a20
select instance_name,host_name,name,open_mode,log_mode,database_role,switchover_status from v$database,v$instance;
AT PDC SITE: it will become standby
===========
1) alter database commit to switchover to physical standby with session shutdown;
2) shut immediate;
3) startup nomount;
4) alter database mount standby database;
5) alter database recover managed standby database disconnect from session;
AT ODC SITE: it will become primary
============
1)alter database recover managed standby database cancel;
2)alter database commit to switchover to primary;
3)shut immediate;
4)startup
swithBack:
++++++++++
AT ODC SITE: this is primary
============
1) alter database commit to switchover to physical standby with session shutdown;
2) shutdown immediate;
3) startup mount;
4) alter database recover managed standby database disconnect from session;
AT PDC SITE: this is standby
===========
1)alter database recover managed standby database cancel;
2)alter database commit to switchover to primary;
3)shutdown immediate;
4)startup;
NOte: onece it open we need to start recover at standby side
Rajwinder
On Primary:
SQL> Set lines 200 pages 50
SQL > select dest_id,STATUS,database_mode,recovery_mode, archived_seq#, error,gap_status from v$archive_dest_status;
SQL > select thread#, max(sequence#) "Last Primary Seq Generated"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
On Standby:
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied" , almax-lhmax "Sequence Difference"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd;
SQL> select PROCESS,STATUS,THREAD#,SEQUENCE#,BLOCK#,BLOCKS
from v$managed_standby
where process like '%MRP%';
@pending arch:
--------------
set linesize 1200
set pagesize 1200
select * from (select sequence#,archived,applied from v$archived_log order by sequence# desc) where rownum<=20 order by rownum desc;
=====================================================================
expdp directory=EXPDP_DIR dumpfile=NTT_NIL_TRN_TBL1.dmp logfile=NTT_NIL_TRN_TBL1.log TABLES=NEFT.NTT_NIL_TRN_TBL
date +%d%m%Y_%H%M%S
For ORA-03137 : TTC Protocol :: Bug 8625762
=====================================================================
To be executed on : 172.22.196.201 NEFT & SFMS Reporting DB Server on 03-Feb-2015
export ORACLE_SID=NEFT
expdp directory=EXPDP_FULL dumpfile=NEFT_FULL_03FEB2015_%U.dmp logfile=NEFT_FULL_03FEB2015.log FULL=Y COMPRESSION=ALL parallel=4 filesize=20G
export ORACLE_SID=SFMS
expdp directory=EXPDP_FULL dumpfile=SFMS_FULL_03FEB2015.dmp logfile=SFMS_FULL_03FEB2015.log FULL=Y COMPRESSION=ALL
$ cd /backup
$ mkdir TEST
SQL> create directory EXPDP_FULL1 as '/backup/TEST';
$ expdp directory=EXPDP_FULL1 dumpfile=SFMSBR_24Apr2015_%U.dmp logfile=SFMSBR_24Apr2015.log schemas=SFMSBR COMPRESSION=ALL parallel=4 filesize=15G
==========================================================================================
---- FULL DB BACKUP ----
vi ncat_lvl0_backup_CDBD_disk.cmd
CONFIGURE CONTROLFILE AUTOBACKUP ON;
run {
allocate channel 'D1' type DISK FORMAT '/b001/rman/CDBD/hot/lvl0_DB_%d_%c_%U_%D%M%Y.bak';
allocate channel 'D2' type DISK FORMAT '/b001/rman/CDBD/hot/lvl0_DB_%d_%c_%U_%D%M%Y.bak';
allocate channel 'D3' type DISK FORMAT '/b002/rman/CDBD/hot/lvl0_DB_%d_%c_%U_%D%M%Y.bak';
sql 'alter system archive log current';
set controlfile autobackup format for device type disk to '/b001/rman/CDBD/hot/cf_%F';
backup incremental level 0 as compressed backupset database plus archivelog skip inaccessible;
sql 'alter system archive log current';
copy current controlfile to '/b001/rman/CDBD/hot/CDBD_control_hot_%t.ctl';
release channel 'D1';
release channel 'D2';
release channel 'D3';
}
CONFIGURE CONTROLFILE AUTOBACKUP ON;
exit
---- ARCH Backup ----
vi ncat_arch_backup_CDBD_disk.cmd
configure controlfile autobackup off;
run {
allocate channel D1 device type disk;
sql 'alter system archive log current';
backup as compressed
backupset format '/b001/rman/CDBD/arch/CDBD_003_arch_ncat_DB_%d_%F_%p.bak'
archivelog all not backed up 1 times;
delete noprompt force archivelog all backed up 1 times to device type disk;
sql 'alter system archive log current';
allocate channel 'D2' type disk;
copy current controlfile to '/b001/rman/CDBD/control/CDBD_control_hot_%t.ctl';
release channel 'D2';
release channel 'D1';
}
configure controlfile autobackup on;
exit
======================
DELETE ARCHIVELOG UNTIL SEQUENCE = 75200;
delete archivelog until time = 'sysdate-1' backed up 1 times to sbt_tape ;
delete archivelog all backed up 1 times; before 'sysdate';
delete archivelog all not backed up 2 times to device type sbt_tape;
delete archivelog all completed before 'sysdate-1';
======================
Delete from TAPE, where backup OLDER then 17 Days (sysdate - 17)
bash-4.2$ cat /sd_oraBkp/DBA_Activity/DBA_Script/config/delete_RMANBKP_TAPE.sh
#---Export current date
dy=`date "+%d%m%y-%H%M"`
export dy
echo "Starting Backup HouseKeeping Activity" > /sd_oraBkp/DBA_Activity/rman_bkp/obsolete_log/rman_deletion_tape_$dy.log
echo "*************************:CHECKING THE OBSOLETE BACKUP AND DELETING THE OBSOLETE BACKUP:****************************"
#---RMAN full backup script
#---Connect Target Database and Create RMAN Log File
rman TARGET / << EOF>>/sd_oraBkp/DBA_Activity/rman_bkp/obsolete_log/rman_deletion_tape_$dy.log
allocate channel for maintenance device type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
list backup completed before 'sysdate-17';
delete noprompt backup completed before 'sysdate-17';
exit;
eof
bash-4.2$ cd /sd_oraBkp/DBA_Activity/rman_bkp/obsolete_log/
======================
delete archivelog all backed up 1 times to device type Sbt_Tape;
FULL_BKP_%d_set%s_piece%p_%T_%U for backupsets when duplexing is not used.
For duplexing backup it would be FULL_BKP_%d_set%s_piece%p_copy%c_%T_%U
•%d : name of database
•%s :backup set number. (Unique for controlfile lifetime)
•%p :piece number in backup set.
•%T : Specified date in format YYYYMMDD
•%U : Unique number consist of %u_%p_%c
•%c : copy number of backup piece.when duplexing of backup
If no format is specified, Oracle by default uses %U.For controlfile autobackup, I prefer to use default config which is %F.This tag has DBID in the filename which would be necessary in the case of recovery when RMAN catalog is not accessible.This tag can not be used for backup sets.
==========================================================================================
orakill
@logon
SELECT s.inst_id,
s.sid,
s.serial#,
p.pid,
p.spid,
s.username,
s.program,
s.osuser
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id;
-- WHERE s.type != 'BACKGROUND';
SELECT s.inst_id,
s.sid,
s.serial#,
p.pid,
p.spid,
s.username,
s.program
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
where p.spid = 11222;
-------------------------------------------------------------------------------------------------------------------------------------------
crontab setting
00 20 01 03 * /u01/app/oracle/global/bin/rman/scripts/backup_db_logwatcher.ksh cdbp2 levl0_cdbp2_2tape.cmd >/dev/null
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
434779241
BEGIN
DBMS_STATS.gather_table_stats('RSPROD_ARCH',
'REQUEST',
ESTIMATE_PERCENT => 0.1,
METHOD_OPT => 'FOR COLUMNS CLOSEDDATE SIZE 254');
END;
/
select count(*) from V$FAST_START_TRANSACTIONS;
file://C:\Program Files (x86)\lucky leap\bin\Pac9064.js
http://autocache.hp.com/
HP LAPTOP 15R014tx
=====================================
oradw @ sf03s03xxd07:cmfd1
[/home/ais/oradw]$
tokill=`ps -fea|grep mon_ts|awk '{ printf $2" "}'`; kill -9 $tokill;
========================================
landed in similar situation.
I executed command
nid target=sys/pnt4vm dbname=PNT4VM
before renaming/creating the tempfile and was struck with error.
NID-00111: Oracle error reported from target database while executing
begin dbms_backup_restore.nidprocessdf(:fno, :istemp, :skipped, :idchged, :nmchged)
; end;
ORA-01116: error in opening database file F:\ORACLE\ORADATA\PNT4\TEMP02.DBF
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.
ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 6164
ORA-06512: at line 1
WorkAround.
This is what I understood.
If I try reverting (nid target=sys/pnt4vm REVERT=Y) the revert process agains fails. But it reverts all the datafiles except file 01 i.e. SYSTEM.DBF. So as a workaround, I performed following steps.
1) Executed the command
nid target=sys/pnt4vm dbname=PNT4VM
This will fail.
2) Shut down the database.
3) Take Backup of Existing control file.
4) Generate trace for Control file.
5) Remove the existing control files.
6) Edit the parameter file with new DB_NAME
7) Start the Instance in Nomount Stage.
8) Create the control files with SET option. (New DB NAme)
9) Open database with Resetlogs.
10) Add the tempfiles to temp tablespace.
=============================================================
RDA
DFSprod_sys
OVSsys
==========================================================================
DATAGAURD Stopping & Starting Process:
Stopping
1)SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;
Canceling recover operation.
2)ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
3)SELECT NAME, SEQUENCE#, ARCHIVED, APPLIED FROM V$ARCHIVED_LOG;
4)SHUTDOWN IMMEDIATE;
------
Starting
1)STARTUP NOMOUNT;
2)ALTER DATABASE MOUNT STANDBY DATABASE;
3)ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
ALTER DATABASE RECOVER managed standby database disconnect from session;
alter database recover managed standby database cancel;
===================================================
=====================================================================
col name for a50
SELECT NAME, max(SEQUENCE#), ARCHIVED, APPLIED FROM V$ARCHIVED_LOG where applied='YES' and name not like '%sd_ora%'group by name, ARCHIVED, APPLIED;
SELECT max(SEQUENCE#) FROM V$ARCHIVED_LOG where applied='YES';
alter system set log_archive_config='DG_CONFIG=(SFMS_BEL,SFMS_KHAR,SFMS_NAG,SFMS_KHR)' scope=both;
alter system set log_archive_dest_4='SERVICE=SFMS_KHR LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_KHR' scope=both;
alter system set log_archive_dest_state_4=DEFER scope=both;
alter system set log_archive_dest_state_4=ENABLE scope=both;
CREATE OR REPLACE PROCEDURE TRUNCATE_TABLE_PROC (oname IN varchar2,
tname IN varchar2 ) as
/**********************************
AUTHOR JP Vijaykumar
Oracle DBA
DATE 10-05-2006
**********************************/
begin
execute immediate 'truncate table '||oname||'.'||tname;
exception
when others then
raise_application_error(-20001,'Insufficient privileges');
end;
The above truncate table procedure is a simple procedure. Whoever is granted EXECUTE privileges on the procedure can truncate any table in the database.
===== WEUP Proc. ======================================================
1-- Truncating Procedure Will created by Oracle DBA
CREATE PROCEDURE IWAM_STG.TRUNC_DEL_TABLE (btch IN number) as
begin
delete from iwam_stg.load_status_as400 where batch_id = btch;
commit;
execute immediate 'truncate table IWAM_STG.unified_data_as400';
exception
when others then
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR (-20001, btch || ':$:' || SQLERRM, TRUE) ;
end IWAM_STG.TRUNC_DEL_TABLE;
/
2-- Privilege granted to XYZ_User by Oracle DBA on this Truncate proc
grant execute on IWAM_STG.TRUNC_DEL_TABLE to XYZ_User;
3-- Execute Backup & Truncate and deleting procedure in XYZ_User with BATCH_ID Parameter in brackets () to be deleted, from single script created by Us
A. vi rr.sh <== If running from Oracle DB Server, other / Oracle User
a. export ORACLE_HOME
b. export ORACLE_SID
c. expdp xyz_user/xyz_user directory=XYZ_EXPDP filename=Table2_$DT.dmp logname=Table2_$DT.log schemas=iwam_stg tables=(IWAM_STG.unified_data_as400,iwam_stg.load_status_as400)
d. gzip Table2_$DT.dmp
e. sqlplus xyz_user/xyz_user @trunc_del_Proc.sql
e.1. vi trunc_del_Proc.sql ==> execute IWAM_STG.TRUNC_DEL_TABLE(874);
OR OR OR
B. execute IWAM_STG.TRUNC_DEL_TABLE(874); <== If running from TOAD / SQL Developer / etc... & not from logging on to Oracle DB Server
=====================================
@listenerpurging
LSNRCTL> set Log_status off
LSNRCTL> status --check the path of listenerlog
LSNRCTL> exit
Test $> mv listener.log listener_old.log
Test $> touch listener.log
Test $> lsnrctl
LSNRCTL> set Log_Status on
LSNRCTL> exit
====================================
& set LOGGING_LISTENER=OFF in the listener.ora file to stop the listener logging.
=========================================================
00 00,01,02,03,04,05,06,07 27 12 * /u02/orashare/oracle/scripts/dbei/gen200/prd/bin/cronstub.ksh /u02/orashare/oracle/scripts/dbei/ora225/prd/bin/rman.ksh pfubsfll RMAN_Backup/runarchivebkup.rman -n > /u02/orashare/oracle/scripts/dbeiwork/rmanlogs/runarchivebkup_pfubsfll.lst 2>&1
-- All versions. TRACE
SQL> ALTER SESSION SET sql_trace=TRUE;
SQL> ALTER SESSION SET sql_trace=FALSE;
SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => TRUE);
SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => FALSE);
h
yh
SQL> ALTER SESSION SET EVENTS '10046 trace name context forever, level 8';
SQL> ALTER SESSION SET EVENTS '10046 trace name context off';
@traceuser
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>TRUE);
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>FALSE);
SQL> EXEC DBMS_SYSTEM.set_ev(si=>123, se=>1234, ev=>10046, le=>8, nm=>' ');
SQL> EXEC DBMS_SYSTEM.set_ev(si=>123, se=>1234, ev=>10046, le=>0, nm=>' ');
-- Available from SQL*Plus since 8i (commandline utility prior to this.
SQL> CONN sys/password AS SYSDBA; -- User must have SYSDBA.
SQL> ORADEBUG SETMYPID; -- Debug current session.
SQL> ORADEBUG SETOSPID 1234; -- Debug session with the specified OS process.
SQL> ORADEBUG SETORAPID 123456; -- Debug session with the specified Oracle process ID.
SQL> ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12;
SQL> ORADEBUG TRACEFILE_NAME; -- Display the current trace file.
SQL> ORADEBUG EVENT 10046 TRACE NAME CONTEXT OFF;
-- All versions, requires DBMS_SUPPORT package to be loaded.
SQL> EXEC DBMS_SUPPORT.start_trace(waits=>TRUE, binds=>FALSE);
SQL> EXEC DBMS_SUPPORT.stop_trace;
SQL> EXEC DBMS_SUPPORT.start_trace_in_sessivx'bon(sid=>123, serial=>1234, waits=>TRUE, binds=>FALSE);
SQL> EXEC DBMS_SUPPORT.stop_trace_in_session(sid=>123, serial=>1234);
tkprof dev1_ora_367660.trc translated.txt explain=test/test table=sys.plan_table sys=no waits=yes
ORADEBUG SETOSPID 11228;
ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12;
ORADEBUG TRACEFILE_NAME;
ORADEBUG EVENT 10046 TRACE NAME CONTEXT OFF;
=== Rename DB P44 to T44, by NID
nid target=/ DBNAME=T44
nid target=/ DBNAME=metad1
=============================
oradim -NEW -SID P36
===============================
ed large
set pagesize 100
set linesize 500
col sid format 99999
col username format a10 truncated
col status format a1 truncated
col logon format a19
col idle format a9
col program format a30 truncated
col running_since format a15
col event format a35
select
TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI'),a.inst_id,a.sid,a.event,a.username,a.status,a.sql_hash_value,
to_char(logon_time,'dd-mm-yy hh:mi:ss') "LOGON",
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "RUNNING_SINCE",
a.program
from
gv$session a
where
a.type='USER'
AND floor(last_call_et/3600)*60+floor(mod(last_call_et,3600)/60) > 10
AND a.STATUS = 'ACTIVE'
AND a.SID > 10
order by a.last_call_et
/
OWIP 426 Server
bash-3.2$ cat rr_rman.sh
echo "" > rr.sh
BCKUP_DIR=/b01/rman/PNEOLOG/arch
cd $BCKUP_DIR
echo "`pwd`"
LSL=`ls *.bak`
echo "LSL : $LSL"
cd $BCKUP_DIR >> rr.sh
for filename in $LSL
do
echo "Processing : $filename"
echo "gzip $filename "
echo "gzip $filename &" >> rr.sh
done
chmod 755 rr.sh
./rr.sh &
================
create or replace trigger LOGG_TRAIL
before alter on database
when (ora_dict_obj_type = 'USER'
and ora_dict_obj_name != user
and sys_context('USERENV','ISDBA') = 'FALSE' );
declare
by_user varchar2(30);
to_user varchar2(30);
vprofile varchar2(30);
begin
select to.PROFILE into vprofile
from DBA_USERS by, DBA_USERS to
where by.USERNAME = user
and to.USER_NAME = ora_dict_obj_name
and by.PROFILE = to.PROFILE;
insert into TRAIL_TEMP (USER_ALTERED, PASSWORD_MODIFIED_BY, PASSWORD_MODIFIED_DATE, PROFILE)
values (ora_dict_obj_name, user, sysdate, vprofile);
exception
when others then raise_application_error (-20001,'can''t alter user');
end;
/
select to.PROFILE
from DBA_USERS by, DBA_USERS to
where by.USERNAME = user
and to.USER_NAME = ora_dict_obj_name
and by.PROFILE = to.PROFILE;
find / -name "mailx" 2>/dev/null
echo "This is the body."| mailx -s "mailx Test1" ronak.darji@hp.com 2> ./rr.out
echo "This is the body."| /usr/bin/mailx -s "mailx Test1" ronak.darji@hp.com 2> ./rr.out
echo "This is the body."| /bin/mailx -s "mailx Test1" ronak.darji@hp.com 2> ./rr.out
/bin/mailx -r oracle@o-i.com -s "RMAN Backup SUCCESSFUL" ronak.darji@hp.com anup.biswas@hp.com < ./testMail.out
/bin/mail -s "RMAN FAILURE (${HN}:${ORACLE_SID}) " `cat /u001/app/oracle/dba/dba_fail.lst|grep -v "#"` -- -f rman@convatec.com < ${RMAN_LOG_FL}
/bin/mail -s "RMAN FAILURE : TEST rr" ronak.darji@hp.com anup.biswas@hp.com -- -f ronak.darji@hp.com < ./dead.letter
SQL> select name,state,total_mb,free_mb from gv$asm_diskgroup;
NAME STATE TOTAL_MB FREE_MB
------------------------------ ----------- ---------- ----------
DATA MOUNTED 379276 378867
FRA MOUNTED 28610 26008
DATA DISMOUNTED 0 0
FRA DISMOUNTED 0 0
SQL> drop diskgroup FRA including contents;
Diskgroup dropped.
SQL> select name,state,total_mb,free_mb from gv$asm_diskgroup;
NAME STATE TOTAL_MB FREE_MB
------------------------------ ----------- ---------- ----------
DATA MOUNTED 379276 378867
DATA DISMOUNTED 0 0
SQL> drop diskgroup DATA including contents;
Diskgroup dropped.
SQL> select name,state,total_mb,free_mb from gv$asm_diskgroup;
no rows selected
UMG - Donot Close CLOSE only RESOLVE
*************************************************************************************************************
echo "=================================================================" >> ./cp_rr.log
echo "===========S T A R T :- `date` ============" >> ./cp_rr.log
echo "Enter Date of the Files needs to be COPIED e.g Feb 11 or Feb 2"
read dg1
mkdir cp_rr
fn1=`ls -ltr | grep "$dg1" | sed "s/ /;/g" | sed "s/ /;/g" | sed "s/ /;/g" | sed "s/;;;/;/g" | sed "s/;;/;/g" | sed "s/;;/;/g" | cut -d';' -f9`
##echo "dg1"
ls -ltr | grep "$dg1"
ls -ltr | grep "$dg1" >> ./cp_rr.log
echo " "
echo " " >> ./cp_rr.log
echo "================================================================="
echo "===========S T A R T :- `date` ============"
for filename in $fn1
do
cp $filename cp_rr/
echo "File COPIED :- $filename"
echo "File COPIED :- $filename" >> ./cp_rr.log
done
echo "============= E N D :- `date` ============" >> ./cp_rr.log
echo "============= E N D :- `date` ============"
*************************************************************************************************************
Script Deletes only required dated Files only
oracle@ustlvoi424>/export/home/oracle>cat Del_rr.sh
echo "=================================================================" >> ./Del_rr.log
echo "===========S T A R T :- `date` ============" >> ./Del_rr.log
echo "Enter Date of the GZ Files needs to be deleted e.g Feb 11 or Feb 2"
read dg1
fn1=`ls -ltr *.gz | grep "$dg1" | sed "s/ /;/g" | sed "s/ /;/g" | sed "s/ /;/g" | sed "s/;;;/;/g" | sed "s/;;/;/g" | cut -d';' -f9`
##echo "dg1"
ls -ltr *.gz | grep "$dg1"
ls -ltr *.gz | grep "$dg1" >> ./Del_rr.log
echo " "
echo " " >> ./Del_rr.log
echo "================================================================="
echo "===========S T A R T :- `date` ============"
for filename in $fn1
do
rm $filename
echo "File Deleted :- $filename"
echo "File Deleted :- $filename" >> ./Del_rr.log
done
echo "============= E N D :- `date` ============" >> ./Del_rr.log
echo "============= E N D :- `date` ============"
*************************************************************************************************************
echo "=================================================================" >> ./GZIP_rr.log
echo "===========S T A R T :- `date` ============" >> ./GZIP_rr.log
echo "Enter Files Extension needs to be GZIPPED e.g dmp"
read dg1
fn1=`ls *.$dg1`
cnt=`ls *.$dg1 | wc -l`
echo "fn1 : $fn1 : $cnt"
for filename in $fn1
do
echo "Pending $dg1 Files to be GZIPPED : $cnt"
cnt=`expr $cnt - 1`
gzip $filename
echo "File GZIPPED :- $filename"
echo "File GZIPPED :- $filename" >> ./GZIP_rr.log
done
echo "============= E N D :- `date` ============" >> ./GZIP_rr.log
echo "============= E N D :- `date` ============"
*************************************************************************************************************
/u07/oraexport/pfcdb/GZIP_rr.sh > /u07/oraexport/pfcdb/GZIP_rr1.log 2> /u07/oraexport/pfcdb/GZIP_rr1.err &
CONVERTING from RAC to NON-RAC, Online Redo Log file dropping from THREAD 2 / NODE 2
SQL> select THREAD#, STATUS, ENABLED
2 from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED PRIVATE
SQL> select group# from v$log where THREAD#=2;
GROUP#
----------
4
5
6
SQL> alter database disable thread 2;
Database altered.
SQL> alter database clear unarchived logfile group 4; ( repeat for 4 to 6)
Database altered.
SQL> alter database drop logfile group 4; ( repeat for 4 to 6)
Database altered.
- Now you can remove the undo tablespaces of other instances.
SQL> show parameter undo;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL> select tablespace_name from dba_tablespaces where contents='UNDO';
TABLESPACE_NAME
------------------------------
UNDOTBS1
UNDOTBS2
SQL> drop tablespace UNDOTBS2 including contents and datafiles;
Tablespace dropped.
**************************************************************
cat db_mon.cfg | grep 15m | grep -v ^"#" | grep -v l$
select table_name,partition_name,SUBPARTITION_COUNT,HIGH_VALUE,TABLESPACE_NAME,last_analyzed from dba_tab_partitions where table_name='&SMA_FAC_DIG_SALES';
========ORACLE GRID & DB HOME PSU Patch
opatch lsinventory -detail
@cpupatch:
----------
unzip p21972320_112040_AIX64-5L.zip
cd 21972320
export PATH=$ORACLE_HOME/OPatch:$PATH
opatch lsinventory
opatch version
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
opatch napply -skip_subset -skip_duplicate
opatch lsinventory | grep applied
opatch version
sqlplus / as sysdba
@?/rdbms/admin/catbundle.sql cpu apply
@?/rdbms/admin/utlrp.sql
set lines 200
set pages 200
set time on
col ACTION_TIME for a35
col ACTION for a12
col NAMESPACE for a12
col VERSION for a12
col COMMENTS for a30
col BUNDLE_SERIES for a10
select * from registry$history;
$ opatch version
$ opatch lsinventory
###########################################################################3
#opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./13696242
opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./
.As root user execute:
# opatch auto <UNZIPPED_PATCH_LOCATION> -oh <ORACLE_HOME>
echo $PATH
export PATH=/u01/app/crs/11.2.0.3/grid/OPatch:$PATH
cd <PSU_Location>
opatch auto <PSU_Location> -oh /u01/app/crs/11.2.0.3/grid -local
Case 5: Patching a Software Only GI Home Installation
1.Apply the CRS patch using.
As the GI home owner execute:
$ <GI_HOME>/OPatch/opatch napply -oh <GI_HOME> -local <UNZIPPED_PATCH_LOCATION>/13696242
As the GI home owner execute:
$ <GI_HOME>/OPatch/opatch napply -oh <GI_HOME> -local <UNZIPPED_PATCH_LOCATION>/13923804
Case 6: Patching a Software Only Oracle RAC or Oracle RAC One Node Home Installation
1.Run the pre script for DB component of the patch.
As the database home owner execute:
$ <UNZIPPED_PATCH_LOCATION>/13696242/custom/server/13696242/custom/scripts/prepatch.sh -dbhome <ORACLE_HOME>
2.Apply the DB patch.
As the database home owner execute:
$ <ORACLE_HOME>/OPatch/opatch napply -oh <ORACLE_HOME> -local <UNZIPPED_PATCH_LOCATION>/13696242/custom/server/13696242
$ <ORACLE_HOME>/OPatch/opatch napply -oh <ORACLE_HOME> -local <UNZIPPED_PATCH_LOCATION>/13923804
3.Run the post script for DB component of the patch.
As the database home owner execute:
$ <UNZIPPED_PATCH_LOCATION>/13696242/custom/server/13696242/custom/scripts/postpatch.sh -dbhome <ORACLE_HOME>
=================================================================================================================================
@racpatching
All-Node Patch
--------------
. Shutdown all Oracle instances on all nodes
. Apply the patch to all nodes
. Bring all nodes up
Minimum downtime
----------------
. Shutdown the Oracle instance on node 1
. Apply the patch to the Oracle instance on node 1
. Shutdown the Oracle instance on node 2
. Apply the patch to the Oracle instance on node 2
. Shutdown the Oracle instance on node 3
. At this point, instances on nodes 1 and 2 can be brought up
. Apply the patch to the Oracle instance on node 3
. Startup the Oracle instance on node 3
Rolling patch (no downtime)
---------------------------
. Shutdown the Oracle instance on node 1
. Apply the patch to the Oracle instance on node 1
. Start the Oracle instance on node 1
. Shutdown the Oracle instance on node 2
. Apply the patch to the Oracle instance on node 2
. Start the Oracle instance on node 2
. Shutdown the Oracle instance on node 3
. Apply the patch to the Oracle instance on node 3
. Start the Oracle instance on node 3
==========================================================================================================================================
2.5.2 Loading Modified SQL Files into the Database
The following steps load modified SQL files into the database. For an Oracle RAC or Oracle RAC One Node environment, perform these steps on only one node.
1.For each database instance running on the Oracle home being patched, connect to the database using SQL*Plus. Connect as SYSDBA and run the catbundle.sql script as follows:
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @?/rdbms/admin/catbundle.sql psu apply
SQL> QUIT
The catbundle.sql execution is reflected in the dba_registry_history view by a row associated with bundle series PSU.
For information about the catbundle.sql script, see My Oracle Support Note 605795.1 Introduction to Oracle Database catbundle.sql.
2.Check the following log files in $ORACLE_BASE/cfgtoollogs/catbundle for any errors:
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log
where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS. If there are errors, refer to Section 3, "Known Issues".
2.5.3 Upgrade Oracle Recovery Manager Catalog
If you are using the Oracle Recovery Manager, the catalog needs to be upgraded. Enter the following command to upgrade it:
$ rman catalog username/password@alias
RMAN> UPGRADE CATALOG;
=====================================
Eliminating Migrated or Chained Rows in a Table
You can use the information in the CHAINED_ROWS table to reduce or eliminate migrated and chained rows in an existing table. Use the following procedure.
Use the ANALYZE statement to collect information about migrated and chained rows.
ANALYZE TABLE order_hist LIST CHAINED ROWS;
Query the output table:
SELECT *
FROM CHAINED_ROWS
WHERE TABLE_NAME = 'ORDER_HIST';
OWNER_NAME TABLE_NAME CLUST... HEAD_ROWID TIMESTAMP
---------- ---------- -----... ------------------ ---------
SCOTT ORDER_HIST ... AAAAluAAHAAAAA1AAA 04-MAR-96
SCOTT ORDER_HIST ... AAAAluAAHAAAAA1AAB 04-MAR-96
SCOTT ORDER_HIST ... AAAAluAAHAAAAA1AAC 04-MAR-96
The output lists all rows that are either migrated or chained.
If the output table shows that you have many migrated or chained rows, then you can eliminate migrated rows by continuing through the following steps:
Create an intermediate table with the same columns as the existing table to hold the migrated and chained rows:
CREATE TABLE int_order_hist
AS SELECT *
FROM order_hist
WHERE ROWID IN
(SELECT HEAD_ROWID
FROM CHAINED_ROWS
WHERE TABLE_NAME = 'ORDER_HIST');
Delete the migrated and chained rows from the existing table:
DELETE FROM order_hist
WHERE ROWID IN
(SELECT HEAD_ROWID
FROM CHAINED_ROWS
WHERE TABLE_NAME = 'ORDER_HIST');
Insert the rows of the intermediate table into the existing table:
INSERT INTO order_hist
SELECT *
FROM int_order_hist;
Drop the intermediate table:
DROP TABLE int_order_history;
Delete the information collected in step 1 from the output table:
DELETE FROM CHAINED_ROWS
WHERE TABLE_NAME = 'ORDER_HIST';
Use the ANALYZE statement again, and query the output table.
======================================
CREATE DISKGROUP TEST EXTERNAL REDUNDANCY DISK '/dev/oracleasm/disks/DG_TEST','/dev/oracleasm/disks/DG_TEST1','/dev/oracleasm/disks/DG_TEST2' ATTRIBUTE 'au_size'='4M',
'compatible.asm' = '11.2.0.3.0',
'compatible.rdbms' = '11.2.0.3.0',
'compatible.advm' = '11.2.0.3.0';
CREATE DISKGROUP DATADG EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_DATA2','ORCL:ARGQ_DATA3','ORCL:ARGQ_DATA4','ORCL:ARGQ_DATA5','ORCL:ARGQ_DATA6','ORCL:ARGQ_DATA7','ORCL:ARGQ_DATA8','ORCL:ARGQ_DATA9','ORCL:ARGQ_DATA10';
CREATE DISKGROUP UNDODG EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_UNDO1','ORCL:ARGQ_UNDO2','ORCL:ARGQ_UNDO3';
CREATE DISKGROUP TEMPDG EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_DATA1','ORCL:ARGQ_DATA2','ORCL:ARGQ_TEMP3';
CREATE DISKGROUP FRADG EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_FRA1','ORCL:ARGQ_FRA2','ORCL:ARGQ_FRA3','ORCL:ARGQ_FRA4','ORCL:ARGQ_FRA5','ORCL:ARGQ_FRA6';
CREATE DISKGROUP REDODG1 EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_REDO_1';
CREATE DISKGROUP REDODG2 EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_REDO_2';
select name,state,total_mb,free_mb,COMPATIBILITY,DATABASE_COMPATIBILITY from gv$asm_diskgroup;
alter diskgroup ARGQ_UNDO set attribute 'compatible.asm'='11.2';
alter diskgroup ARGQ_UNDO set attribute 'compatible.rdbms'='11.2';
==========================================
set lines 160
set pages 2002
set time on
column machine format a20
column event format a35
column program format a30
column schemaname for a10
column action format a50
column FC_cdt new_value file_time noprint
column FC_DB new_value file_DB noprint
select to_char(sysdate,'dd_mm_yyyy_hh24_mi_ss') FC_cdt from dual;
select instance_name FC_DB from gv$instance;
spool &file_DB._Session_Check_&file_time..txt
prompt ===== TOTAL SESSION ======
select count(*) from v$session;
prompt ===== SESSION Count as per EVENT ======
select event,count(*) from v$session group by event;
prompt ===== TOTAL SESSION DETAIL INFORMATION======
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,status from v$session
where logon_time not like sysdate
and schemaname not like 'SYS%'
order by logon_time;
spool off;
exit;
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,status from v$session
where sid = &SID order by logon_time desc;
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,status
from v$session
where event like '%gc%'
order by logon_time desc;
select snaps.begin_interval_time, snaps.instance_number,snaps.snap_id,hist.event_name , hist.wait_time_milli, hist.wait_count
from dba_hist_event_histogram hist, dba_hist_snapshot snaps
where snaps.snap_id = hist.snap_id and snaps.instance_number = hist.instance_number and
snaps.begin_interval_time > sysdate - 1/12 -- sysdate - 1/12 -> display AWR reports from the last 2 hours
AND hist.event_name like lower ('%log%')
order by 4,2,3;
-- order by snaps.snap_id , snaps.instance_number, wait_time_milli;
set lines 160
set pages 2002
set time on
column FC_cdt new_value file_time noprint
column FC_DB new_value file_DB noprint
select to_char(sysdate,'dd_mm_yyyy_hh24_mi_ss') FC_cdt from dual;
select instance_name FC_DB from gv$instance;
spool &file_DB._Session_Check_&file_time..txt
spool off;
exit;
===================================================
change archivelog all crosscheck;
crosscheck backup of database;
====******** DAILY QUERY *********=====
BLOCKING
=========
Recipie #1 - find blocking sessions with v$session
SELECT
s.blocking_session,
s.sid,
s.serial#,
s.seconds_in_wait
FROM
v$session s
WHERE
blocking_session IS NOT NULL;
Recipie #2 - find blocking sessions using v$lock
SELECT
l1.sid || ' is blocking ' || l2.sid blocking_sessions
FROM
v$lock l1, v$lock l2
WHERE
l1.block = 1 AND
l2.request > 0 AND
l1.id1 = l2.id1 AND
l1.id2 = l2.id2;
Recipie #3 - blocking sessions with all available information
The next query prints a few more information, it let's you quickly see who's blocking who. Run this query and you can immediately call the colleague who's locking your table
SELECT s1.username || '@' || s1.machine
|| ' ( SID=' || s1.sid || ' ) is blocking '
|| s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
FROM v$lock l1, v$session s1, v$lock l2, v$session s2
WHERE s1.sid=l1.sid AND s2.sid=l2.sid
AND l1.BLOCK=1 AND l2.request > 0
AND l1.id1 = l2.id1
AND l2.id2 = l2.id2 ;
==============================================================================================================
SILENT INSTALLATION
You can use the below command to run the silent mode and after installation finish, run root.sh with root privilege
cd /backup/11203/database/response
./runInstaller -silent -responseFile /u01/app/oracle/data/db/database/db_install_new.rsp
==============================================================================================================
@UPGRADATION to 11.2.0.3.8 PSU8
1. Install 11.2.0.3.0 Software -- 10404530
2. Database ( USUX52P5 ) upgrade to 11.2.0.3 on USHPEAVDBS016.
Pre-Upgrade TASKS From OLD HOME...DB
SQL> @$11g_ORACLE_HOME/rdbms/admin/utlu112i.sql
SQL> select * from registry$sys_inv_objs; -- Any invalid SYS/SYSTEM objects found before upgrading the database are stored in the table named registry$sys_inv_objs
SQL> PURGE dba_recyclebin
SQL> @utlrp.sql
SQL> Gather System Statistics
SQL> backup PFILE / SPFILE
Change Compatible parameter to 11.2.0.3
Upgrade TASK
SQL> STARTUP UPGRADE -- From New HOME
SQL> @?/rdbms/admin/catupgrd.sql
SQL> @utlu112s.sql -- the Post-Upgrade Status Tool, which provides a summary of the upgrade at the end of the spool log
SQL> @catuppst.sql
SQL> @utlrp.sql
SQL> SELECT count(*) FROM dba_invalid_objects;
SQL> SELECT distinct object_name FROM dba_invalid_objects;
•After the upgrade, run ORACLE_HOME/rdbms/admin/utluiobj.sql
3. Apply PSU 8 Patch on 11.2.0.3.0 -- 16902043
unzip p16902043_11203_<platform>.zip
cd 16902043
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
opatch apply
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle.sql psu apply
opatch lsinventory
===
POSSIBLE Errors
?ORA-00401: the value for parameter compatible is not supported by this release
The COMPATIBLE initialization parameter is set to a value less than 10.0.0.
?ORA-39701: database must be mounted EXCLUSIVE for UPGRADE or DOWNGRADE
The CLUSTER_DATABASE initialization parameter is set to TRUE instead of FALSE.
?ORA-39700: database must be opened with UPGRADE option
The STARTUP command was issued without the UPGRADE keyword.
?ORA-00336: log file size xxxx blocks is less than minimum 8192 blocks
A redo log file size is less than 4 MB:
===
1. Install 11.2.0.3.0 rdbms software
11.2.0.3 patch set is a full release. There is no need to install 11.2.0.1 software
See Note 1189783.1 Important Changes to Oracle Database Patch Sets Starting With 11.2.0.2
The software can be downloaded from My Oracle support: Patch:10404530
Please select your platform before downloading (Click on "Platform or Language" drop down menu)
if the platform name contains (32-bit) then it's 32-bit 11.2.0.3 client version
To install 11.2.0.3, you must download both p10404530_112030_<platform>_1of7.zip
and p10404530_112030_<platform>_2of7.zip
<platform> = your platform( ie for linux x86, download p10404530_112030_LINUX_1of7.zip and
p10404530_112030_LINUX_2of7.zip )
Note 1194734.1 : Where do I find that on My Oracle Support (MOS) [Video]
Note 549617.1 : How To Verify The Integrity Of A Patch/Software Download? [Video]
Note 169706.1 : Oracle Database Installation and Configuration Requirements Quick Reference (8.0.5 to 11.2)
The minimum version required to upgrade to 11.2.0.X.X is 9.2.0.8.0.
Note 551141.1 : Database Server Upgrade/Downgrade Compatibility Matrix
2. Upgrade the database to 11.2.0.3.0
Note 419550.1 : Different Upgrade Methods For Upgrading Your Database
Note 837570.1 : Complete Checklist for Manual Upgrades to 11gR2
Note 870814.1 : Complete checklist to upgrade the database to 11gR2 using DBUA
REFERENCE:
Availability and Known issues for 11.2.0.3 Note:1348336.1
11.2.0.3 Patch Set - List of Bug Fixes by Problem Type Note 1348303.1
Actions For DST Updates When Upgrading To Or Applying The 11.2.0.3 Patchset Note 1358166.1
==============================================================================================================
@postupg
SELECT comp_name component, version, status FROM dba_registry;
http://dbaoracletips.blogspot.in/2014/02/owb-component-not-upgraded-to-11204.html
The Database has been upgraded from 11.2.0.2 to 11.2.0.4. Upgrade completed successfully but the OWB component is not upgraded and showing version 11.2.0.4
Solution:
Login as sysdba and execute below scripts
execute the script $ORACLE_HOME\owb\UnifiedRepos\clean_owbsys.sql
execute the script $ORACLE_HOME\owb\UnifiedRepos\cat_owb.sql
==============================================================================================================
==== RMAN Arch Delete
rman target / nocatalog << EOF >> $RMAN_LOG
run
{
allocate channel dsk_inst1 device type disk;
allocate channel dsk_inst2 device type disk;
delete noprompt archivelog all completed before 'sysdate -2';
release channel dsk_inst1;
release channel dsk_inst2;
}
EOF
list archivelog until time 'sysdate - 1';
crosscheck archivelog until time 'sysdate - 1';
delete noprompt archivelog all completed before 'sysdate - 1';
delete noprompt archivelog all completed before 'sysdate - 2';
delete noprompt archivelog all completed before 'sysdate - 1/12';
delete noprompt archivelog from sequence 1111 to sequence 1122;
rman target / nocatalog << EOF >> $RMAN_LOG
run
{
allocate channel dsk_inst1 device type disk;
allocate channel dsk_inst2 device type disk;
--delete noprompt archivelog all completed before 'sysdate -2';
backup database;
release channel dsk_inst1;
release channel dsk_inst2;
}
EOF
RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 73320 UNTIL SEQUENCE 73500;
RMAN> DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 73500;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 267914;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 268265;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 1100;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 1370;
list backup of datafile 1,2,3,4 completed after 'trunc(sysdate) -3';
list backup summary completed after 'trunc(sysdate) -3';
==========================================================================================================
RMAN Restore on Time basis:
RMAN> run
{
Set until time "to_date('15/04/2014 00:30:00','dd/mm/yyyy hh24:mi:ss')";
Restore controlfile from ‘h:\rman\backup…..\control.ctl’;
}
RMAN> restore database until time "to_date('15/04/2014 00:30:00','dd/mm/yyyy hh24:mi:ss')";
RMAN> recover database until time "to_date('15/04/2014 00:30:00','dd/mm/yyyy hh24:mi:ss')";
SQL> alter database open resetlogs;
======
configure retention policy to recovery window of 7 days;
configure retention policy to redundancy 2;
==========================================================================================================
root@HBFCRPPRDDB1:/fc_precut_dump/scripts $cat fc_precut_rman.sh
#!/usr/bin/ksh
# Name : rman_bkp.sh
# Description :
# This script takes a RMAN Daily FULL Database and Archive files backup.
# Also takes controlfile and spfile autobackup.
# It removes the obsolete backup and 3 days old archive files.
cd /fc_precut_dump/backup/logs
#topas_nmon -f -t -s10 -c180
export ORACLE_HOME=/oracle11R2/app/11.2.2
export ORACLE_SID=FCPRECUT
export PATH=$ORACLE_HOME/bin:$PATH
tdate=`date '+%d-%m-%y'`
DBNAME=FCPRECUT
BKPLOC=/fc_precut_dump/backup/RMAN/CURRENT
LOGLOC=/fc_precut_dump/backup/logs/RMAN
RMAN_LOG=$LOGLOC/"$DBNAME"_rman_backup_$tdate.log
sqlplus " /as sysdba" <<EOF>/fc_precut_dump/backup/logs/database_status.lst
@/fc_precut_dump/scripts/sql/database_status.sql
EOF
a=`cat /fc_precut_dump/backup/logs/database_status.lst | grep -i STARTED | wc -l | awk '{print $1}'`
if [ $a -eq 1 ]
then
echo "fcpreeod database is in nomount mode...please connect dba support"
exit 1
else
echo " ......"
fi
dbavl=`ps -eaf|grep ora_pmon_FCPRECUT | grep -v grep | wc -l`
spchk=`df -gt /fc_precut_dump|awk '{print $5}'|tail -1|cut -f1|sed -e 's/%//'`
if [ $dbavl -eq 1 ] && [ $spchk -le 85 ]; then
echo "\n\n **************** RMAN Backup Startup time : `date` *****************" >> $RMAN_LOG
rman target / nocatalog << EOF >> $RMAN_LOG
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
allocate channel c6 type disk;
allocate channel c7 type disk;
allocate channel c8 type disk;
allocate channel c9 type disk;
allocate channel c10 type disk;
allocate channel c11 type disk;
allocate channel c12 type disk;
allocate channel c13 type disk;
allocate channel c14 type disk;
allocate channel c15 type disk;
allocate channel c16 type disk;
allocate channel c17 type disk;
allocate channel c18 type disk;
allocate channel c19 type disk;
allocate channel c20 type disk;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/fc_precut_dump/backup/RMAN/CURRENT/snapcf_FCRPT.f';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/fc_precut_dump/backup/RMAN/CURRENT/fcprdgl_ctl%F';
crosscheck backup;
backup as compressed backupset database TAG 'Daily_Full_DB_Backup_$tdate' FORMAT '$BKPLOC/DBFULL_FC_%U_%D_%M_%Y';
backup archivelog all not backed up 1 times TAG 'ARC_Backup_$tdate' FORMAT '$BKPLOC/ARCH_FC_%U_%D_%M_%Y';
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;
release channel c9;
release channel c10;
release channel c11;
release channel c12;
release channel c13;
release channel c14;
release channel c15;
release channel c16;
release channel c17;
release channel c18;
release channel c19;
release channel c20;
}
EOF
else
echo "Database is down ...or Enough free space not available for Backup"
exit 1
fi
cd /openview_archive/openview_EXPBKP
dt=`date +%d%m%Y_%H%M%S`
find . -name "*.trc" -mtime +20 -exec rm {} \;
00 23 27 * * /home/oracle/rr/EXPDP_openview.sh 2>> /home/oracle/rr/EXPDP_openview.err
Arun RBI - 9870054897
Sonu Gupta - Mail Initiated
cd $BKPLOC
find . -name -mtime +60 -exec rm {} \;
find . -mtime +20 -exec rm -rf {} \;
find . -name "*.log" -mtime +60 -exec rm {} \;
find . -mtime +1 -exec rm {} \;
find . -mtime +20 -exec ls -ltr {} \;
find . -mtime +10 -exec rm {} \;
find . -mtime +1 -exec ls -ltr {} \;
find . -mtime +0 -exec ls -ltr {} \;
find . -mtime +1 -exec gzip {} \;
find . -mtime +10 -exec rm {} \;
find . -mtime -2 -exec rm {} \;
find . -mtime -2 -exec ls -ltr {} \;
find . -mtime +2 -exec ls -ltr {} \;
Will ls Files whose Modified time is Older then 24 Hours
find . -mtime +1 -name "*.gz" -exec ls -ltr {} \;
Will ls Files whose Modified time is Older then 48 Hours
find . -mtime +2 -exec ls -ltr {} \;
echo "\n\n ******************RMAN Backup for $DBNAME has completed at : `date` **********************" >> $RMAN_LOG
cd /fc_precut_dump/backup/logs/RMAN
chmod 755 $RMAN_LOG
find . -mtime +5 -exec rm {} \;
exit
ZUS-EMTOOLS-MR-AR <ZUS-EMTOOLS-MR-AR@hp.com>
find ./metap3_ora*.trc.gz -mtime +15 -exec rm {} \;
find . -mtime +15 -exec ls -ltr {} \;
find . -mtime +15 -exec gzip {} \;
find . -mtime +30 -exec rm {} \;
find . -mtime +1 -exec rm {} \;
find . -mtime -1 -exec ls -ltr {} \;
find . -mtime +200 -exec rm {} \;
find ./metaemp1_ora_*.trc -mtime +3 -exec ls -ltr {} \;
find /b001/backup/exports/wuktst -mtime +1 -exec ls -ltr {} \;
find /b001/backup/exports/wukdev/ -mtime +1 -exec ls -ltr {} \;
======= SQL
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
124.30.56.17 - DELL 2850
10.240.32.201 - DELL 2850
exec sp_send_cdosysmail 'dba@hdfcinsurance.com','dba@hdfcinsurance.com','','test','test'
-2147023782.
qazwsxed04
======= Oracle
opatch lsinventory -- check what this command does.
select owner,object_name,object_type,created,status from dba_objects where object_NAME like '%KGSKWT%';
select OWNER,CONSTRAINT_NAME,R_CONSTRAINT_NAME,CONSTRAINT_TYPE,TABLE_NAME,STATUS,INVALID from dba_constraints where TABLE_NAME like '%AUDIT_TRAIL%';
select * from dba_cons_columns where CONSTRAINT_name like '%PRL_CANDIDATE_CASE_REGN_R88%';
select OWNER,CONSTRAINT_NAME,R_CONSTRAINT_NAME,CONSTRAINT_TYPE,TABLE_NAME,STATUS,INVALID from dba_constraints where TABLE_NAME like '%PRL_CANDIDATE_CASE_REGN%';
select owner,object_name,object_type,created,status from dba_objects where object_NAME like '%TTFGLD106954%';
alter table
Truncating & Deallocating space.
================================
SQL> TRUNCATE TABLE BIGTABLE REUSE STORAGE;
SQL> ALTER TABLE BIGTABLE DEALLOCATE UNUSED KEEP 1707M; (2Gb*5/6)
\\bkchome\Common\Others\Komal\sutapa\RPT-Setup
imp ams/ams file='' log='' tables=(AMS_NEFT_COMMDETAILS,AMS_NEFT_DETAILS,CC_MED_LETTER_PDF,AMS_COMM_CHQ_DIS_STATUS,AMS_ECS_COMMDETAILS,AMS_ECS_MANREJ_DETAILS,AMS_NEFT_MANREJ_DETAILS) feedback=10000 buffer=1234567890 ignore=y
('AMS_NEFT_COMMDETAILS','AMS_NEFT_DETAILS','CC_MED_LETTER_PDF','AMS_COMM_CHQ_DIS_STATUS','AMS_ECS_COMMDETAILS','AMS_ECS_MANREJ_DETAILS','AMS_NEFT_MANREJ_DETAILS')
=====================================================================================
vi rmanbackup.sh
export ORACLE_HOME=/oracle11R2/app/11.2.2
export ORACLE_SID=FCPRECUT
export PATH=$ORACLE_HOME/bin:$PATH
tdate=`date '+%d-%m-%y'`
DBNAME=FCPRECUT
RMAN_LOG=/home/oracle/$DBNAME_rmanbackup_$tdate.log
rman target / nocatalog << EOF >> $RMAN_LOG
run
{
allocate channel dsk_inst1 device type disk;
allocate channel dsk_inst2 device type disk;
--delete noprompt archivelog all completed before 'sysdate -2';
backup database;
release channel dsk_inst1;
release channel dsk_inst2;
}
EOF
delete archivelog all backedup before 'sysdate';
RAC Services Check
Oracle11g
==========
srvctl config database -d RAC
srvctl status database -d HDFCPROD
srvctl stop database -d RAC
srvctl start instance -d racdb -i racdb1, racdb3
srvctl stop instance -d racdb -i racdb1, racdb3
srvctl status
crsctl status resource -t
crsctl status server -f
SELECT * FROM v$active_instances;
SELECT svrname, dirname FROM v$dnfs_servers;
ORACLE10g
==========
C:\>crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
D:\oracle\product\10.2.0\crs\BIN>srvctl status nodeapps -n ccdb1
VIP is running on node: ccdb1
GSD is running on node: ccdb1
Listener is not running on node: ccdb1
ONS daemon is running on node: ccdb1
crs_stat -t
C:\Documents and Settings\setouqe>D:\oracle\product\10.2.0\crs\BIN\crs_stat.exe -t
Name Type Target State Host
------------------------------------------------------------
ora....T1.inst application ONLINE OFFLINE
ora....T2.inst application ONLINE ONLINE ccdb2
ora.HDFCUAT.db application ONLINE ONLINE ccdb2
ora....AT1.srv application ONLINE ONLINE ccdb2
ora....luat.cs application ONLINE ONLINE ccdb2
ora....SM1.asm application ONLINE ONLINE ccdb1
ora....B1.lsnr application ONLINE OFFLINE
ora.ccdb1.gsd application ONLINE OFFLINE
ora.ccdb1.ons application ONLINE ONLINE ccdb1
ora.ccdb1.vip application ONLINE ONLINE ccdb1
ora....SM2.asm application ONLINE ONLINE ccdb2
ora....B2.lsnr application ONLINE ONLINE ccdb2
ora.ccdb2.gsd application ONLINE ONLINE ccdb2
ora.ccdb2.ons application ONLINE ONLINE ccdb2
ora.ccdb2.vip application ONLINE ONLINE ccdb2
ora....prod.db application OFFLINE OFFLINE
ora....d1.inst application ONLINE OFFLINE
ora....d2.inst application ONLINE UNKNOWN ccdb2
ora....prod.cs application OFFLINE OFFLINE
ora....od1.srv application OFFLINE OFFLINE
ora....od2.srv application OFFLINE OFFLINE
=============================================================================
Supriyo - 9920057626
Daily TBSP Check:
=============
10.60.0.186 -- ODS - Auto Manu
10.60.0.141 -- PRLPROD
10.60.0.144 -- Not Required
10.60.1.91 -- MINT1 , PINNACLE1 -- OracleDBConsole Auto
10.60.1.93 -- MINT2 , PINNACLE2 -- OracleDBConsole Auto
124.30.56.2 -- HDFCPROD1
124.30.56.15 -- HDFCPROD2
10.60.0.201 -- HDFCDB , IDB , FNTIDBCS -- Manu
10.60.1.208 -- MDEALING -- Auto - Manu
10.60.0.230 -- HDFCAML , FNTIDBCS , AMLUAT -- Manu
10.60.0.127 --
10.60.0.195 -- SUNAR , SUNLA , ORACLE9 Agent -- Auto Manu
Daily Disk Space Check:
=======================
10.60.0.126 -- Standby Server
10.60.0.201
124.30.56.16 -- Standby Server
Daily ASM Check:
================
124.30.56.2 / 15
10.60.1.91 / 93
select * from v$sess_io where sid in (select sid from v$session where program like '%(J0%');
@schemasize:
select sum(bytes/1024/1024/1024) from dba_segments where owner = '&AMS';
select username,default_tablespace from dba_users where username = 'AMS';
EVENTS :
=========
cursor: pin S wait on X : A session waits on this event when requesting a mutex for sharable operations
related to pins (such as executing a cursor), but the mutex cannot be granted because
it is being held exclusively by another session (which is most likely parsing the cursor).
SELECT p2raw
,to_number(substr(to_char(rawtohex(p2raw)), 1, 8), 'XXXXXXXX') sid
FROM v$session
WHERE event = 'cursor: pin S wait on X';
P2RAW SID
---------------- ---
0000001F00000000 31
On 64 bit platforms 8 bytes are used, so the top 4 bytes are the holding session Id (if the mutex is held X), and the bottom 4 bytes are the ref count (if the mutex is held S).
On 32 bit platforms 4 bytes are used, so the top 2 bytes are the holding session Id (if the mutex is held X) and the bottom 2 bytes are the ref count (if the mutex is held S).
select p1, p2raw, count(*)
from v$session
where event = 'cursor: pin S wait on X’
and wait_time = 0
group by p1, p2raw;
col p1text for a15
col p2text for a15
col p3text for a15
select sid,serial#,program,event,p1, p1text ,p2, p2text,p3,p3text, p2raw from v$session where event like '%write%';
SOLUTION:
---------
Quick workaround is to set "_kks_use_mutex_pin" to false .
or
Apply the patch 5907779
RMAN: Restoring an RMAN Backup to Another Node [ID 73974.1]
library cache pin
library cache lock
ALTER DATABASE ADD LOGFILE group 7 ('/u02/oradata/P38/redo07a.log', '/u03/oradata/P38/redo07b.log') size 15728640;
ed cursorcheck
select a.value, s.username, s.sid, s.serial#
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current'
order by 1;
select sum(x.value) from (select a.value, s.username, s.sid, s.serial#
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current') x;
col max_open_cur for a7
select max(a.value) as highest_open_cur, p.value as max_open_cur
from v$sesstat a, v$statname b, v$parameter p
where a.statistic# = b.statistic#
and b.name = 'opened cursors current'
and p.name= 'open_cursors'
group by p.value;
=============================
Freespace:
set time on
column host_name format a25
select name,open_mode from gv$database;
select instance_name,host_name,status,logins from gv$instance;
set pages 500
set lines 120
set heading on
column tablespace_name for a30
column tbsize for 999999999.999
column tbfree for 999999999.999
column Largest for 99999.999
column ratio for 9999.99
column Required for 99999.999
select
a.tablespace_name ,
tbsize ,
tbfree ,
b.tbfree/a.tbsize*100 "% Free TBS" ,
b.Largest "Largest space"
from
( select tablespace_name,sum(bytes)/1024/1024 tbsize
from dba_data_files
group by tablespace_name) a,
( select tablespace_name,nvl(sum(bytes)/1024/1024,0) tbfree,
nvl(max(bytes)/1024/1024,0) Largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name(+)
order by 4 desc;
D:\IBM Oracle Docs\IBM\RBI_Requirements\Mail from Maruti CMDDB\CDBMSNEW_Tables_Details
select owner,segment_name Table_Name ,sum(bytes/1024/1024) Table_MB from dba_segments where segment_type = 'TABLE' and TABLESPACE_NAME not like 'SYS%' group by owner,segment_name order by 1,3;
select * from v$recover_file;
select distinct status from v$datafile;
archive log list;
alter system checkpoint;
alter system switch logfile;
07738900976
column file_name format a55
column tablespace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&UNDO%' order by 3;
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
select 'alter tablespace ' || tablespace_name || ' add datafile ' || ''' || '/CDBMS_DATA/cdbmsstg/oradata/cdbms_st/' || tablespace_name || '_C001.dbf' || ''' || ' size 1G autoextend on;' from dba_tablespaces order by 1;
select sid,serial#,program,event ,to_char(logon_time,'DD-MM-YYYY HH24:MI:SS') from gv$session where schemaname not like 'SYS';
select * from dba_tab_privs where grantee = 'MLOG$_VI_CHANNEL_T';
select * from dba_tab_privs where grantee = 'OERR';
@logon:
------
set lines 190
select sid,serial#,program ,to_char(logon_time,'DD-MM-YYYY HH24:MI:SS'),SQL_HASH_VALUE,username,sql_id from gv$session where schemaname not like 'SYS' and status='ACTIVE' order by logon_time;
======================
set lines 180
col username for a20
col machine for a25
col module for a45
col sql_id for a20
select count(*),username,sql_id,status,osuser,machine,module from v$session group by username,status,osuser,machine,module,sql_id order by 3;
==============
select sid,serial#,program ,to_char(logon_time,'DD-MM-YYYY HH24:MI:SS'),SQL_HASH_VALUE,sql_id from gv$session where sql_id is not null;
select sid,serial#,program ,to_char(logon_time,'DD-MM-YYYY HH24:MI:SS'),SQL_HASH_VALUE,sql_id from gv$session where sid=183;
Abhi. 9766673333
Riyaz FreeSpace:
=================
set pages 999
col tablespace_name format a40
col "size MB" format 999,999,999
col "free MB" format 99,999,999
col "% Used" format 999
select tsu.tablespace_name, ceil(tsu.used_mb) "size MB"
, decode(ceil(tsf.free_mb), NULL,0,ceil(tsf.free_mb)) "free MB"
, decode(100 - ceil(tsf.free_mb/tsu.used_mb*100), NULL, 100,
100 - ceil(tsf.free_mb/tsu.used_mb*100)) "% used"
from (select tablespace_name, sum(bytes)/1024/1024 used_mb
from dba_data_files group by tablespace_name union all
select tablespace_name || ' **TEMP**'
, sum(bytes)/1024/1024 used_mb
from dba_temp_files group by tablespace_name) tsu
, (select tablespace_name, sum(bytes)/1024/1024 free_mb
from dba_free_space group by tablespace_name) tsf
where tsu.tablespace_name = tsf.tablespace_name (+)
AND tsu.tablespace_name like '%TEMP%'
order by 4;
--AND tsu.tablespace_name like '%&TBS_NAME%'
prompt ======================Checking Datafiles of TABLESPACE=================================================
Yogesh / Farhad - 9921795572
Jaianand harik. - 9820237054
column file_name format a55
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&UNDO%' order by 3;
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
select count(file_id) from dba_data_files where tablespace_name like '%&TBS%';
column file_name format a55
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where file_name like '%&UNDO%' order by 3;
column file_name format a55
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where autoextensible='YES' order by 6;
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where file_name like '%&UNDO%' order by 3;
alter system set session_cached_cursors=150 scope=both sid='FBAU3FCR2';
srvctl relocate service -d fcprdfcr -s fcprodnode2 -i FBAU3FCR2 -t FBAU3FCR1
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where file_name like '%&FIleName%' order by 2;
select * from v$sort_usage -- No rows should be there to resize temp Tablespace
select * from v$undostat -- to Check UNDO Tablespace
select tablespace_name,count(file_name),sum(bytes/1024/1024) from dba_data_files group by tablespace_name order by 2;
select distinct tablespace_name,status,file_id,bytes,blocks,owner from DBA_UNDO_EXTENTS where status='UNEXPIRED' order by 1,3;
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%SYSTEM%';
== Check Possible Shrink
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&Ams%' order by 1;
select file_id,max((block_id+blocks-1)*8192)/1024/1024 from dba_extents where TABLESPACE_NAME like '%&AMS_MASTER%' group by file_id order by 1;
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where file_name like '%&AMS_MASTER%' order by 1;
select file_id,max((block_id+blocks-1)*8192)/1024/1024 from dba_extents where file_name like '%&AMS_MASTER%' group by file_id order by 1;
col segment_name for a30
set pages 200
set lines 200
select segment_name,file_id,sum(bytes/1024) from dba_extents where file_id = 43 group by segment_name,file_id;
set linesize 150
column file_name format a50
column tablespace_name format a10
column free_space format 9999.9999
select ddf.file_name
,ddf.tablespace_name
,sum(dfs.bytes)/1024/1024 free_space
from dba_data_files ddf, dba_free_space dfs
where ddf.file_id = dfs.file_id
and ddf.tablespace_name like 'MP1_DATA'
group by ddf.file_name,ddf.tablespace_name;
ALTER TABLE AUD$ DEALLOCATE UNUSED KEEP 500M;
@tempfile:
RESIZE :
ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' RESIZE 18M;
============
SHRINK :
ALTER TABLESPACE temp SHRINK SPACE KEEP 20M;
ALTER TABLESPACE temp SHRINK TEMPFILE '+FRA/hdfcuat/tempfile/temp.507.721312809';
=========================================
DROP Single Tempfile :
ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' DROP INCLUDING DATAFILES;
===========================================
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp_grp;
===================================
col file_name for a45
select tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files order by file_name;
=========================
col TABLESPACE for a10
col FILENAME for a50
set lines 190
SELECT d.tablespace_name tablespace , d.file_name filename, d.file_id fl_id, d.bytes/1024/1024
size_m
, NVL(t.bytes_cached/1024/1024, 0) used_m, TRUNC((t.bytes_cached / d.bytes) * 100) pct_used
FROM
sys.dba_temp_files d, v$temp_extent_pool t, v$tempfile v
WHERE (t.file_id (+)= d.file_id)
AND (d.file_id = v.file#);
==================================
alter tablespace temp add tempfile '&tempfilepath' size 1800M;
=======================================================
== Check Posible UNDO Shrink.
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&UNDO%' order by 3;
select file_id,max((block_id+blocks-1)*8192)/1024/1024 from dba_extents where TABLESPACE_NAME like '%&UNDO%' group by file_id order by 1;
=============================================
select object_type,count(object_type) from dba_objects where owner = 'SAM_SIT' group by rollup(object_type);
select sid,serial#,program,action,event from v$session where program like '%imp%';
select count(*) from dba_indexes where owner = 'SAM_SIT';
select object_name,owner,object_type,status from dba_objects where object_id=307196;
=============================================
set pages 200
set lines 200
column machine format a18
column event format a35
column program format a33
column schemaname for a10
column username for a10
column action format a50
col LT for a21
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,schemaname,username,status from v$session where logon_time like sysdate and schemaname <> 'SYS' order by logon_time desc;
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,schemaname,status from v$session where logon_time not like sysdate and schemaname <> 'SYS' order by logon_time;
col sidd for a55
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' SIDD --, Program
from v$session
where to_char(logon_time,'dd-mm-yyyy hh24') like '01-08-2014 21' and schemaname <> 'SYS' and program like 'JDBC%';
and lower(program) like 'plsqldev.exe' order by logon_time;
col sidd for a55
col LT for a22
col program for a30
col schemaname for a12
col osuser for a10
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' SIDD, to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,program,osuser, schemaname from v$session
where logon_time < sysdate - 1 and schemaname <> 'SYS' order by logon_time;
col osuser for a10
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' SIDD, to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,program,osuser,status from v$session
where osuser in ('bzp8xz', 'bz3l0j','bzztqb') order by 2;
--where sid=&SID;
select * from v$sess_io where sid in (select sid from v$session where program like '%(J0%');
select sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,schemaname,status from v$session order by logon_time;
col program for a30
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname from v$session order by logon_time;
@session:
set pages 200
set lines 200
column machine format a20
column event format a35
column program format a30
column schemaname for a10
column action format a50
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,status from v$session where schemaname not like 'SYS%' order by logon_time;
set pages 200
set lines 200
column machine format a20
column event format a35
column program format a20
column action format a20
column schemaname format a5
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,action from v$session where sid in
(select distinct sid from
v$statname n,v$sesstat s
where n.STATISTIC# = s.STATISTIC# and name like 'session%memory%');
col LT for a35
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,schemaname from v$session order by logon_time;
select spid, osuser, s.program from
v$process p, v$session s where p.addr=s.paddr
and id=&sid;
select sid,s.serial#, spid, osuser, s.program from
v$process p, v$session s where p.addr=s.paddr
and spid=&spid;
-- Enable row movement.
ALTER TABLE FLAG.FLAG_EMP_CFC_DETAIL ENABLE ROW MOVEMENT;
-- Recover space and amend the high water mark (HWM).
ALTER TABLE FLAG.FLAG_EMP_CFC_DETAIL SHRINK SPACE;
--- For UNDO
== Check Possible Shrink
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%UNDO%' order by 1;
select file_id,max((block_id+blocks-1)*8192)/1024/1024 from dba_extents where TABLESPACE_NAME like '%UNDO%' group by file_id order by 1;
SELECT to_char(stat.begin_time,'dd-mm-yyyy hh24:mi:ss'),
to_char(stat.end_time,'dd-mm-yyyy hh24:mi:ss'),
stat.undoblks * param.value / 1024 / 1024 undo_mb,
stat.undoblks * param.value / 1024 / 1024 / 10 / 60
undo_mb_per_sec,
stat.maxquerylen
FROM v$undostat stat,
v$parameter param
WHERE param.name = 'db_block_size';
ROLLBACK
select activeblks,UNEXPIREDBLKS,EXPIREDBLKS,TUNED_UNDORETENTION from v$undostat;
select distinct tablespace_name,status,file_id,bytes,blocks,owner from DBA_UNDO_EXTENTS where status<>'EXPIRED' order by 1;
select latch ,shrinks,extends,status,curext,curblk from V$ROLLSTAT where rownum <= 10;
SELECT TO_CHAR(BEGIN_TIME, 'MM/DD/YYYY HH24:MI:SS') BEGIN_TIME,
TO_CHAR(END_TIME, 'MM/DD/YYYY HH24:MI:SS') END_TIME,
UNDOTSN, UNDOBLKS, TXNCOUNT, MAXCONCURRENCY AS "MAXCON"
FROM v$UNDOSTAT WHERE rownum <= 144;
select tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&TBSP%';
create tablespace TBS_PRL_PROD1_INDX datafile '' size 2G;
@which Session is Using UNDO Tablespace ==============
col osuser for a15
col user for a10
col undo_tbs for a12
col SEGMENT_NM for a15
set pages 200
set lines 200
SELECT ds.TABLESPACE_NAME "UNDO_TBS",ds.RELATIVE_FNO "File Nos",r.name "SEGMENT_NM", s.sid, s.serial#,s.osuser, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,
substr(s.program, 1, 78) "COMMAND"
FROM sys.v_$session s, sys.v_$transaction t, sys.v_$rollname r,dba_segments ds
WHERE t.addr = s.taddr
and t.xidusn = r.usn
and ds.segment_name = r.name(+)
ORDER BY t.cr_get, t.phy_io;
SELECT r.name "RBS", s.sid, s.serial#,s.osuser, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,
substr(s.program, 1, 78) "COMMAND"
FROM sys.v_$session s, sys.v_$transaction t, sys.v_$rollname r
WHERE t.addr = s.taddr
and t.xidusn = r.usn
ORDER BY t.cr_get, t.phy_io;
arun.k74@wipro.com
select distinct tablespace_name,status,file_id,bytes,blocks,owner from DBA_UNDO_EXTENTS where status<>'EXPIRED' order by 1;
col program for a30
col event for a40
col action for a30
col username for a10
col schemaname for a5
select sid,serial#,program,event,action,schemaname,username from v$session where sid=;
==============================
CREATE PROFILE my_profile LIMIT
FAILED_LOGIN_ATTEMPTS 3 -- Account locked after 3 failed logins.
PASSWORD_LOCK_TIME 5 -- Number of days account is locked for. UNLIMITED required explicit unlock by DBA.
PASSWORD_LIFE_TIME 30 -- Password expires after 90 days.
PASSWORD_GRACE_TIME 3 -- Grace period for password expiration.
PASSWORD_REUSE_TIME 120 -- Number of days until a specific password can be reused. UNLIMITED means never.
PASSWORD_REUSE_MAX 10 -- The number of changes required before a password can be reused. UNLIMITED means never.
/
ALTER USER scott PROFILE my_profile;
alter profile DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
==============================
Advise
select distinct task_id,BENEFIT_TYPE from dba_advisor_recommendations where BENEFIT_TYPE like 'Enable%' order by BENEFIT_TYPE;
SELECT
r.type,
r.Rank,
r.benefit,
f.impact_type,
f.impact,
f.message
FROM
dba_advisor_recommendations r,
dba_advisor_findings f
WHERE r.task_name = 'TASK_4502'
AND r.finding_id = f.finding_id
AND r.task_id = f.task_id
ORDER BY r.rank ASC, r.benefit DESC;
===============
alter system set standby_file_management='manual';
alter database create datafile 'D:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\UNNAMED00196' as 'D:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\ams_transaction_data.317.718326941'
STEP1:- Check the name of the datafile on standby database
select name from v$datafile; ---- This command should show the datafile name as UNNAMEDxxxxx
STEP2:- ON STANDBY DATABASE
alter system set standby_file_management='manual';
STEP3:- Rename the datafile
alter database create datafile 'C:\ORACLE\ORA10G\DATABASE\UNNAMED00129' as 'C:\ORACLE\ORA10G\DATABASE\actual_dbfile_name.dbf'
STEP4:- On the standby database
alter system set standby_file_management='auto';
STEP5:- On the standby database
recover managed standby database disconnect;
shutdown and then reopen the standby database and continue applying the redo logs
SQL> show parameter stand
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_archive_dest string %ORACLE_HOME%\RDBMS
standby_file_management string AUTO
SQL>
547 - 2
== If alter database create datafile 'OLD File' as 'NEW File'; Doesnot work
SQL> alter system set standby_file_management='AUTO'; -- Parameter status need to be checked
RMAN> run {
2> set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00012' to '+DATA_IDEAS/pinnacle/datafile/ideas.318.719999863';
3> restore datafile 12;
4> recover datafile 12;
5> }
alter database create datafile 'D:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\UNNAMED00005' as 'D:\APP\ORACLE\ORADATA\ORCL\DBSP101.DBF';
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history
where sequence# in (select max(sequence#) from v$log_history group by thread#);
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history
where sequence# = 567;
delete archivelog all completed before 'sysdate -1';
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history where sequence# = 3196;
RIYAZ STANDBY APPLIED APPLY LOG DETAILS
1. Please fire the sql first to determine which archive last came last and which was the last applied. Server standby 008
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd;
2. Check the archive gap.
SELECT PROCESS, STATUS,SEQUENCE#,BLOCK#,BLOCKS, DELAY_MINS FROM V$MANAGED_STANDBY;
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history
where to_char(first_time,'DD-MON-YY') >= '11-MAY-14' and to_char(first_time,'DD-MON-YY') <= '11-MAY-14';
alter database create standby controlfile as '/b01/backup/STANDBY_CTL.ctl';
alter database backup controlfile to trace;
alter database backup controlfile to 'g:\Controlfile.ctl';
alter database backup controlfile to '/home/ais/oradw/rr/control_SP1.ctl';
SCN RMAN RESTORE -- If Standby ARCHIVE Files are Missing
=========================================================
1....On Primary & Standby Database.
SQL> select name,open_mode,CURRENT_SCN from v$database;
SQL> select scn_to_timestamp(1447102) from dual; ---- e.g SCN NOS.
2....On Primary Database. ( a OR b OR c) ----- Take SCN Nos. from v$database (as above)
a. RMAN> BACKUP DEVICE TYPE SBT INCREMENTAL FROM SCN 750923 DATABASE;
b. RMAN> BACKUP INCREMENTAL FROM SCN 750923 DATABASE;
c. RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750983 DATABASE FORMAT '/tmp/incr_standby_%U';
3....On Primary Database.
Backup Controlfile
SQL> alter database create standby controlfile as 'BACKUP LOCATION\STANDBY_CTL.ctl';
4.... COPY Backedup FILES to Standby DB Server.
5.... On Standby Database.
SQL> shut immediate.
SQL> startup nomount
RMAN> restore controlfile from 'CTL FILE SAVED LOCATION\Control.ctl';
SQL> alter database mount standby database;
SQL> alter system set standby_Management parameter to MANUAL
6....On Standby Database
$ rman target=/
RMAN> catalog start with '<BACKUP FILE STORED LOCATION>';
7....On Standby Database.
START RECOVER
RMAN> RECOVER DATABASE NOREDO;
8....On Standby Database.
SQL> select name,open_mode,CURRENT_SCN from v$database;
SQL> select scn_to_timestamp(1447102) from dual; ---- e.g SCN NOS.
select timestamp_to_scn('09-JAN-09:12:00:10') from dual;
select timestamp_to_scn('10-JAN-14:10:00:10') from dual;
select scn_to_timestamp(8733) from dual;
select scn_to_timestamp(3196) from dual;
SELECT TIMESTAMP_TO_SCN('10-JAN-14 10.00.09.000000000 AM') FROM dual;
9....On Standby Database.
*** START real time RECOVERY ***
====================
SELECT c.index_name, i.uniqueness, c.column_name
FROM user_indexes i, user_ind_columns c
WHERE i.index_name = c.index_name
AND i.table_name = 'AMS_POLICY_DETAILS'
ORDER BY c.index_name, c.column_position
/
select thread#,max(sequence#) from v$log_history group by thread#;
create undo tablespace UNDOTBS002 datafile size 100M;
create undo tablespace UNDOTBS001 datafile size 100M;
select sum(bytes/1024/1024/1024) from dba_segments;
CREATE PUBLIC DATABASE LINK "CC_UAT1"
connect to WONUAT identified by WONUAT
using 'CCUAT';
Fcubuat2$
drop DATABASE LINK "FCCUAT.FCUBSMOLINK";
CREATE DATABASE LINK "FCUBSMOLINK"
connect to FCCMO_READ identified by Fccmo_1234
using 'MFUBSFLL25';
select DBMS_METADATA.GET_DDL('DB_LINK',db_link,OWNER) db_link_ddl
from dba_db_links
where db_link like '%&DB_LINK_Char%';
set long 9999999
select DBMS_METADATA.GET_DDL('TABLESPACE','TEMP') TEMP_TBS from dual;
from v$tempfile
where name like '%&DB_LINK_Char%';
set long 9999999
select DBMS_METADATA.GET_DDL('TABLESPACE',tablespace_name) TBS from dba_tablespaces where tablespace_name like 'SYSAUX';
BAAN.TTFGLD106954
set long 9999999
select DBMS_METADATA.GET_DDL('TABLE',table_name) TBS from dba_tables where table_name like 'TTFGLD106954';
set long 9999999
select DBMS_METADATA.GET_DDL('TABLE',table_name) TBS from dba_tables where table_name like 'COMP_CUSTOMER_HISTORY' and owner='CDB_ADMIN';
drop DATABASE LINK ARCHLINK_ECOD$.WORLD;
CREATE DATABASE LINK FLEXPROD_HOST.ARCHLINK_ECOD$.WORLD
CONNECT TO FC_ARCH_READ IDENTIFIED BY VALUES '05066CCD3894D446CB9C182BB5A2C0C5ABD2E8DC8ABF0DE9EB'
USING 'FCARCDB';
col owner for a20
col directory_path for a60
set lines 150
set pages 999
select * from dba_directories;
col GRANTEE for a20
col GRANTOR for a10
col PRIVILEGE for a15
select * from dba_tab_privs where table_name in (select DIRECTORY_NAME from dba_directories);
CREATE TEMPORARY TABLESPACE TEMP1 TEMPFILE '/u005/oradata/FDM11DVT/temp1_01.dbf' SIZE 1048M;
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1048576;
select DBMS_METADATA.GET_DDL('TABLESPACE','TEMP') from dual;
select DBMS_METADATA.GET_DDL('TABLESPACE','AMS_MASTER_DATA') from dual;
select DBMS_METADATA.GET_DDL('TABLESPACE','OCCLSS') from dual;
select DBMS_METADATA.GET_DDL('STARPERF',username) db_SCHEMA
from dba_USERS
where username like 'STARPERF';
set long 9999999
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS
where username like 'NEOLOG';
CREATE PUBLIC DATABASE LINK "AMS_Prod"
connect to AMSUAT identified by AMSUAT
using 'HDFCPROD11';
CREATE PUBLIC DATABASE LINK "HDFCDBIDB"
connect to IDBDOC identified by IDBDOC
using 'IDBPROD';
drop PUBLIC DATABASE LINK "AMS_Prod"
select 'grant select on ams.' || object_name || ' to amsuat;' from dba_objects where owner='AMS' and object_type = 'TABLE';
select dbms_metadata.get_ddl ('TABLE', 'AMS_USER_MASTER', 'AMS') from dual;
select dbms_metadata.get_ddl ('TABLE', 'AUD$', 'SYS') from dual;
select dbms_metadata.get_ddl ('TABLE', 'TTFGLD106954', 'BAAN') from dual;
select DBMS_METADATA.GET_DDL('TABLE',table_name,owner) TBS from dba_tables where table_name like 'TTFGLD106954' and owner='BAAN';
select dbms_metadata.get_ddl ('DB_LINK', 'CC_UAT', 'PUBLIC') from dual;
select dbms_metadata.get_ddl ('TABLE', 'KU$NOEXP_TAB1', 'SYS') from dual;
set long 999999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,owner) TBS from dba_tables where table_name like 'COMP_CUSTOMER_HISTORY' and owner='CDB_ADMIN';
set long 999999999
select DBMS_METADATA.GET_DDL('USER','STARPERF') db_SCHEMA from dual;
set long 999999999
select DBMS_METADATA.GET_DDL('USER','SAM_NEW') db_SCHEMA from dual;
CREATE USER "STARPERF" IDENTIFIED BY VALUES 'S:072FA01B7A9502EA75A18766B2385F
F6E827222215087CC72929D7721858;3C117B8C67D369D3'
DEFAULT TABLESPACE "AMS_TRANSACTION_DATA"
TEMPORARY TABLESPACE "TEMP"
column host format a6
column username format a10
column os_user format a8
column program format a30
column tsname format a12
select
b.machine host,
b.username username,
b.server,
b.osuser os_user,
b.program program,
a.tablespace_name ts_name,
row_wait_file# file_nbr,
row_wait_block# block_nbr,
c.owner,
c.segment_name,
c.segment_type
from
dba_data_files a,
v$session b,
dba_extents c
where
b.row_wait_file# = a.file_id
and
c.file_id = row_wait_file#
and
row_wait_block# between c.block_id and c.block_id + c.blocks - 1
and
row_wait_file# <> 0
and
type='USER'
;
=================
http://www.idevelopment.info/data/Oracle/DBA_tips/Automatic_Storage_Management/ASM_36.shtml
Moving database files from one diskgroup/mountpoint to other in ASM using RMAN
1) Database should be in archive log mode.
2) Take file offline which needs to be moved.
SQL > alter database datafile '+DATA1/hdfcuat/datafile/undotbs3.268.730589449' offline;
3) Use below cmd to copy datafile to other directory/mountpoint using below RMAN cmd. It will create file in other location with different name.
RMAN > COPY DATAFILE '+DATA1/hdfcuat/datafile/undotbs3.268.730589449' TO '+DATA2';
Above will create file in other location with different name.
4) Once the RMAN cmd is successfully executed, use below cmd to Rename old file to new file name.
SQL > ALTER DATABASE RENAME FILE '+DATA1/hdfcuat/datafile/undotbs3.268.730589449' to '+DATA2/hdfcuat/datafile/undotbs3.256.732542101';
5) Use below RMAN cmd to rename the ASM database file copy.
RMAN> SWITCH DATAFILE '+DATA2/hdfcuat/datafile/undotbs3.256.732542101' TO COPY;
6) Recover the New ASM datafile. (Copy all the archives in one location/server if there are multiple instances)
SQL> RECOVER DATAFILE '+DATA2/hdfcuat/datafile/undotbs3.256.732542101';
7) Bring New ASM datafile online.
SQL> ALTER DATABASE DATAFILE '+DATA2/hdfcuat/datafile/undotbs3.256.732542101' ONLINE;
8) Check status and file name with new location.
SELECT file_name FROM dba_data_files;
9) Drop old named datafile using below cmd if it exist in old path.
SQL> ALTER DISKGROUP +DATA1 DROP FILE '+DATA1/hdfcuat/datafile/undotbs3.268.730589449';
==========================================================================
We have created external table for Querying the CSV file from the same server & from Other Server. From the same server we are able to query & the ouput is fune , but to query the CSV file datas from other server we are facing Problem , below:
SQL> select * from test;
select * from test
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
error opening file \\HSLCC2\scott\TEST_3208_6236.log
Windows Server 2003 Enterprise x64 Edition (64Bit)
===============
SQL> select tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%UNDO%';
TABLESPACE_NAME FILE_NAME BYTES/1024/1024 AUT
------------------------------ ----------------------------------------------------------------- --------------- ---
UNDOTBS1 - hdfcuat1 +FRA/hdfcuat/datafile/undono1_11.dbf 2116.1875 YES
UNDOTBS2 - hdfcuat2 +DATA/hdfcuat/datafile/undotbs2.311.683717465 104 NO
UNDOTBS2 +DATA/hdfcuat/datafile/undotbs2.310.683717495 150 NO
UNDOTBS2 +DATA/hdfcuat/datafile/undotbs2.267.683717531 213 NO
UNDOTBS2 +FRA/hdfcuat/datafile/undotbs2.489.704573057 5400 YES
UNDOTBS002 +FRA/hdfcuat/datafile/undotbs002.492.716165505 100 NO
UNDOTBS2 +FRA/hdfcuat/datafile/undotbs2.487.704587779 3400 YES
UNDOTBS_01 +FRA/hdfcuat/datafile/undono1_1.dbf 7976.125 YES
UNDOTBS001 +DATA/hdfcuat/datafile/undotbs001.348.716165603 100 NO
9 rows selected.
prompt ======================TEMP TABLESPACE=================================================
SELECT tablespace_name, SUM(bytes_used/1024), SUM(bytes_free/1024)
FROM V$temp_space_header
GROUP BY tablespace_name;
prompt =================Finds Possible TABLESPACE Datafile to shrink==========================================
@shrink@
select 'alter database datafile '''||file_name ||''' resize '|| ceil( (nvl(hwm,1)*8192)/1024/1024 )||'m;' cmd from dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) b where a.file_id = b.file_id(+) and ceil(blocks*8192/1024/1024)- ceil((nvl(hwm,1)*8192)/1024/1024 ) > 0;
prompt ======================Possible TABLESPACE to Coalesce =================================================
select a.tablespace_name, a.file_id, a.block_id, a.blocks,b.block_id
from dba_free_space a, dba_free_space b
where a.tablespace_name like '%DATA%'
and b.tablespace_name like '%DATA%'
and a.file_id = b.file_id
and a.block_id+a.blocks = b.block_id;
DBA
=====
vinay 9820468856
Dhawal 9833105884
prasad 9920769718
prompt ======================Possible Alter Database TABLESPACE=================================================
select 'alter database datafile '''||file_name ||''' resize '|| ceil( (nvl(hwm,1)*8192)/1024/1024 )||'m;' cmd
from dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) b
where a.file_id = b.file_id(+)
and ceil(blocks*8192/1024/1024)- ceil((nvl(hwm,1)*8192)/1024/1024) > 0
and tablespace_name like '%UNDO%';
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%SYSTEM%';
select file_id,file_name,blocks,MAXBLOCKS from dba_data_files where TABLESPACE_NAME = 'SYSTEM';
select file_id,max(block_id) from dba_extents where TABLESPACE_NAME = 'SYSTEM' group by file_id;
===================================================================
Datafile
set linesize 150
column file_name format a50
column tablespace_name format a10
column free_space format 9999.9999
select ddf.file_name
,ddf.tablespace_name
,sum(dfs.bytes)/1024/1024 free_space
from dba_data_files ddf, dba_free_space dfs
where ddf.file_id = dfs.file_id
and ddf.tablespace_name like 'USERS'
group by ddf.file_name,ddf.tablespace_name;
===================================================================
External Value -- Hidden Parameters
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_px_xtgranule_size%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_compression_comp%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_job_queue_interval%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_cr_server_log_flush%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_fix_control%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_allow_resetlogs_corruption%';
_allow_resetlogs_corruption
alter system set "_allow_resetlogs_corruption"=TRUE scope=spfile;
SQL> alter system set "_compression_compatibility"='11.2.0.0.0' scope=both;
System altered.
SQL>
SQL>
Hi,
Possible hot blocks in the buffer cache normally can be identified by a high or rapid increasing wait count on the CACHE BUFFERS CHAINS latch.
This latch is acquired when searching for data blocks cached in the buffer cache.
Since the Buffer cache is implemented as a sum of chains of blocks, each of those
chains is protected by a child of this latch when needs to be scanned. Contention
in this latch can be caused by very heavy access to a single block. This can
require the application to be reviewed.
ACTION PLAN
===========
Please perform the following action plan during the time of issue.
First determine which latch id(ADDR) are interesting by examining the number of
sleeps for this latch. The higher the sleep count, the more interesting the
latch id(ADDR) is:
SQL> select CHILD# "cCHILD"
, ADDR "sADDR"
, GETS "sGETS"
, MISSES "sMISSES"
, SLEEPS "sSLEEPS"
from v$latch_children
where name = 'cache buffers chains'
order by 5, 1, 2, 3;
Run the above query a few times to to establish the id(ADDR) that has the most
consistent amount of sleeps. Once the id(ADDR) with the highest sleep count is found
then this latch address can be used to get more details about the blocks
currently in the buffer cache protected by this latch.
The query below should be run just after determining the ADDR with
the highest sleep count.
SQL> column segment_name format a35
select /*+ RULE */
e.owner ||'.'|| e.segment_name segment_name,
e.extent_id extent#,
x.dbablk - e.block_id + 1 block#,
x.tch,
l.child#
from
sys.v$latch_children l,
sys.x$bh x,
sys.dba_extents e
where
x.hladdr = '&ADDR' and
e.file_id = x.file# and
x.hladdr = l.addr and
x.dbablk between e.block_id and e.block_id + e.blocks -1
order by x.tch desc ;
Example of the output :
SEGMENT_NAME EXTENT# BLOCK# TCH CHILD#
-------------------------------- ------------ ------------ ------ ----------
SCOTT.EMP_PK 5 474 17 7,668
SCOTT.EMP 1 449 2 7,668
column segment_name format a35
select /*+ RULE */
e.owner ||'.'|| e.segment_name segment_name,
e.extent_id extent#,
x.dbablk - e.block_id + 1 block#,
x.tch,
l.child#
from
sys.v$latch_children l,
sys.x$bh x,
sys.dba_extents e
where
x.hladdr = '&ADDR' and
e.file_id = x.file# and
x.hladdr = l.addr and
x.dbablk between e.block_id and e.block_id + e.blocks -1
order by x.tch desc ;
www.tirumala.org
select * from (select CHILD# "cCHILD"
, ADDR "sADDR"
, GETS "sGETS"
, MISSES "sMISSES"
, SLEEPS "sSLEEPS"
from v$latch_children
where name = 'cache buffers chains' and rownum <= 20
order by 5 desc) a
where rownum <= 20;
Depending on the TCH column (The number of times the block is hit by a SQL
statement), you can identify a hotblock. The higher the value of the TCH column,
the more frequent the block is accessed by SQL statements.
In order to reduce contention for this object the following mechanisms can be put in place:
1) Examine the application to see if the execution of certain DML and SELECT statements
can be reorganized to eliminate contention on the object.
2) Decrease the buffer cache -although this may only help in a small amount of cases.
3) DBWR throughput may have a factor in this as well.
If using multiple DBWR's then increase the number of DBWR's.
4) Increase the PCTFREE for the table storage parameters via ALTER TABLE
or rebuild. This will result in less rows per block.
5) Consider implementing reverse key indexes
(if range scans aren't commonly used against the segment)
2)Also upload the AWR report for the duration of 60min during the Good & Bad Period.
Regards
Naveen
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' "sids", to_char(logon_time,'dd-mm-yyyy hh24:mi'),username,schemaname,program from v$session where sid in (select SESSION_ID from v$locked_object where object_id = 172419)
order by 2;
col schemaname for a10
col program for a30
col sids for a70
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' "sids", to_char(logon_time,'dd-mm-yyyy hh24:mi'),status,username,schemaname,program
from v$session
where logon_time < sysdate - 20 and schemaname not like 'SYS%'
order by 2;
select sid,event,schemaname,module,to_char(logon_time,'dd/mm/yyyy hh:mi') from v$session where event like 'latch%' order by 5;
==================================================================================
DBAsupport.com Forums > Archives > Forum Archives > PCTFREE Vs PCTUSED
--------------------------------------------------------------------------------
PDAClick to See Complete Forum and Search --> : PCTFREE Vs PCTUSED
--------------------------------------------------------------------------------
ckwan02-23-2001, 08:12 PM
Dear all,
I want to pour some questions on the above topic questions :
1. I come across a statement saying that PCTUSED Parameter explanation - After a data block becomes full, as determined by PCTFREE, Oracle does not consider the block for the insertion of new rows until the percentage of the block being used falls below the parameter PCTUSED. Before this value is archived, Oracle uses the free space of the data block only for updates to rows already contained in the data block.
Q : What is the reason for this - PCTUSED ? Why they want to control that parameter ? Can I set it to 0 ?
Q: Is free list this pre-allocated ? Is this only use for PCTFREE ? Where does it store ?
Your answer is very much appreciated. Thanks.
--------------------------------------------------------------------------------
IT_girl20002-24-2001, 02:04 AM
hope this will provide you your answer...
The PCTFREE parameter specifies the percentage of
space in each data block that is reserved for growth
resulting from updates of rows in that data block. This
parameter has a default value of 10 percent.
For example, the value of the PCTFREE parameter is
specified as 20 in a CREATE TABLE statement. This
indicates that inserts to the block should stop as soon as
free space drops to 20 percent or less. The free space
thereafter can only be used for updates.
The PCTUSED parameter represents the minimum
percentage of the used space that the Oracle server tries
to maintain for each data block of the table. This
parameter has a default value of 40 percent.
When a data block is filled to the limit determined by the
value of the PCTFREE parameter, Oracle considers the
block unavailable for the insertion of new rows. The block
is unavailable for the insertion of new rows until the
percentage filled by the data of that block falls below the
value of the PCTUSED parameter.
Until the percentage of the block falls below the value of
the PCTUSED parameter, Oracle uses the free space of
the data block only for updating the rows contained in the
data block.
For example, if PCTUSED is defined as 40 percent, the
block is reused for inserts as soon as utilization drops to
less than 40 percent. Inserts continue until utilization
reaches 80 percent and the cycle repeats.
--------------------------------------------------------------------------------
rohitsn02-24-2001, 02:31 AM
Pctused and Pctfree are block storage parameters.
Pctused is used to find out how much percentage of the block will be used to store rows.Pctfree is used to find out how much percentage of the block will be used to store rows resulting from further updates to the rows in the same datablock.
Eg. If u keep pctused to 40% and pctfree 20.so u can insert rows till 40 %.if the limit exceeds 40%,still also u can insert rows in the datablock till the limit reaches 80% (100%-20%) as u have kept pctfree to 20%.Now if one goes on deleting the rows,the block is not said to be free unless and until pctused falls below 40%.As soon as pctused falls below 40% from deleting the rows, that block can be used to insert the rows.In this way the cycle continous.So it is recommended that u never sum up pctused+pctfree=100.Always have some gap between them this helps in reducing ur Oracle server for allocation and disallocation of freelists.
If any further doubts write to rohitsn@hotmail.com
--------------------------------------------------------------------------------
tamilselvan02-25-2001, 11:48 AM
This is an interesting question. I would like to share my experience.
In the last 3 months, I had interviewed 15 Oracle DBAs and asked the same question. Only one person answered correctly.
Both the parameters are applicable and used for each data block in the Database. I hope an example will give you the right answer.
Consider 8K block size. The total bytes 8 x 1024 = 8196 bytes
Each block requires approximately 117 bytes for the header. Please note that the header size varies depending upon the block size.
The total available bytes for data = ( 8196 – 117) = 8079 bytes.
A table is created with PCTFREE 20 PCTUSED 50 .
PCTRFREE in bytes = 1615
PCTUSED in bytes = 4039
Now the data available for insert and update = (8079 – (20 * 8079)/100 ) = 6463 Bytes.
Now user can insert new rows into this block as long as the old rows’ total bytes + new row’s total byte is less than or equal to 6463 bytes. If the new row’s total byte cannot be put into this block, then Oracle will get the next block from the free list, and inserts into it.
When a row is updated and the row’s data is expanded, then PCTFREE come into play. The updated row’s data is placed into PCTFREE’s area, provided the updated row’s new data can be fit into PCTFREE area. If it is not fit into that area, another new block will be obtained from the Freelist, and the row will be migrated. But the original row info (pointer) is kept in the old block. For subsequent access to this row involves 2 read I/O. That is why row migration should be avoided because of excessive I/Os.
ROW DELETION:
The PCTUSED parameter value (in this example 50 %) is the threshold limit for the old block to be added in the FREELIST. To understand better, let us assume that a block is of full data. Now the user starts deleting rows from the block. When a row is deleted, Oracle does not put the block into the FREELIST because it requires many recursive calls to update the FREELIST. The PCTUSED % (50) determines when the block should be added into FREELIST. When the total bytes in the block is less than or equal to 4039 bytes, then the block will be added into FREELIST.
If a table has high inserts and high deletion, then you should decrease the PCTUSED value in order to minimize the frequent update of FREELIST.
The best confidence booster is knowledge. Good Luck, guys.
--------------------------------------------------------------------------------
tamilselvan02-26-2001, 11:03 AM
Correction in earlier post.
The overhead for each block is 107 bytes, not 117 bytes.
Tamilselvan
--------------------------------------------------------------------------------
sambavan02-26-2001, 11:27 AM
That was one damn good explanation. But on reading this thread, I'm getting more questions than that of answers.
1. How do one get to check the over head for different block_sizes.
2. What happens when one sets the PCTFREE to 80%
Sorry for such a lame question, but was curious to know the answer, atleast to the first one.
Thanx,
Sam
--------------------------------------------------------------------------------
tamilselvan02-26-2001, 11:41 AM
Oracle says the overhead for each block varies from 84 bytes to 107 bytes.
I do not know how to cross check over head bytes for various block sizes.
Does anybody know the answer?
--------------------------------------------------------------------------------
pando02-26-2001, 11:44 AM
if pctfree is high then basically we are wasting hard drive space since only 10% of block is used for inserts, of course if you consider that you will update the rows so often and fill the 80% up then it´s up to you but I think it´s pretty rare
I say 10% but it can be less since pctfree+pctused cant be more than 100 and if we set pctused 20 and pctfree 80 most probably we will face perfomance issues because the block has to be put on freelist and taken off free list all the time.
As for block overhead I think there is a formula in Oracle DBA Handbook
--------------------------------------------------------------------------------
badrinathn02-26-2001, 11:47 AM
To add on to the question pool,
I understand that the pctused is used by oracle to put the block into the free list for future inserts.
1) Will any new blocks(extends) added will directly put into the freelist ?
2) I know that I have a table, in which I rarely have any updates and deletes but only insertions, then can I set the parameters for
PCT FREE = 100
and PCT USED=0?
Badrinath
--------------------------------------------------------------------------------
LND02-26-2001, 12:11 PM
badrinathn:
on site http://www.ixora.com.au/q+a/datablock.htm is good discussion of that issue. from my understanding, new blocks goes to so called master free list.
pctused=0 and pctfree=100 would make sense for insert only table.
--------------------------------------------------------------------------------
rsuri02-26-2001, 12:48 PM
shouldn't pctfree be more like 'Zero' for insert-only table ?
pctfree = 100 means nothing can be inserted !
--------------------------------------------------------------------------------
badrinathn02-26-2001, 12:52 PM
Hey, Thats correct,
In that case , for a insert only tables it means
pctfree = 0
and
pctused = 0
Advisors, what do you say?
--------------------------------------------------------------------------------
tamilselvan02-26-2001, 02:02 PM
When PCTFREE is set to 0, then every update on a row requires a row migration.
When PCTUSED is set to 0 , then after deleting all rows in the block, it will be added into FREELIST.
--------------------------------------------------------------------------------
pranavgovind12-19-2007, 09:22 PM
All,I just read this thread and i see very useful information. I just want to share my thoughts for PCTUSED Vs PCTFREE for insert only tables.
PCTFREE = 0 AND PCTUSED value does matter for insert only tables. PCTUSED will not play the role as long as we are not deleting any data in the block. Another point here is, we can not set PCTUSED=100 or PCTFREE = 100. The value 100 is invalid value. Also sum of PCTUSED and PCTFREE can not exceed 100. Pease reply if any one is not agreeing. Thanks
SQL> create table test
2 (no number)
3 pctused 0
4 pctfree 100;
pctfree 100
*
ERROR at line 4:
ORA-02211: invalid value for PCTFREE or PCTUSED
SQL> create table test(no number)
2 pctused 60
3 pctfree 41;
create table test(no number)
*
ERROR at line 1:
ORA-04000: the sum of PCTUSED and PCTFREE cannot exceed 100
--------------------------------------------------------------------------------
davey23uk12-21-2007, 02:17 PM
its 6 years old for gods sake
--------------------------------------------------------------------------------
dbasupport.com
Copyright 2010 Internet.com Inc. All Rights Reserved.
========================================================================================
======= Datagaurd
Max Details in \\10.50.11.28\d$\ronak\Datagaurd folder
select sequence#, applied from v$archived_log order by sequence#;
alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;
col name for a13
col value for a13
col unit for a30
set lines 132
select name, value, unit, time_computed from v$dataguard_stats where name in ('transport lag', 'apply lag');
select to_char(start_time, 'DD-MON-RR HH24:MI:SS') start_time, item , sofar
from v$recovery_progress
where item in ('Active Apply Rate', 'Average Apply Rate', 'Redo Applied');
@genarc:
-------
select to_char(trunc(first_time), 'Mon DD') "DG Date",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "12am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "01am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "02am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "03am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "04am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "05am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "06am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "07am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "08am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "09am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "10am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "11am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "12pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "01pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "02pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "03pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "04pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "05pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "06pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "07pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "08pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "09pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "10pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "11pm"
from v$log_history
group by trunc(first_time)
order by trunc(first_time) desc
;
select thread#, low_sequence#, high_sequence# from v$archive_gap;
select dest_id,max(sequence#), thread# from v$archived_log group by thread#,dest_id;
## On the primary run the below
select L.thread#, L.sequence#
from
(select thread#, sequence# from v$archived_log where dest_id=1) L
where L.sequence# not in
(select sequence# from v$archived_log where dest_id=2 and thread# = L.thread#);
select to_char(start_time, 'DD-MON-RR HH24:MI:SS') start_time, item , sofar
from v$recovery_progress
where item in ('Active Apply Rate', 'Average Apply Rate', 'Redo Applied');
col name for a13
col value for a13
col unit for a30
set lines 132
select name, value, unit, time_computed from v$dataguard_stats where name in ('transport lag', 'apply lag');
col name for a25
col value for a20
col unit for a40
select distinct name, value, unit, time_computed from v$dataguard_stats;
SELECT MESSAGE FROM V$DATAGUARD_STATUS;
select message, to_char(timestamp,’HH:MI:SS’) timestamp
from v$dataguard_status
where severity in (‘Error’,’Fatal’)
order by timestamp
col type for a30
col COMMENTS for a30
select * from v$recovery_progress;
col client_pid for a10;
select pid, process, status, client_process, client_pid, thread#, sequence#, block#, blocks from v$managed_standby;
select * from V$ARCHIVE_DEST_STATUS where dest_name like 'LOG_ARCHIVE_DEST_2';
select current_scn from v$database;
select scn_to_timestamp(190469922) from dual;
=======================================================================================
PGA
From Oracle FAQ
Jump to: navigation, search
The PGA (Program or Process Global Area) is a memory area (RAM) that stores data and control information for a single process. For example, it typically contains a sort area, hash area, session cursor cache, etc.
[edit] Auto tuning
PGA areas can be sized manually by setting parameters like hash_area_size, sort_area_size etc.
To allow Oracle to auto tune the PGA areas, set the WORKAREA_SIZE_POLICY parameter to AUTO and the PGA_AGGREGATE_TARGET to the size of memory that can be used for PGA. This feature was introduced in Oracle 9i.
Oracle 11g allows users to tune both PGA and SGA areas with a single parameter, called MEMORY_TARGET.
[edit] Monitor
PGA usage statistics:
select * from v$pgastat;
Determine a good setting for pga_aggregate_target:
select * from v$pga_target_advice order by pga_target_for_estimate;
Show the maximum PGA usage per process:
select max(pga_used_mem), max(pga_alloc_mem), max(pga_max_mem) from v$process;
# tnsnames.ora.ideasmintdb Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora.ideasmintdb
# Generated by Oracle configuration tools.
IPC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = IPC_test1))
)
(CONNECT_DATA =
(SERVICE_NAME = IDEAS2)
)
)
MINT =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MINT)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
HDFCDBPROD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.0.201)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = HDFCDB)
)
)
LISTENER_MINT2 =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.1.95)(PORT = 1521))
LISTENER_MINT1 =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.1.94)(PORT = 1521))
LISTENERS_PINNACLE =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
)
PINNACLE2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PINNACLE)
(INSTANCE_NAME = PINNACLE2)
)
)
PINNACLE1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PINNACLE)
(INSTANCE_NAME = PINNACLE1)
)
)
LISTENER_+ASM2 =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
PINNACLE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PINNACLE)
)
)
hdfcprod_new =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 124.30.56.83)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 124.30.56.84)(PORT = 1521))
(LOAD_BALANCE = yes)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = hdfcprod)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
MINT2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MINT)
(INSTANCE_NAME = MINT2)
)
)
MINT1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MINT)
(INSTANCE_NAME = MINT1)
)
)
IDEASUAT =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.0.252)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = IDEASUAT)
)
)
LISTENERS_MINT =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
)
===== GOLDEN GATE
SQL> @$GGATE/marker_setup.sql
SQL> @$GGATE/ddl_setup.sql
SQL> @$GGATE/role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ggate;
SQL> @$GGATE/ddl_enable.sql
--extract group--
extract ext1
--connection to database--
userid ggate@prim, password qwerty
--hostname and port for trail--
rmthost newods, mgrport 7807
--path and name for trail--
rmttrail D:\GGS\v22234-01-170861\DIRDAT\CA
--DDL support
ddl include mapped objname sender.*;
--DML
table sender.*
extract ext1
userid ggate@prim, password qwerty
rmthost newods, mgrport 7807
rmttrail D:\GGS\v22234-01-170861\DIRDAT\CE
ddl include mapped objname sender.*;
table sender.*
add exttrail D:\GGS\v22234-01-170861\DIRDAT\CE, extract ext1
GGSCI (newods) 261> view params load1
EXTRACT load1
EXTTRAIL D:\GGS\v22234-01-170861\DIRDAT\CA
DISCARDFILE D:\GGS\v22234-01-170861\DIRRPT\EXTPUMP_DSC_CA.RPT,PURGE
USERID sys@prim, PASSWORD ggs sysdba
TABLE ggs.info;
view params global
GGSCHEMA ggate
CHECKPOINTTABLE ggate.checkpoint
delete replicat rep1, exttrail D:\GGS\v22234-01-170861\DIRDAT\CA, checkpointtable ggate.checkpoint
alter replicat rep3, exttrail D:\GGS\v22234-01-170861\DIRDAT\CE, checkpointtable ggate.checkpoint
--Replicat group --
replicat rep3
--source and target definitions
ASSUMETARGETDEFS
--target database login --
userid ggate@prim, password qwerty
--file for dicarded transaction --
discardfile D:\GGS\v22234-01-170861\DISCARD\rep3_discard.txt, append, megabytes 10
--ddl support
DDL
--Specify table mapping ---
map sender.*, target rr.*;
This example illustrates using the GoldenGate direct load method to extract records from an Oracle 11g database on Red Hat Linux platform and load the same into an Oracle 11g target database on an AIX platform.
The table PRODUCTS in the SH schema on the source has 72 rows and on the target database the same table is present only in structure without any data. We will be loading the 72 rows in this example from the source database to the target database using GoldenGate Direct Load method.
On Source
1) Create the Initial data extract process ‘load1'
GGSCI (redhat346.localdomain) 5> ADD EXTRACT load1, SOURCEISTABLE
EXTRACT added.
Since this is a one time data extract task, the source of the data is not the transaction log files of the RDBMS (in this case the online and archive redo log files) but the table data itself, that is why the keyword SOURCEISTABLE is used.
2) Create the parameter file for the extract group load1
EXTRACT: name of the extract group
USERID/PASSWORD: the database user which has been configured earlier for Extract ( this user is created in the source database)
RMTHOST: This will be the IP address or hostname of the target system
MGRPORT: the port where the Manager process is running
TABLE: specify the table which is being extracted and replicated. This can be specified in a number of ways using wildcard characters to include or exclude tables as well as entire schemas.
GGSCI (redhat346.localdomain) 6> EDIT PARAMS load1
EXTRACT load1
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST devu007, MGRPORT 7809
RMTTASK replicat, GROUP load2
TABLE sh.products;
On Target
3) Create the initial data load task ‘load2'
Since this is a one time data load task, we are using the keyword SPECIALRUN
GGSCI (devu007) 1> ADD REPLICAT load2, SPECIALRUN
REPLICAT added.
4) Create the parameter file for the Replicat group, load2
REPLICAT: name of the Replicat group created for the initial data load
USERID/PASSWORD: database credentials for the Replicat user (this user is created in the target database)
ASSUMETARGETDEFS: this means that the source table structure exactly matches the target database table structure
MAP: with GoldenGate we can have the target database structure entirely differ from that of the source in terms of table names as well as the column definitions of the tables. This parameter provides us the mapping of the source and target tables which is same in this case
GGSCI (devu007) 2> EDIT PARAMS load2
“/u01/oracle/software/goldengate/dirprm/rep4.prm” [New file]
REPLICAT load2
USERID ggs_owner, PASSWORD ggs_owner
ASSUMETARGETDEFS
MAP sh.customers, TARGET sh.customers;
On Source
SQL> select count(*) from products;
COUNT(*)
———-
72
On Target
SQL> select count(*) from products;
COUNT(*)
———-
0
On Source
5) Start the initial load data extract task on the source system
We now start the initial data load task load 1 on the source. Since this is a one time task, we will initially see that the extract process is runningand after the data load is complete it will be stopped. We do not have to manually start the Replicat process on the target as that is done when the Extract task is started on the source system.
On Source
GGSCI (redhat346.localdomain) 16> START EXTRACT load1
Sending START request to MANAGER …
EXTRACT LOAD1 starting
GGSCI (redhat346.localdomain) 28> info extract load1
EXTRACT LOAD1 Last Started 2010-02-11 11:33 Status RUNNING
Checkpoint Lag Not Available
Log Read Checkpoint Table SH.PRODUCTS
2010-02-11 11:33:16 Record 72
Task SOURCEISTABLE
GGSCI (redhat346.localdomain) 29> info extract load1
EXTRACT LOAD1 Last Started 2010-02-11 11:33 Status STOPPED
Checkpoint Lag Not Available
Log Read Checkpoint Table SH.PRODUCTS
2010-02-11 11:33:16 Record 72
Task SOURCEISTABLE
On Target
SQL> select count(*) from products;
COUNT(*)
———-
72
Coming Soon! – Creating an Online Extract and Replicat Group for Change Synchronization …..
http://gavinsoorma.com/2010/02/goldengate-concepts-and-architecture/
The Data Pump (not to be confused with the Oracle Export Import Data Pump) is an optional secondary Extract group that is created on the source system. When Data Pump is not used, the Extract process writes to a remote trail that is located on the target system using TCP/IP. When Data Pump is configured, the Extract process writes to a local trail and from here Data Pump will read the trail and write the data over the network to the remote trail located on the target system.
The advantages of this can be seen as it protects against a network failure as in the absence of a storage device on the local system, the Extract process writes data into memory before the same is sent over the network. Any failures in the network could then cause the Extract process to abort (abend). Also if we are doing any complex data transformation or filtering, the same can be performed by the Data Pump. It will also be useful when we are consolidating data from several sources into one central target where data pump on each individual source system can write to one common trail file on the target.
Create the Extract process
GGSCI (devu007) 1> ADD EXTRACT ext1, TRANLOG, BEGIN NOW
EXTRACT added.
Create a local trail
Using the ADD EXTRAIL command we will now create a local trail on the source system where the Extract process will write to and which is then read by the Data Pump process. We will link this local trail to the Primary Extract group we just created, ext1
GGSCI (devu007) 3> ADD EXTTRAIL /u01/oracle/software/goldengate/dirdat/lt, EXTRACT ext1
EXTTRAIL added.
Create the Data Pump group
On the source system create the Data Pump group and using the EXTTRAILSOURCE keywork specify the location of the local trail which will be read by the Data Pump process
GGSCI (devu007) 4> ADD EXTRACT dpump, EXTTRAILSOURCE /u01/oracle/software/goldengate/dirdat/lt
EXTRACT added.
Create the parameter file for the Primary Extract group
GGSCI (devu007) 5> EDIT PARAMS ext1
“/u01/oracle/software/goldengate/dirprm/ext1.prm” [New file]
EXTRACT ext1
USERID ggs_owner, PASSWORD ggs_owner
EXTTRAIL /u01/oracle/software/goldengate/dirdat/lt
TABLE MONITOR.WORK_PLAN;
Specify the location of the remote trail on the target system
Use the RMTTRAIL to specify the location of the remote trail and associate the same with the Data Pump group as it will be wriiten to over the network by the data pump process
GGSCI (devu007) 6> ADD RMTTRAIL /u01/oracle/ggs/dirdat/rt, EXTRACT dpump
RMTTRAIL added.
Create the parameter file for the Data Pump group
Note- the parameter PASSTHRU signifies the mode being used for the Data Pump which means that the names of the source and target objects are identical and no column mapping or filtering is being performed here.
GGSCI (devu007) 2> EDIT PARAMS dpump
“/u01/oracle/software/goldengate/dirprm/dpump.prm” [New file]
EXTRACT dpump
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST redhat346, MGRPORT 7809
RMTTRAIL /u01/oracle/ggs/dirdat/rt
PASSTHRU
TABLE MONITOR.WORK_PLAN;
ON TARGET SYSTEM
Create the Replicat group
The EXTTRAIL clause indicates the location of the remote trail and should be the same as the RMTTRAIL value that was used when creating the Data Pump process on the source system.
GGSCI (redhat346.localdomain) 2> ADD REPLICAT rep1, EXTTRAIL /u01/oracle/ggs/dirdat/rt
REPLICAT added.
Create the parameter file for the Replicat group
GGSCI (redhat346.localdomain) 3> EDIT PARAMS rep1
REPLICAT rep1
ASSUMETARGETDEFS
USERID ggs_owner, PASSWORD ggs_owner
MAP MONITOR.WORK_PLAN, TARGET MONITOR.WORK_PLAN;
ON SOURCE
On the source system, now start the Extract and Data Pump processes.
GGSCI (devu007) 3> START EXTRACT ext1
Sending START request to MANAGER …
EXTRACT EXT1 starting
GGSCI (devu007) 4> START EXTRACT dpump
Sending START request to MANAGER …
EXTRACT DPUMP starting
GGSCI (devu007) 5> info extract ext1
EXTRACT EXT1 Last Started 2010-02-18 11:23 Status RUNNING
Checkpoint Lag 00:40:52 (updated 00:00:09 ago)
Log Read Checkpoint Oracle Redo Logs
2010-02-18 10:42:19 Seqno 761, RBA 15086096
GGSCI (devu007) 6> INFO EXTRACT dpump
EXTRACT DPUMP Last Started 2010-02-18 11:23 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:02 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/lt000000
2010-02-18 11:15:10.000000 RBA 5403
Note- the data pump process is reading from the Local Trail file – /u01/oracle/software/goldengate/dirdat/lt000000
ON TARGET SYSTEM
Start the Replicat process
GGSCI (redhat346.localdomain) 4> START REPLICAT rep1
Sending START request to MANAGER …
REPLICAT REP1 starting
GGSCI (redhat346.localdomain) 5> STATUS REPLICAT rep1
REPLICAT REP1: RUNNING
Coming Next! – DDL change synchronization …
--Replicat group --
replicat rep1
--source and target definitions
ASSUMETARGETDEFS
--target database login --
userid ggate, password qwerty
--file for dicarded transaction --
discardfile D:\GGS\v22234-01-170861\DISCARD\rep1_discard.txt, append, megabytes 10
--ddl support
DDL
--Specify table mapping ---
map sender.*, target receiver.*;
In addition to providing replication support for all DML statements, we can also configure the GoldenGate environment to provide DDL support as well.
A number of prerequisite setup tasks need to be performed which we willl highlight here.
Run the following scripts from the directory where the GoldenGate software was installed.
The assumption here is that the database user GGS_OWNER has already been created and granted the required roles and privileges as discussed in our earlier tutorial.
Note - run the scripts as SYSDBA
SQL> @marker_setup
Marker setup script
You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter GoldenGate schema name:GGS_OWNER
Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGS_OWNER
======
Oracle GoldenGate not only provides us a replication solution that is Oracle version independent as well as platform independent, but we can also use it to do data transformation and data manipulation between the source and the target.
So we can use GoldenGate when the source and database database differ in table structure as well as an ETL tool in a Datawarehouse type environment.
We will discuss below two examples to demonstrate this feature – column mapping and filtering of data.
In example 1, we will filter the records that are extracted on the source and applied on the target – only rows where the JOB column value equals ‘MANAGER” in the MYEMP table will be considered for extraction.
In example 2, we will deal with a case where the table structure is different between the source database and the target database and see how column mapping is performed in such cases.
Example 1
Initial load of all rows which match the filter from source to target. The target database MYEMP table will only be populated with rows from the EMP table where filter criteria of JOB=’MANAGER’ is met.
On Source
GGSCI (redhat346.localdomain) 4> add extract myload1, sourceistable
EXTRACT added.
GGSCI (redhat346.localdomain) 5> edit params myload1
EXTRACT myload1
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST devu007, MGRPORT 7809
RMTTASK replicat, GROUP myload1
TABLE scott.myemp, FILTER (@STRFIND (job, “MANAGER”) > 0);
On Target
GGSCI (devu007) 2> add replicat myload1, specialrun
REPLICAT added.
GGSCI (devu007) 3> edit params myload1
“/u01/oracle/software/goldengate/dirprm/myload1.prm” [New file]
REPLICAT myload1
USERID ggs_owner, PASSWORD ggs_owner
ASSUMETARGETDEFS
MAP scott.myemp, TARGET sh.myemp;
On Source – start the initial load extract
GGSCI (redhat346.localdomain) 6> start extract myload1
Sending START request to MANAGER …
EXTRACT MYLOAD1 starting
On SOURCE
SQL> select count(*) from myemp;
COUNT(*)
———-
14
SQL> select count(*) from myemp where job=’MANAGER’;
COUNT(*)
———-
9
On TARGET
SQL> select count(*) from myemp where job=’MANAGER’;
COUNT(*)
———-
9
Create an online change extract and replicat group using a Filter
GGSCI (redhat346.localdomain) 10> add extract myload2, tranlog, begin now
EXTRACT added.
GGSCI (redhat346.localdomain) 11> add rmttrail /u01/oracle/software/goldengate/dirdat/bb, extract myload2
RMTTRAIL added.
GGSCI (redhat346.localdomain) 11> edit params myload2
EXTRACT myload2
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST 10.53.200.225, MGRPORT 7809
RMTTRAIL /u01/oracle/software/goldengate/dirdat/bb
TABLE scott.myemp, FILTER (@STRFIND (job, “MANAGER”) > 0);
On Target
GGSCI (devu007) 2> add replicat myload2, exttrail /u01/oracle/software/goldengate/dirdat/bb
REPLICAT added.
GGSCI (devu007) 3> edit params myload2
“/u01/oracle/software/goldengate/dirprm/myload2.prm” [New file]
REPLICAT myload2
ASSUMETARGETDEFS
USERID ggs_owner, PASSWORD ggs_owner
MAP scott.myemp, TARGET sh.myemp;
On Source – start the online extract group
GGSCI (redhat346.localdomain) 13> start extract myload2
Sending START request to MANAGER …
EXTRACT MYLOAD2 starting
GGSCI (redhat346.localdomain) 14> info extract myload2
EXTRACT MYLOAD2 Last Started 2010-02-23 11:04 Status RUNNING
Checkpoint Lag 00:27:39 (updated 00:00:08 ago)
Log Read Checkpoint Oracle Redo Logs
2010-02-23 10:36:51 Seqno 214, RBA 103988
On Target
GGSCI (devu007) 4> start replicat myload2
Sending START request to MANAGER …
REPLICAT MYLOAD2 starting
GGSCI (devu007) 5> info replicat myload2
REPLICAT MYLOAD2 Last Started 2010-02-23 11:05 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:08 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/bb000000
First Record RBA 989
On Source we now insert two rows into the MYEMP table – one which has the JOB value of ‘MANAGER’ and the other row which has the job value of ‘SALESMAN’
On SOURCE
SQL> INSERT INTO MYEMP
2 (empno,ename,job,sal)
3 VALUES
4 (1234,’GAVIN’,’MANAGER‘,10000);
1 row created.
SQL> commit;
Commit complete.
SQL> INSERT INTO MYEMP
2 (empno,ename,job,sal)
3 VALUES
4 (1235,’BOB’,’SALESMAN‘,1000);
1 row created.
SQL> commit;
Commit complete.
SQL> select count(*) from myemp;
COUNT(*)
———-
16
SQL> select count(*) from myemp where job=’MANAGER’;
COUNT(*)
———-
10
On Target, we will see that even though two rows have been inserted into the source MYEMP table, on the target MYEMP table only one row is inserted because the filter has been applied which only includes the rows where the JOB value equals ‘MANAGER’.
SQL> select count(*) from myemp;
COUNT(*)
———-
10
Example 2 – source and target table differ in column structure
In the source MYEMP table we have a column named SAL whereas on the target, the same MYEMP table has the column defined as SALARY.
Create a definitions file on the source using DEFGEN utility and then copy that definitions file to the target system
GGSCI (redhat346.localdomain) > EDIT PARAMS defgen
DEFSFILE /u01/oracle/ggs/dirsql/myemp.sql
USERID ggs_owner, PASSWORD ggs_owner
TABLE scott.myemp;
[oracle@redhat346 ggs]$ ./defgen paramfile /u01/oracle/ggs/dirprm/defgen.prm
***********************************************************************
Oracle GoldenGate Table Definition Generator for Oracle
Version 10.4.0.19 Build 002
Linux, x64, 64bit (optimized), Oracle 11 on Sep 18 2009 00:09:13
Copyright (C) 1995, 2009, Oracle and/or its affiliates. All rights reserved.
Starting at 2010-02-23 11:22:17
***********************************************************************
Operating System Version:
Linux
Version #1 SMP Wed Dec 17 11:41:38 EST 2008, Release 2.6.18-128.el5
Node: redhat346.localdomain
Machine: x86_64
soft limit hard limit
Address Space Size : unlimited unlimited
Heap Size : unlimited unlimited
File Size : unlimited unlimited
CPU Time : unlimited unlimited
Process id: 14175
***********************************************************************
** Running with the following parameters **
***********************************************************************
DEFSFILE /u01/oracle/ggs/dirsql/myemp.sql
USERID ggs_owner, PASSWORD *********
TABLE scott.myemp;
Retrieving definition for SCOTT.MYEMP
Definitions generated for 1 tables in /u01/oracle/ggs/dirsql/myemp.sql
If we were to try and run the replicat process on the target without copying the definitions file, we will see an error as shown below which pertains to the fact that the columns in the source and target database are different and GoldenGate is not able to resolve that.
2010-02-23 11:31:07 GGS WARNING 218 Aborted grouped transaction on ‘SH.MYEMP’, Database error 904 (ORA-00904: “SAL”: invalid identifier).
2010-02-23 11:31:07 GGS WARNING 218 SQL error 904 mapping SCOTT.MYEMP to SH.MYEMP OCI Error ORA-00904: “SAL”: invalid identifier (status = 904), SQL .
We then ftp the definitions file from the source to the target system – in this case to the dirsql directory located in the top level GoldenGate installed software directory
We now go and make a change to the original replicat parameter file and change the parameter ASSUMEDEFS to SOURCEDEFS which provides GoldenGate with the location of the definitions file.
The other parameter which is included is the COLMAP parameter which tells us how the column mapping has been performed. The ‘USEDEFAULTS’ keyword denotes that all the other columns in both tables are identical except for the columns SAL and SALARY which differ in both tables and now we are mapping the SAL columsn in source to the SALARY column on the target.
REPLICAT myload2
SOURCEDEFS /u01/oracle/software/goldengate/dirsql/myemp.sql
USERID ggs_owner, PASSWORD ggs_owner
MAP scott.myemp, TARGET sh.myemp,
COLMAP (usedefaults,
salary = sal);
We now go and start the originall replicat process myload2 which had abended because of the column mismatch (which has now been corrected via the parameter change) and we see that the process now is running without any error.
now go and start the process which had failed after table modification
GGSCI (devu007) 2> info replicat myload2
REPLICAT MYLOAD2 Last Started 2010-02-23 11:05 Status ABENDED
Checkpoint Lag 00:00:03 (updated 00:11:44 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/bb000000
2010-02-23 11:31:03.999504 RBA 1225
GGSCI (devu007) 3> start replicat myload2
Sending START request to MANAGER …
REPLICAT MYLOAD2 starting
GGSCI (devu007) 4> info replicat myload2
REPLICAT MYLOAD2 Last Started 2010-02-23 11:43 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:03 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/bb000000
2010-02-23 11:31:03.999504 RBA 1461
Coming Next! – Monitoring the GoldenGate environment …..
MARKER TABLE
-------------------------------
OK
MARKER SEQUENCE
-------------------------------
OK
Script complete.
SQL> alter session set recyclebin=OFF;
Session altered.
SQL> @ddl_setup
GoldenGate DDL Replication setup script
Verifying that current user has privileges to install DDL Replication...
You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: On Oracle 10g and up, system recycle bin must be disabled.
NOTE: Stop all DDL replication before starting this installation.
Enter GoldenGate schema name:GGS_OWNER
You will be prompted for the mode of installation.
To install or reinstall DDL replication, enter INITIALSETUP
To upgrade DDL replication, enter NORMAL
Enter mode of installation:INITIALSETUP
Working, please wait ...
Spooling to file ddl_setup_spool.txt
Using GGS_OWNER as a GoldenGate schema name, INITIALSETUP as a mode of installation.
Working, please wait ...
RECYCLEBIN must be empty.
This installation will purge RECYCLEBIN for all users.
To proceed, enter yes. To stop installation, enter no.
Enter yes or no:yes
DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGS_OWNER
DDLORA_GETTABLESPACESIZE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
CLEAR_TRACE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
CREATE_TRACE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
TRACE_PUT_LINE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
INITIAL_SETUP STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDLVERSIONSPECIFIC PACKAGE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDLREPLICATION PACKAGE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDLREPLICATION PACKAGE BODY STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDL HISTORY TABLE
-----------------------------------
OK
DDL HISTORY TABLE(1)
-----------------------------------
OK
DDL DUMP TABLES
-----------------------------------
OK
DDL DUMP COLUMNS
-----------------------------------
OK
DDL DUMP LOG GROUPS
-----------------------------------
OK
DDL DUMP PARTITIONS
-----------------------------------
OK
DDL DUMP PRIMARY KEYS
-----------------------------------
OK
DDL SEQUENCE
-----------------------------------
OK
GGS_TEMP_COLS
-----------------------------------
OK
GGS_TEMP_UK
-----------------------------------
OK
DDL TRIGGER CODE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDL TRIGGER INSTALL STATUS
-----------------------------------
OK
DDL TRIGGER RUNNING STATUS
-----------------------------------
ENABLED
STAYMETADATA IN TRIGGER
-----------------------------------
OFF
DDL TRIGGER SQL TRACING
-----------------------------------
0
DDL TRIGGER TRACE LEVEL
-----------------------------------
0
LOCATION OF DDL TRACE FILE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/gavin/gavin/trace/ggs_ddl_trace.log
Analyzing installation status...
STATUS OF DDL REPLICATION
--------------------------------------------------------------------------------
SUCCESSFUL installation of DDL Replication software components
Script complete.
SQL>
SQL> @role_setup
GGS Role setup script
This script will drop and recreate the role GGS_GGSUSER_ROLE
To use a different role name, quit this script and then edit the params.sql script to change
the gg_role parameter to the preferred name. (Do not run the script.)
You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter GoldenGate schema name:GGS_OWNER
Wrote file role_setup_set.txt
PL/SQL procedure successfully completed.
Role setup script complete
Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:
GRANT GGS_GGSUSER_ROLE TO
where is the user assigned to the GoldenGate processes.
SQL> grant ggs_ggsuser_role to ggs_owner;
Grant succeeded.
SQL> @ddl_enable
Trigger altered.
SQL> @ddl_pin GGS_OWNER
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Turn Recyclebin OFF
We need to set the parameter recyclebin to OFF via the ALTER SYSTEM SET RECYCLEBIN=OFF command in order to prevent this error which we will see if we try and configure DDL support and then start the Extract process.
2010-02-19 11:13:30 GGS ERROR 2003 RECYCLEBIN must be turned off. For 10gr2 and up, set RECYCLEBIN in parameter file to OFF. For 10gr1, set _RECYCLEBI
N in parameter file to FALSE. Then restart database and extract.
2010-02-19 11:13:30 GGS ERROR 190 PROCESS ABENDING.
Enable additional logging at the table level
Note- We had earlier enabled additional supplemental logging at the database level. Using the ADD TRANDATA command we now enable it at even the table level as this is required by GoldenGate for DDL support.
GGSCI (redhat346.localdomain) 5> DBLOGIN USERID ggs_owner, PASSWORD ggs_owner
Successfully logged into database.
GGSCI (redhat346.localdomain) 6> ADD TRANDATA scott.emp
Logging of supplemental redo data enabled for table SCOTT.EMP.
Edit the parameter file for the Extract process to enable DDL synchronization
We had earlier created a parameter file for an Extract process ext1. We now edit that parameter file and add the entry
DDL INCLUDE MAPPED
This means that DDL support is now enabled for all tables which have been mapped and in this case it will only apply to the SCOTT.EMP table as that is the only table which is being processed here. We can also use the INCLUDE ALL or EXCLUDE ALL or wildcard characters to specify which tables to enable the DDL support for.
GGSCI (redhat346.localdomain) 1> EDIT PARAM EXT1
EXTRACT ext1
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST 10.53.100.100, MGRPORT 7809
RMTTRAIL /u01/oracle/software/goldengate/dirdat/rt
DDL INCLUDE MAPPED
TABLE scott.emp;
Test the same
We will now alter the structure of the EMP table by adding a column and we can see that this new table structure is also reflected on the target system.
On Source
SQL> ALTER TABLE EMP ADD NEW_COL VARCHAR2(10);
Table altered.
On Target
SQL> desc emp
Name Null? Type
—————————————– ——– —————————-
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(20)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
MYCOL VARCHAR2(10)
NEW_COL VARCHAR2(10)
These errors are characteristic to memory exhaustion problems. Either enough memory is not available on the server, or, the memory is not configured to sustain the Oracle software needs.
Please apply the suggested solutions from 'ORA-07445 [ACCESS_VIOLATION] [unable_to_trans_pc] on Windows Platforms (Doc ID 456801.1)'. I will place the SR in monitoring status, waiting for your feedback for 1 week. The ora-7445 mentioned in the note is not mandatory, but the memory issues and the suggestions are valid, so please implement the recommendations.
I will follow up with you next Monday, June 20th.
Best regards,
Adina
Global Customer Services
Solution
Please refer to Note 342443.1 and apply latest minipack.
Have sufficient physical memory on Server so that you can allocate more SGA/PGA to the database.
1) Increase SGA_MAX_SIZE and SGA_TARGET so that you can accommodate following pools.
2) Restart the instance.
3) Increase INIT.ORA memory parameters and make sure following pools are set to recommended value i.e. 200M.
a) SHARED_POOL_SIZE
b) JAVA_POOL_SIZE
c) STREAMS_POOL_SIZE
Directing LogMiner Operations and Retrieving Data of Interest
You direct LogMiner operations using the DBMS_LOGMNR and DBMS_LOGMNR_D PL/SQL packages, and retrieve data of interest using the V$LOGMNR_CONTENTS view, as follows:
Specify a LogMiner dictionary.
Use the DBMS_LOGMNR_D.BUILD procedure or specify the dictionary when you start LogMiner (in Step 3), or both, depending on the type of dictionary you plan to use.
Specify a list of redo log files for analysis.
Use the DBMS_LOGMNR.ADD_LOGFILE procedure, or direct LogMiner to create a list of log files for analysis automatically when you start LogMiner (in Step 3).
Start LogMiner.
Use the DBMS_LOGMNR.START_LOGMNR procedure.
Request the redo data of interest.
Query the V$LOGMNR_CONTENTS view. (You must have the SELECT ANY TRANSACTION privilege to query this view.)
End the LogMiner session.
Use the DBMS_LOGMNR.END_LOGMNR procedure.
You must have been granted the EXECUTE_CATALOG_ROLE role to use the LogMiner PL/SQL packages and to query the V$LOGMNR_CONTENTS view.
Note:
When mining a specified time or SCN range of interest within archived logs generated by an Oracle RAC database, you must ensure that you have specified all archived logs from all redo threads that were active during that time or SCN range. If you fail to do this, any queries of V$LOGMNR_CONTENTS will return only partial results (based on the archived logs specified to LogMiner through the DBMS_LOGMNR.ADD_LOGFILE procedure). This restriction is also in effect when you are mining the archived logs at the source database using the CONTINUOUS_MINE option. You should only use CONTINUOUS_MINE on an Oracle RAC database if no thread is being enabled or disabled.
DBMS_LOGMNR.ADD_LOGFILE
DBMS_LOGMNR_D.BUILD
DBMS_LOGMNR.ADD_LOGFILE
DBMS_LOGMNR.START_LOGMNR
V$LOGMNR_CONTENTS
DBMS_LOGMNR.END_LOGMNR
Check in that table st_inward_temp
======== Restore from RMAN (Any DB can be used for the same)========
399302992110
399303211009
run
{
set archivelog destination to '/opt/oracle/admin/RMAN_18082014';
restore archivelog from scn 399302992110 until scn 399303211009;
}
run
{
set archivelog destination to '/archive/arch/MD1';
restore archivelog from scn 4872613932 until scn 4873978397;
}
run
{
set archivelog destination to '/opt/oracle/admin/RMAN_18082014/';
restore archivelog from sequence until sequence 140580;
}
run
{
allocate channel 'T1' type 'SBT_TAPE' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt.P44)';
set archivelog destination to '/u025/';
restore archivelog from sequence 140481 until sequence 140580;
release channel 'T1';
}
2 7194 12-JAN-2014 01:30:06
1 7855 12-JAN-2014 01:30:06
1 7856 12-JAN-2014 03:41:56
7213
7873
run
{
allocate channel 'T1' type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=ustlscbu104,NSR_CLIENT=ustsmcdcvtc011,NSR_DATA_VOLUME_POOL=Oracletape)';
allocate channel 'T2' type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=ustlscbu104,NSR_CLIENT=ustsmcdcvtc011,NSR_DATA_VOLUME_POOL=Oracletape)';
set archivelog destination to '/u115/dbarchive/SGRP/';
restore archivelog from sequence 7855 until sequence 7873 thread 1;
restore archivelog from sequence 7194 until sequence 7213 thread 2;
release channel 'T1';
release channel 'T1';
}
@
2025 - 2042
cd /u025/
gz *.arc
scp *.arc.gz bznvjs@ustlsoi011:/u025/arch/TST44
scp P44_control_hot_20140511.ctl qz4x1r@ustlsoi011:/home/oracle/rr
======== LOG MINING ==================
EXECUTE DBMS_LOGMNR.ADD_LOGFILE('/adhocfcdump/rman_bak/rr/1_75430_740933967.dbf');
EXECUTE DBMS_LOGMNR.ADD_LOGFILE('/adhocfcdump/rman_bak/rr/2_69405_740933967.dbf');
execute DBMS_LOGMNR.START_LOGMNR();
create table LOGMNR_rr as select * from V$LOGMNR_CONTENTS where 1 = 2;
select * from V$LOGMNR_CONTENTS where upper(seg_name) = upper('st_inward_temp');
insert into LOGMNR_rr (select * from V$LOGMNR_CONTENTS where upper(seg_name) = upper('st_inward_temp'));
execute DBMS_LOGMNR.END_LOGMNR();
=======================================
select sid,serial#,SOFAR,TOTALWORK,START_TIME,LAST_UPDATE_TIME,time_remaining from gv$session_longops where sofar <> totalwork;
Hi
Kindly check the query below / depends on AWR retention
command type (7) - delete
SELECT st.executions_total||'--'||SP.SQL_ID||'--'||COST ||'--'||ds.BEGIN_INTERVAL_TIME||'--'||ds.END_INTERVAL_TIME
FROM DBA_HIST_SQL_PLAN SP,DBA_HIST_SQLSTAT ST
,DBA_HIST_SNAPSHOT ds WHERE
SP.SQL_ID=ST.SQL_ID AND ds.SNAP_ID=ST.SNAP_ID AND
st.executions_total> 1 and cost >1 and
to_date(to_char(ds.BEGIN_INTERVAL_TIME,'dd-mm-yyyy hh24:mi'),'dd-mm-yyyy hh24:mi') >= to_date('15-11-2011 13:00','dd-mm-yyyy hh24:mi')
and to_date(to_char(ds.BEGIN_INTERVAL_TIME,'dd-mm-yyyy hh24:mi'),'dd-mm-yyyy hh24:mi')
<= to_date('15-11-2011 15:00','dd-mm-yyyy hh24:mi')
AND SP.SQL_ID IN
(SELECT SQL_ID FROM DBA_HIST_SQLTEXT WHERE SQL_ID IN (
SELECT distinct SP.SQL_ID FROM DBA_HIST_SQL_PLAN SP,DBA_HIST_SQLSTAT ST
,DBA_HIST_SNAPSHOT ds WHERE
SP.SQL_ID=ST.SQL_ID AND ds.SNAP_ID=ST.SNAP_ID
) and COMMAND_TYPE IN (7))
ORDER BY st.executions_total,COST,ds.BEGIN_INTERVAL_TIME;
Regards
Prasad Joshi
select sid,SQL_HASH_VALUE,opname,sofar,totalwork,round(time_remaining/60,2) time_remain_mins from gv$session_longops where time_remaining >0 order by time_remaining desc;
/
select sid,SQL_HASH_VALUE,opname,sofar,totalwork,round(time_remaining/60,2) time_remain_mins from gv$session_longops where time_remaining >0 order by time_remaining desc
=== Check Session remaining Time.
col target for a30
col opname for a30
col program for a30
col event for a40
select s.sid,l.opname,l.target,l.sofar,l.totalwork,round(l.time_remaining/60,2) time_remain_mins,l.SQL_HASH_VALUE,s.serial#,s.program,s.event
from gv$session_longops l,gv$session s
where s.sid=l.sid
and time_remaining >0
and program like '%sqlplus%'
order by time_remaining desc
;
col target for a30
col opname for a30
col program for a30
col event for a40
select s.sid,l.opname,l.target,l.sofar,l.totalwork,round(l.time_remaining/60,2) time_remain_mins,l.SQL_HASH_VALUE,s.serial#,s.program
from gv$session_longops l,gv$session s
where s.sid=l.sid
and time_remaining >0
and program like '%sqlplus%'
order by time_remaining desc
;
col target for a30
col opname for a30
col program for a30
col event for a40
select s.sid,l.opname,l.target,l.sofar,l.totalwork,round(l.time_remaining/60,2) time_remain_mins,l.SQL_HASH_VALUE,s.serial#,s.program,s.event
from v$session_longops l, v$session s
where s.sid=l.sid
--and time_remaining >0
and program like '%sqlplus%'
order by time_remaining desc
;
grant select on CASE_INFORMATION to wondersii;
AUDIT_TRAIL
PROPOSALS
STAFFO
M_PRDCTS
M_MST_GRP_DTL
M_BRANCH
SLA_BRANCH_MASTER
--- STATSPACK
sqlplus "/ as sysdba"
@?/rdbms/admin/spcreate.sql
conn perfstat/perfstat
exec statspack.snap; --- Start SnapShot
@?/rdbms/admin/spreport.sql
-------------------------------------------------------------------------
Installation of the Oracle Statspack tool is a relatively simple process. The following is a step-by-step guide to the process of installing Oracle Statspack on a UNIX system.
1. Navigate to the $ORACLE_HOME/rdbms/admin directory as follows:
# cd $ORACLE_HOME/rdbms/admin/
2. Start the Statspack install script, spcreate.sql, as follows:
# sqlplus "/ as sysdba" @spcreate.sql
3. Enter a password for the PERFSTAT user when prompted.
4. Enter the default tablespace (tools) for the PERFSTAT user when prompted.
5. Enter the temporary tablespace (temp) for the PERFSTAT user when prompted.
6. Exit sqlplus as follows:
SQL> exit
To collect statistics
1. Connect to the database as the PERFSTAT user as follows:
sqlplus perfstat/<password>
2. Create a snapshot with the statspack package as follows:
SQL> execute statspack.snap(i_snap_level=>7);
3. Exit SQLPLUS as follows:
SQL> exit
To run a Statspack report.
1. Navigate to the $ORACLE_HOME/rdbms/admin directory as follows:
# cd $ORACLE_HOME/rdbms/admin/
2. Run the standard Statspack report as follows:
# sqlplus perfstat/<password> @spreport
* Enter a beginning snapshot ID.
* Enter an ending snapshot ID.
* Enter a name for the report or accept the default.
* Exit SQLPLUS as follows:
SQL> exit
Removing Statspack
To deinstall Statspack, connect as a user with SYSDBA privilege and run the following SPDROP script from SQL*Plus. For example:
SQL> CONNECT / AS SYSDBA
SQL> @?/rdbms/admin/spdrop
The SPDROP.SQL script calls the following scripts:
SPDTAB.SQL - drops tables and public synonyms
SPDUSR.SQL - drops the user
Check each of two output files produced (SPDTAB.LIS, SPDUSR.LIS) to ensure that the package was completely deinstalled.
Managing and Sharing Statspack Performance Data
This section discusses the following topics:
Sharing Data Through Export
Removing Unnecessary Data
Truncating All Statspack Data
Sharing Data Through Export
If you want to share data with other sites (for example, if Oracle Support requires the raw statistics), then you can export the PERFSTAT user. An export parameter file (SPUEXP.PAR) is supplied for this purpose. To use this file, supply the export command with the userid parameter, along with the export parameter file name. For example:
exp userid=perfstat/my_perfstat_password parfile=spuexp.par
This creates a file called SPUEXP.DMP and the log file SPUEXP.LOG. If you want to load the data into another database, use the import command.
See Also:
Oracle9i Database Utilities for more information on using export and import
Removing Unnecessary Data
Purge unnecessary data from the PERFSTAT schema using the SPPURGE.SQL script. This deletes snapshots that fall between the begin and end snapshot IDs you specify.
Note:
You should export the schema as a backup before running this script, either using your own export parameters or those provided in SPUEXP.PAR.
Purging can require the use of a large rollback segment, because all data relating to each snapshot ID to be purged is deleted. You can avoid rollback segment extension errors in one of two ways:
Specify a smaller range of snapshot IDs to purge.
Explicitly use a large rollback segment, by executing the SET TRANSACTION USE ROLLBACK SEGMENT statement before running the SPPURGE.SQL script.
See Also:
Oracle9i SQL Reference
When you run SPPURGE.SQL, it displays the instance to which you are connected and the available snapshots. It then prompts you for the low snap ID and high snap ID. All snapshots that fall within this range are purged.
Example 21-6 Sample Run of SPPURGE.SQL
SQL> CONNECT perfstat/my_perfstat_password
SQL> SET TRANSACTION USE ROLLBACK SEGMENT rbig;
SQL> @?/rdbms/admin/sppurge
Database Instance currently connected to
========================================
Instance
DB Id DB Name Inst Num Name
----------- ---------- -------- ----------
720559826 PERF 1 perf
Snapshots for this database instance
====================================
Snap
Snap Id Level Snapshot Started Host Comment
---------- ----- --------------------- --------------- -------------------
1 5 30 Feb 2000 10:00:01 perfhost
2 5 30 Feb 2000 12:00:06 perfhost
3 5 01 Mar 2000 02:00:01 perfhost
4 5 01 Mar 2000 06:00:01 perfhost
Caution:
SPPURGE.SQL deletes all snapshots ranging between the lower and upper bound snapshot IDs specified for the database instance connected to. You might want to export this data before continuing.
Specify the Low Snap ID and High Snap ID range to purge
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for losnapid: 1
Using 1 for lower bound.
Enter value for hisnapid: 2
Using 2 for upper bound.
Deleting snapshots 1 - 2
Purge of specified snapshot range complete. If you want to rollback the purge,
it is still possible to do so. Exiting from SQL*Plus automatically commits the
purge.
SQL> -- end of example output
To purge in batch mode, you must assign values to the SQL*Plus variables that specify the low and high snapshot IDs to purge. The variables are:
LOSNAPID: Begin snapshot ID
HISNAPID: End snapshot ID
Example 21-7 Running SPPURGE.SQL in Batch Mode
SQL> CONNECT perfstat/my_perfstat_password
SQL> DEFINE losnapid=1
SQL> DEFINE hisnapid=2
SQL> @?/rdbms/admin/sppurge
When SPPURGE.SQL is run, it does not prompt for the information provided by the variables.
Truncating All Statspack Data
To truncate all performance data indiscriminately, use SPTRUNC.SQL. This script truncates all statistics data gathered.
Note:
Oracle Corporation recommends that you export the schema as a backup before running this script, either using your own export parameters or those provided in SPUEXP.PAR.
Example 21-8 Sample Run of SPTRUNC.SQL
SQL> CONNECT perfstat/my_perfstat_password
SQL> @?/rdbms/admin/sptrunc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note:
Running SPTRUNC.SQL removes all data from Statspack tables. You might want to export the data before continuing.
If you would like to continue, enter any string, followed by <return>.
Enter value for anystring:
entered - starting truncate operation
Table truncated.
<etc>
Truncate operation complete.
----------------------
spool c:\Object_Check_IDB_OUTPUT.txt
select count(*) from dba_objects;
select object_type,count(*) from dba_objects group by object_type;
select owner,count(*) from dba_objects where status = 'INVALID' group by owner order by 1;
select owner,count(*) from dba_objects group by owner;
select count(*) from dba_synonyms;
select count(*) from dba_queues;
spool off;
k-- AUDIT
set head off
spool d:\audit_TEST.log;
select distinct a from (
select 'audit ' || a.privilege || ' by ' || username || ' by access;' a
from dba_users u, (select user_name,privilege from dba_priv_audit_opts) a)
order by 1
/
select distinct a from (
select 'noaudit ' || a.privilege || ' by ' || username || ';' a
from dba_users u, (select user_name,privilege from dba_priv_audit_opts where USER_NAME = 'TEST' and privilege like 'CREATE%') a
where u.created like '18-SEP-10')
order by 1
/
select distinct a from (
select 'noaudit ' || a.privilege || ' by ' || username || ';' a
from dba_users u, (select user_name,privilege from dba_priv_audit_opts where USER_NAME = 'TEST' and privilege like 'CREATE%') a
where u.created like '18-SEP-10')
order by 1
/
select user_name,privilege from dba_priv_audit_opts where USER_NAME = 'SYS';
select user_name,audit_option from dba_stmt_audit_opts where USER_NAME = 'SYS';
select ACTION_NAME,username,OWNER,OBJ_NAME,OBJ_PRIVILEGE,EXTENDED_TIMESTAMP from dba_audit_trail where username = 'AMS' order by 6;
select ACTION_NAME,username,OWNER,OBJ_NAME,OBJ_PRIVILEGE,EXTENDED_TIMESTAMP from dba_audit_trail where username = 'TESTRR2' order by 6;
select user_name,audit_option from dba_stmt_audit_opts where USER_NAME = 'TESTRR';
select user_name,privilege from dba_priv_audit_opts where USER_NAME = 'TESTRR';
select ACTION_NAME,username,OWNER,OBJ_NAME,OBJ_PRIVILEGE,EXTENDED_TIMESTAMP from dba_audit_trail where order by 6;
Auditing is disabled by default, but can enabled by setting the AUDIT_TRAIL static parameter, which has the following allowed values.
AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }The following list provides a description of each setting:
•none or false - Auditing is disabled.
•db or true - Auditing is enabled, with all audit records stored in the database audit trial (SYS.AUD$).
•db,extended - As db, but the SQL_BIND and SQL_TEXT columns are also populated.
•xml- Auditing is enabled, with all audit records stored as XML format OS files.
•xml,extended - As xml, but the SQL_BIND and SQL_TEXT columns are also populated.
•os- Auditing is enabled, with all audit records directed to the operating system's audit trail.
Note. In Oracle 10g Release 1, db_extended was used in place of db,extended. The XML options are new to Oracle 10g Release 2.
The AUDIT_SYS_OPERATIONS static parameter enables or disables the auditing of operations issued by users connecting with SYSDBA or SYSOPER privileges, including the SYS user. All audit records are written to the OS audit trail.
The AUDIT_FILE_DEST parameter specifies the OS directory used for the audit trail when the os, xml and xml,extended options are used. It is also the location for all mandatory auditing specified by the AUDIT_SYS_OPERATIONS parameter.
Statement level
Auditing will be done at statement level.
Statements that can be audited are found in STMT_AUDIT_OPTION_MAP.
SQL> audit table by scott;
Audit records can be found in DBA_STMT_AUDIT_OPTS.
SQL> select * from DBA_STMT_AUDIT_OPTS;
Object level
Auditing will be done at object level.
These objects can be audited: tables, views, sequences, packages, stored procedures and stored functions.
SQL> audit insert, update, delete on scott.emp by hr;
Audit records can be found in DBA_OBJ_AUDIT_OPTS.
SQL> select * from DBA_OBJ_AUDIT_OPTS;
Privilege level
Auditing will be done at privilege level.
All system privileges that are found in SYSTEM_PRIVILEGE_MAP can be audited.
SQL> audit create tablespace, alter tablespace by all;
Specify ALL PRIVILEGES to audit all system privileges.
Audit records can be found in DBA_PRIV_AUDIT_OPTS.
SQL> select * from DBA_PRIV_AUDIT_OPTS;
SELECT_PRIV
INSERT_PRIV
DELETE_PRIV
UPDATE_PRIV
REFERENCES_PRIV
ALTER_PRIV
INDEX_PRIV
audit grant on test.test1 by access;
noaudit grant on test.test1;
select ACTION_NAME,username,OWNER,grantee,OBJ_NAME,OBJ_PRIVILEGE from dba_audit_trail username = 'RONAK';
Obj_Privilege has below 16 Audit Trail Grants Systems, There is 16 (-) Hifns which means Grants.
HiPNS:
1 - ALTER
2 -
3 -
4 - DELETE
5 -
6 -
7 - INSERT
8 -
9 -
10 - SELECT
11 - UPDATE
12 -
13 -
14 -
15 -
16 -
grant insert,update,delete on test1 to rr;
---Y--Y---Y-----
audit alter any trigger by test by access;
AUDIT GRANT PROCEDURE BY USER;
AUDIT GRANT DIRECTORY
AUDIT GRANT SEQUENCE
AUDIT GRANT TABLE
AUDIT GRANT TYPE
AUDIT ROLE
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to ' || grantee from DBA_TAB_PRIVS where grantee like 'WONUAT';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to CP;' from DBA_TAB_PRIVS where owner like 'BLTS';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to || grantee ||';' from DBA_TAB_PRIVS where table_name in (select table_name from dba_external_tables);
ams_rate_master 10 - 144
SQL> select SQL_TEXT from v$sqltext where HASH_VALUE='3783944380' order by PIECE;
SQL_TEXT
----------------------------------------------------------------
SELECT DECODE(MDCG.DCMNT_CTGRY_CD,NULL,0, MDCG.DCMNT_CTGRY_CD) ,
DT.DCMNT_TYP_CD , DT.DSPLY_TXT, DECODE(NBD.DCMNT_TYP_CD,NULL,''
,'CHECKED') CHKSEQ, MWD.REQUIRED_YN FROM DCMNT_TYPS DT, NB_DCMNT
S NBD, M_WD_DCMNTS MWD, M_DCMNT_CTGRY_GRP_MAP MDCG WHERE NBD.NB_
REF_NO(+) = :B3 AND NBD.DCMNT_TYP_CD(+) = DT.DCMNT_TYP_CD AND MW
D.WD_DCMNT_GRP_CD = :B2 AND MWD.DCMNT_TYP_CD = DT.DCMNT_TYP_CD A
ND MWD.DCMNT_TYP_CD = MDCG.DCMNT_TYP_CD(+) AND MWD.DELETE_YN = :
B1 AND DT.DELETE_YN = :B1 ORDER BY MWD.DSPLY_SEQ, DT.DSPLY_TXT
vijay goka
ameya kul
vinayak sawant
supratim chaudh
=== Archive Check in Hours
select to_char(first_time,'YYYY-MON-DD') day,
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'99') "00",
to_char(sum(decode(to_char(first_time,'HH24'),'01',1,0)),'99') "01",
to_char(sum(decode(to_char(first_time,'HH24'),'02',1,0)),'99') "02",
to_char(sum(decode(to_char(first_time,'HH24'),'03',1,0)),'99') "03",
to_char(sum(decode(to_char(first_time,'HH24'),'04',1,0)),'99') "04",
to_char(sum(decode(to_char(first_time,'HH24'),'05',1,0)),'99') "05",
to_char(sum(decode(to_char(first_time,'HH24'),'06',1,0)),'99') "06",
to_char(sum(decode(to_char(first_time,'HH24'),'07',1,0)),'99') "07",
to_char(sum(decode(to_char(first_time,'HH24'),'08',1,0)),'99') "08",
to_char(sum(decode(to_char(first_time,'HH24'),'09',1,0)),'99') "09",
to_char(sum(decode(to_char(first_time,'HH24'),'10',1,0)),'99') "10",
to_char(sum(decode(to_char(first_time,'HH24'),'11',1,0)),'99') "11",
to_char(sum(decode(to_char(first_time,'HH24'),'12',1,0)),'99') "12",
to_char(sum(decode(to_char(first_time,'HH24'),'13',1,0)),'99') "13",
to_char(sum(decode(to_char(first_time,'HH24'),'14',1,0)),'99') "14",
to_char(sum(decode(to_char(first_time,'HH24'),'15',1,0)),'99') "15",
to_char(sum(decode(to_char(first_time,'HH24'),'16',1,0)),'99') "16",
to_char(sum(decode(to_char(first_time,'HH24'),'17',1,0)),'99') "17",
to_char(sum(decode(to_char(first_time,'HH24'),'18',1,0)),'99') "18",
to_char(sum(decode(to_char(first_time,'HH24'),'19',1,0)),'99') "19",
to_char(sum(decode(to_char(first_time,'HH24'),'20',1,0)),'99') "20",
to_char(sum(decode(to_char(first_time,'HH24'),'21',1,0)),'99') "21",
to_char(sum(decode(to_char(first_time,'HH24'),'22',1,0)),'99') "22",
to_char(sum(decode(to_char(first_time,'HH24'),'23',1,0)),'99') "23"
from v$log_history
where to_char(first_time,'YYYY') = 2010 and to_char(first_time,'MM') = 10
group by to_char(first_time,'YYYY-MON-DD') order by 1;
=== Recover Until Time
SQL> select 'recover standby database until time ''' || to_char(sysdate,'yyyy-mm-dd') || ':00:05:00'';' from dual;
SQL> recover standby database until time '2010-05-22:11:59:00';
SQL> select name,to_char(CHECKPOINT_TIME,'dd-mm-yyyy hh24:mi:ss') from v$datafile;
SQL> select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history where sequence# in (select max(sequence#) from v$log_history group by thread#);
recover database using backup controlfile until time '2011-10-16:12:00:00';
8 rows selected.
SQL> select username,schemaname,program,sid,serial# from v$session where sid=2896;
USERNAME SCHEMANAME PROGRAM SID SERIAL#
---------- ------------ ---------------------------------------------------------------- ---------- ----------
WONDERSII WONDERSII w3wp.exe 2896 60
SQL> select username,schemaname,program,sid,serial#,machine from v$session where sid=2896;
USERNAME SCHEMANAME PROGRAM SID SERIAL# MACHINE
---------- ------------ ---------------------------------------------------------------- ---------- ---------- ---------------
WONDERSII WONDERSII w3wp.exe 2896 60 HDFCSLDM\VMWOND
ERSWEB5
OBJ$
WRI$_ADV_OBJECTS
WRI$_ADV_OBJSPACE_TREND_DATA
WRI$_SEGADV_OBJLIST -- VIP Table
SYS.WRH$_SQLTEXT
SYS.WRH$_SQL_PLAN
SYS.WRI$_ADV_ACTIONS
SYS.WRI$_ADV_OBJECTS
SYS.WRI$_ADV_RATIONALE
SYS.WRI$_DBU_FEATURE_METADATA
SYS.WRI$_DBU_FEATURE_USAGE
SYS.WRI$_DBU_HWM_METADATA
SELECT snap_id, startup_time FROM dba_hist_snapshot ORDER BY 1,2;
oracle -
EXP--- This table is getting Used by Export to Take export. In Oracle 11g this table is having 1 more Column POLYTYP, that is the reason Export not working from Oracle 11G to Oracle 10G.
SQL> desc EXU9RLS
Name Null? Type
----------------------------------------- -------- ----------------------------
OBJOWN NOT NULL VARCHAR2(30)
OBJNAM NOT NULL VARCHAR2(30)
POLGRP NOT NULL VARCHAR2(30)
POLICY NOT NULL VARCHAR2(30)
POLOWN NOT NULL VARCHAR2(30)
POLSCH VARCHAR2(30)
POLFUN NOT NULL VARCHAR2(30)
STMT VARCHAR2(28)
CHKOPT NOT NULL NUMBER
ENABLED NOT NULL NUMBER
SPOLICY NUMBER
select inst_id,sid,serial#,program,event,action,machine,terminal,p1,p2,p3,schemaname from gv$session where sid=633;
select OPEN_RESETLOGS,DATABASE_ROLE,PLATFORM_NAME,SWITCHOVER_STATUS from v$database;
office 123,
kesar resi.,
above bhagwati hotel,
charkop,
VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'begin rr_update_resource_master; commit; end;',
SYSDATE, 'SYSDATE + 120/1440');
commit;
END;
/
print jobno
select log_user,what,job,broken,FAILURES,TOTAL_TIME,to_char(next_date,'dd-mm-yyyy hh24:mi:ss'),to_char(this_date,'dd-mm-yyyy hh24:mi:ss'),to_char(last_date,'dd-mm-yyyy hh24:mi:ss') from dba_jobs where job=81;
--upper(what) like '%AMS_PKG_UDAAN_DCHANNEL.AMS_SP_HIBERNATE_JOB%';
select log_user,what,job,broken,FAILURES,TOTAL_TIME,to_char(next_date,'dd-mm-yyyy hh24:mi:ss'),to_char(this_date,'dd-mm-yyyy hh24:mi:ss') from dba_jobs where job=1703;
col what for a60
col next_date for a20
col last_date for a20
select log_user,what,job,broken,FAILURES,TOTAL_TIME,to_char(next_date,'dd-mm-yyyy hh24:mi:ss') Next_Date,to_char(last_date,'dd-mm-yyyy hh24:mi:ss') Last_date,interval
from dba_jobs WHERE upper(what) like '%CREATE_REJTXNRPT%';
broken = 'Y';
job=1703;IN (76268,76269,76270);
col log_user for a10
col what for a60
col next_date for a20
col last_date for a20
select log_user,job,broken,FAILURES,TOTAL_TIME,to_char(next_date,'dd-mm-yyyy hh24:mi:ss') Next_Date,to_char(last_date,'dd-mm-yyyy hh24:mi:ss') Last_date,interval
from dba_jobs where last_date like sysdate;
WHERE job=1783;
VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'begin pclmmed.SP_INSTTMEDCLM; end;',
SYSDATE,'SYSDATE + 120/1440');
commit;
END;
/
print jobno
begin
dbms_job.change(755,'begin etl.pk_job_controller.sp_run_group(''CP-Daily-Schedulers''); end;',trunc(sysdate)+1,'trunc(sysdate)+1+8/24');
commit;
end;
/
exec dbms_job.next_date(755, SYSDATE + 11.5/24);
VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'begin etl.pk_job_controller.sp_run_group(''CP-Daily-Schedulers''); end;',
SYSDATE+1,'SYSDATE + 120/1440');
commit;
END;
/
print jobno
NOTE :- To stop a JOB in DBA_JOBS. 1st Disable DBA_JOB & then kill session. The only way to stop DBA_JOBS
BEGIN
DBMS_JOB.change(444,
'begin PRL_PKG_EXTERNAL_UPLOADS.sp_update_resource_master; commit; end;',
SYSDATE+120/1440, 'SYSDATE+180/1440');
commit;
END;
exec DBMS_JOB.run(464);
BEGIN
DBMS_JOB.REMOVE(6865);
COMMIT;
END;
BEGIN
DBMS_JOB.REMOVE(19718);
COMMIT;
END;
BEGIN
DBMS_IJOB.REMOVE(27192);
COMMIT;
END;
/
BEGIN
DBMS_JOB.broken(28730,TRUE);
COMMIT;
END;
/
BEGIN
DBMS_JOB.REMOVE(28730);
COMMIT;
END;
LOG_USER
------------------------------
WHAT
-----------------------------------------------------------------------------------------------------------------
-
JOB B FAILURES TOTAL_TIME TO_CHAR(NEXT_DATE,' TO_CHAR(THIS_DATE,'
---------- - ---------- ---------- ------------------- -------------------
HSLRNRPROD
EOD_UPD_INFC.PROCESS_FILE('001','BASE','SALES','220','cmanil',TO_DATE('22.06.2012', 'dd.MM.yyyy')) ;
19718 N 9 400 23-06-2012 17:01:07
BEGIN
DBMS_JOB.REMOVE(51);
COMMIT;
END;
BEGIN
DBMS_JOB.REMOVE(2);
COMMIT;
END;
BEGIN
DBMS_JOB.REMOVE(24);
COMMIT;
END;
EXEC DBMS_JOB.BROKEN(2670,TRUE);
EXEC DBMS_JOB.BROKEN(2670,TRUE);
EXEC DBMS_JOB.BROKEN(519,TRUE);
EXEC DBMS_JOB.BROKEN(520,TRUE);
EXEC DBMS_JOB.BROKEN(3208,TRUE);
EXEC DBMS_JOB.BROKEN(3196,TRUE);
EXEC DBMS_JOB.BROKEN(51309,TRUE);
EXEC DBMS_JOB.BROKEN(51644,TRUE);
exec DBMS_JOB.run(3);
BEGIN
DBMS_JOB.change(3,
'viking.viking1',
SYSDATE+20/1440, 'SYSDATE+180/1440');
commit;
END;
VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'viking.viking1;',
SYSDATE+20/1440,'SYSDATE + 120/1440');
commit;
END;
/
print jobno
======= DIRECTORIES / DATAPMP ================
CREATE OR REPLACE DIRECTORY test_dir AS '/u01/app/oracle/oradata/';
GRANT READ, WRITE ON DIRECTORY test_dir TO scott;
expdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIR dumpfile=EMP_DEPT.dmp logfile=expdpEMP_DEPT.log SCHEMAS=SCOTT,HR,ALI
impdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIR dumpfile=EMP_DEPT.dmp logfile=impdpEMP_DEPT.log
CREATE OR REPLACE DIRECTORY datapmp_exp AS 'd:\datapmp_exp';
GRANT READ, WRITE ON DIRECTORY datapmp_exp to system;
set oracle_sid=hdfcprod2
expdp system/oracle directory=datapmp_exp dumpfile=expdp_FULL_19082010_%u.dmp logfile=expdp_FULL_24092010.log full=y filesize=25G
set oracle_sid=hdfcamh
impdp system/oracle directory=DATAPMP_EXP dumpfile=expdp_FULL_19082010_%u.dmp logfile=IMP_AMS_TAB_01092010.log
--- DataPMP Script ---
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (set fDate=DATAPMP_exphdfcprod_%%j%%k%%l)
echo -+++++++++++++++++++++++- EXPORT log -+++++++++++++++++++++++->> D:\datapmp_exp\logs\Datapmp_HDFCPRODEXP.Log
Del D:\datapmp_exp\*.* /q >> D:\datapmp_exp\logs\Datapmp_HDFCPRODEXP.Log
set oracle_sid=hdfcprod
expdp system/oracle directory=datapmp_exp dumpfile=%fdate%.dmp logfile=%fdate%.log
echo -+++++++++++++++++++++++- EXPORT log -+++++++++++++++++++++++- >> D:\datapmp_exp\logs\Datapmp_HDFCPRODEXP.Log
exit
---- Datapmp Example -----
move E:\datapmp_exp\EXPDP_PRL_Sys_1.dmp E:\datapmp_exp\EXPDP_PRL_Sys_1_Prev.dmp
move E:\datapmp_exp\EXPDP_PRL_Sys_1.log E:\datapmp_exp\EXPDP_PRL_Sys_1_Prev.log
set oracle_sid=prlprod
expdp system/oracle directory=datapmp_exp dumpfile=expdp_PRL_Sys_1.dmp logfile=expdp_PRL_Sys_1.log tables=prl_prod.PRL_CASE_AUDIT_TRAIL EXCLUDE=STATISTICS,CONSTRAINT,TRIGGER query=\"WHERE PCAT_CR_DT like sysdate - 1\"
xcopy E:\Datapmp_exp\EXPDP_PRL_Sys_1.dmp z:\
xcopy E:\Datapmp_exp\EXPDP_PRL_Sys_1.log z:\
move D:\datapmp_exp\impdp_PRL_Sys_1.log D:\datapmp_exp\impdp_PRL_Sys_1_Prev.log
set oracle_sid=hdfcprod2
impdp system/oracle directory=datapmp_exp dumpfile=expdp_PRL_Sys_1.dmp logfile=impdp_PRL_Sys_1.log tables=PRL_CASE_AUDIT_TRAIL remap_schema=prl_prod:SAM_NEW remap_tablespace=TBS_PRL_PROD:AMS_TRANSACTION_DATA remap_tablespace=TBS_PRL_PROD_INDX:INDX TABLE_EXISTS_ACTION=append
del D:\datapmp_exp\EXPDP_PRL_SYS_1.*
SELECT a.sid, c.pid, c.spid, a.username, b.event, b.wait_time, b.seconds_in_wait, b.p1, b.p2, b.p3
FROM v$session a, v$session_wait b, v$process c
WHERE a.sid = b.sid
AND a.paddr = c.addr
AND b.event LIKE 'enq: RO%' ;
018023289
Paras Query:
Large:
set lines 200
set pages 9999
col logon for a20
col client_info for a30
col status for a10
col program for a30
col event for a30
col username for a15
col running_since for a20
select
a.inst_id,a.sid,a.program,a.event,a.username,a.status,a.sql_hash_value,
to_char(logon_time,'dd-mm-yy hh:mi:ss') "LOGON",
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "RUNNING_SINCE"
from
gv$session a
where
a.type='USER'
AND floor(last_call_et/3600)*60+floor(mod(last_call_et,3600)/60) > 5
AND a.STATUS = 'ACTIVE'
AND a.SID > 10
order by a.last_call_et;
set lines 200
set pages 9999
col logon for a20
col client_info for a30
col status for a10
col program for a30
col event for a30
col username for a15
col running_since for a20
select
a.inst_id,a.sid,a.program,a.event,a.username,a.status,a.sql_hash_value,
to_char(logon_time,'dd-mm-yy hh:mi:ss') "LOGON",
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "RUNNING_SINCE",
last_call_et
from
gv$session a
where
a.type='USER'
AND floor(last_call_et/3600)*60+floor(mod(last_call_et,3600)/60) > 2
AND a.STATUS = 'ACTIVE'
AND a.SID > 10
order by a.last_call_et;
select sql_text from v$sqltext where HASH_VALUE='&HASH_VALUE' order by piece;
3786238237
1439292066
224658237
select sid,serial#,program,event,last_call_et,floor(last_call_et/3600)*60+floor(mod(last_call_et,3600)/60) from v$session where schemaname not like 'SYS';
select sql_text from v$sqltext where HASH_VALUE='&HASH_VALUE' order by piece;
select decode(lob.kglobtyp, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE',
7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
11, 'PACKAGE BODY', 12, 'TRIGGER',
13, 'TYPE', 14, 'TYPE BODY',
19, 'TABLE PARTITION', 20, 'INDEX PARTITION', 21, 'LOB',
22, 'LIBRARY', 23, 'DIRECTORY', 24, 'QUEUE',
28, 'JAVA SOURCE', 29, 'JAVA CLASS', 30, 'JAVA RESOURCE',
32, 'INDEXTYPE', 33, 'OPERATOR',
34, 'TABLE SUBPARTITION', 35, 'INDEX SUBPARTITION',
40, 'LOB PARTITION', 41, 'LOB SUBPARTITION',
42, 'MATERIALIZED VIEW',
43, 'DIMENSION',
44, 'CONTEXT', 46, 'RULE SET', 47, 'RESOURCE PLAN',
48, 'CONSUMER GROUP',
51, 'SUBSCRIPTION', 52, 'LOCATION',
55, 'XML SCHEMA', 56, 'JAVA DATA',
57, 'SECURITY PROFILE', 59, 'RULE',
62, 'EVALUATION CONTEXT',
'UNDEFINED') object_type,
lob.KGLNAOBJ object_name,
pn.KGLPNMOD lock_mode_held,
pn.KGLPNREQ lock_mode_requested,
ses.sid,
ses.serial#,
ses.username
FROM
x$kglpn pn,
v$session ses,
x$kglob lob,
v$session_wait vsw
WHERE
pn.KGLPNUSE = ses.saddr and
pn.KGLPNHDL = lob.KGLHDADR
and lob.kglhdadr = vsw.p1raw
and vsw.event like '%free%'
order by lock_mode_held desc;
select sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi'),sql_hash_value from gv$session where sid=266;
set lines 200
set pages 200
col event for a40
col program for a30
col inst_id for 99
col serial# for 999999
select inst_id,sid,serial#,event,program,action,sql_hash_value,to_char(logon_time,'dd-mm-yyyy hh24:mi'),client_info from gv$session where (event like '%free%' or event like '%local%' or event like '%local%') order by sql_hash_value,logon_time;
select SQL_TEXT from v$sqltext where HASH_VALUE='3114014027' order by PIECE;
set lines 200
set pages 200
col event for a40
col program for a30
col inst_id for 99
col serial# for 999999
col Logon_Time for a20
select inst_id,sid,serial#,event,program,action,sql_hash_value,to_char(logon_time,'dd-mm-yyyy hh24:mi') Logon_time,client_info from gv$session where sid in (select distinct session_id from gv$locked_object) order by logon_time;
Hdfc Bank Customer Support - 61606161
explain plan for
SELECT f_docnumber,f_docclassnumber,f_entrydate,f_archivedate,f_deletedate,f_retentbase,f_retentdisp,f_retentoffset,f_pages,f_doctype,f_accessrights,f_docformat,f_doclocation,f_ce_os_id,f_accessrights_rd,f_accessrights_wr,f_accessrights_ax,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42,a43,a44,a45,a46,a47,a48,a49,a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,a60,a61,a62,a63,a64,a65,a66,a67,a68,a69,a70,a71 FROM f_sw.doctaba WHERE f_docnumber = 29683505;
@?/rdbms/admin/utlxpls.sql
======= SCHEDULER JOBS =============
SELECT name FROM dba_dependencies
WHERE referenced_name = 'DBMS_SCHEDULER'
UNION
SELECT referenced_name FROM dba_dependencies
WHERE name = 'DBMS_SCHEDULER';
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),
to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss'),failure_count from dba_scheduler_jobs where upper(JOB_action) like '%CREATE_REJTXNRPT%';
EXEC DBMS_STATS.gather_table_stats('PRL_PROD', 'RESOURCE_MASTER_MIRROR');
EXEC DBMS_STATS.gather_table_stats('FLEXPROD_HOST', 'CH_ACCT_CUST_XREF_AUDIT', cascade => true);
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,enabled,REPEAT_INTERVAL,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss'),failure_count from dba_scheduler_jobs where JOB_NAME like '%AGENT%';
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss'),failure_count from dba_scheduler_jobs where JOB_NAME like '%Mat_View%';
select owner,job_name,to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),JOB_ACTION from dba_scheduler_jobs where job_name like '%SP_WONDERS_DATA_CHECK%';
UPDATE_MEDICAL_FOR_CLIAMS SCHEDULED EXECUTABLE BEGIN pclmmed.SP_INSTTMEDCLM; END;
SET LONG 100000
SELECT DBMS_METADATA.get_ddl('PROCOBJ','MY_TEST_JOB', 'TEST') AS job_def FROM dual;
SET LONG 100000
SELECT DBMS_METADATA.get_ddl('PROCOBJ',JOB_NAME, owner) AS job_def FROM
dba_scheduler_jobs where job_name = 'AMS_PKG_WALLET_LEADS_JOB' and owner = 'AMS';
begin
dbms_scheduler.drop_job
(
job_name => 'prl_prod.Mat_View_Refersh'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'prl_prod.Mat_View_Refersh',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN DBMS_SNAPSHOT.REFRESH(LIST => ''PRL_PROD.PRL_MVIEW_DMC_INW_TAT_DET_REP''
,PUSH_DEFERRED_RPC => TRUE
,REFRESH_AFTER_ERRORS => FALSE
,PURGE_OPTION => 1
,PARALLELISM => 0
,ATOMIC_REFRESH => TRUE
,NESTED => FALSE); END;',
start_date => TO_DATE('10/23/2012 06:00 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Mat View Referesh'
);
end;
/
wondersii.PRC_NEW_COMP_SMS_1;
begin
dbms_scheduler.create_job
(
job_name => 'WONDERSII.PRC_NEW_COMP_SMS',
job_type => 'PLSQL_BLOCK',
job_action => 'begin wondersii.PRC_NEW_COMP_SMS_1; wondersii.PRC_NEW_COMP_SMS_2; end;',
start_date => TO_DATE('10/04/2012 07:00 AM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Send SMS PRC_NEW_COMP_SMS_1 N 2'
);
end;
/
GP.GP_UNIT_STMT_PKG.SP_EXT_UNIT_STMTS;
rrrr
begin
dbms_scheduler.create_job
(
job_name => 'GP.GP_UNIT_STMT',
job_type => 'PLSQL_BLOCK',
job_action => 'begin GP.GP_UNIT_STMT_PKG.SP_EXT_UNIT_STMTS; end;',
start_date => TO_DATE('11/21/2012 07:00 AM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
enabled => true,
comments => 'GP.GP_UNIT_STMT_PKG.SP_EXT_UNIT_STMTS'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'prl_prod.AMS_AGENT_DATA_UPLOAD',
job_type => 'PLSQL_BLOCK',
job_action => 'begin prl_prod.prl_pkg_external_uploads.sp_update_agent_master; commit; end;',
start_date => TO_DATE('05/26/2012 09:00 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=MINUTELY; INTERVAL=360',
enabled => true,
comments => 'External Upload rr2'
);
end;
begin
dbms_scheduler.create_job
(
job_name => 'wondersii.UPDATE_MEDICAL_FOR_CLIAMS',
job_type => 'PLSQL_BLOCK',
job_action => 'begin wondersii.pclmmed.SP_INSTTMEDCLM; end;',
start_date => TO_DATE('10/30/2010 09:30 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Update Medical for Claim'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'HSLRNRPROD.EOD_AgreementClosure_SJOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin HSLRNRPROD.EOD_AgreementClosure(''001'',''100'',get_businessdate(''001''),''SYSTEM'',NULL); end;',
start_date => TO_DATE('09/13/2012 02:00 AM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'EOD Agreement JOB'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'ams.AMS_SP_CHANGE_REQUEST_SJOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin ams.AMS_SP_CHANGE_REQUEST; end;',
start_date => TO_DATE('09/13/2012 10:30 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Executing AMS_SP_CHANGE_REQUEST'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'CP.PK_CONTROLLER_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin ETL.PK_JOB_CONTROLLER.sp_run_group(''CP Daily Extraction''); ETL.PK_JOB_CONTROLLER.sp_run_group(''Purge Unit Statements''); end;',
start_date => TO_DATE('08/07/2012 03:00 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Execute ETL Controller Job'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'GP.PK_CONTROLLER_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin ETL.PK_JOB_CONTROLLER.sp_run_group(''GP-Daily Extraction''); END;',
start_date => TO_DATE('08/31/2012 03:10 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Execute ETL Controller Job'
);
end;
/
begin dbms_scheduler.drop_job(job_name => 'GP.PK_CONTROLLER_JOB'); end;
/
BEGIN
-- Job defined by existing schedule and inline program.
DBMS_SCHEDULER.create_job (
job_name => 'PRL_PROD.JOB_UPDATE_RESOURCE_MASTER',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN PRL_PROD.rr_UPDATE_RESOURCE_MASTER; COMMIT; END;',
start_date => TO_DATE('10/20/2012 08:00 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=MINUTELY; INTERVAL=20',
enabled => TRUE ,
comments => 'Job defined by existing schedule and inline program.');
END;
/
====================================
===EXECUTING EXECUTABLE from Scheduler JOBS
Need to start JOB Scheduler Service from Services.msc
select status, error#, substr(additional_info,1,500)
from user_scheduler_job_run_details
where job_name = 'EXP_MDEALING';
begin
dbms_scheduler.create_job
(
job_name => 'SYSTEM.EXP_MDEALUAT',
job_type => 'EXECUTABLE',
job_action => 'D:\BKP_Test\MFundMcy.bat',
repeat_interval => 'FREQ=DAILY',
enabled => FALSE,
comments => 'Exp Backup to D:\BKP_Test\MFundMcy.bat'
);
end;
/
exp sys/sys@neft_khr filename=E:\shaik\ABC.dmp logfile=E:\shaik\ABC.log rows=N
select username,owner,obj_name,action_name,timestamp from dba_audit_trail where obj_name like upper('%ap_sp_get%') order by 5;
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),
to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss'),failure_count
from dba_scheduler_jobs where JOB_NAME like '%AMS_PKG_POLICY%';
Begin
Dbms_scheduler.set_attribute
(
name => 'AMS.LTS_LEADS_SUMMARY_CALC_MERGE'
,attribute => 'repeat_interval'
,value => 'FREQ=DAILY;BYHOUR=9;BYMINUTE=0;BYSECOND=0'
);
End;
/
Begin
Dbms_scheduler.set_attribute
(
name => 'AMS.AMS_PKG_UNIT_STATEMENT'
,attribute => 'repeat_interval'
,value => 'FREQ=WEEKLY; BYDAY=MON; BYHOUR=18; BYMINUTE=14;'
);
End;
/
Begin
Dbms_scheduler.set_attribute
(
name => 'wondersii.PRC_NEW_COMP_SMS'
,attribute => 'repeat_interval'
,value => 'FREQ=DAILY;BYHOUR=21;BYMINUTE=20;BYSECOND=0'
);
End;
/
FREQ=WEEKLY; BYDAY=TUE; BYHOUR=11; BYMINUTE=24;
BEGIN
-- Job defined by existing schedule and inline program.
DBMS_SCHEDULER.create_job (
job_name => 'AMS.TEST_TRUNCATE',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN ams.RR_PKG; END;',
start_date => TO_DATE('12/22/2011 09:45 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => TRUE ,
comments => 'AMS.TEST_TRUNCATE');
END;
/
select
EXEC DBMS_SCHEDULER.DROP_JOB('AMS.TEST_TRUNCATE3');
EXEC DBMS_SCHEDULER.DROP_JOB('AMS.TEST_TRUNCATE');
exec DBMS_SCHEDULER.RUN_JOB('AMS.TEST_TRUNCATE');
exec DBMS_SCHEDULER.RUN_JOB('WONDERSII.PRC_NEW_COMP_SMS');
EXEC DBMS_SCHEDULER.DROP_JOB('CP.PK_CONTROLLER_JOB');
insert into ams.AMS_USAGE_DETAIL_PZ_BKPPP (select * from ams.AMS_POLICY_DETAILS);
commit;
exec DBMS_SCHEDULER.RUN_JOB('AMS.TEST_TRUNCATE');
create or replace procedure ams.rr_PKG is
begin
EXECUTE IMMEDIATE 'TRUNCATE TABLE AMS_USAGE_DETAIL_PZ_BKPPP';
End rr_PKG;
/
begin
EXECUTE IMMEDIATE 'TRUNCATE TABLE AMS_USAGE_DETAIL_PZ_BKPPP';
end;
/
create table ams.AMS_USAGE_DETAIL_PZ_BKPPP as (select * from ams.AMS_POLICY_DETAILS);
drop table ams.AMS_USAGE_DETAIL_PZ_BKPPP;
select count(*) from ams.AMS_USAGE_DETAIL_PZ_BKPPP;
insert into ams.AMS_USAGE_DETAIL_PZ_BKPPP (select * from ams.AMS_POLICY_DETAILS);
commit;
exec DBMS_SCHEDULER.RUN_JOB('AMS.TEST_TRUNCATE');
SQL> insert into ams.AMS_USAGE_DETAIL_PZ_BKPPP (select * from ams.AMS_POLICY_DETAILS);
4566350 rows created.
Elapsed: 00:01:33.76
SQL> commit;
Commit complete.
Elapsed: 00:00:00.14
SQL> exec DBMS_SCHEDULER.RUN_JOB('AMS.TEST_TRUNCATE');
PL/SQL procedure successfully completed.
Elapsed: 00:00:55.96
SQL>
====================================
begin
dbms_scheduler.create_job
(
job_name => 'ARC_MOVE_3',
job_type => 'EXECUTABLE',
job_action => '/home/arup/dbtools/move_arcs.sh',
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
enabled => true,
comments => 'Move Archived Logs to a Different Directory'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'ARC_MOVE_3',
job_type => 'EXECUTABLE',
job_action => '/home/arup/dbtools/move_arcs.sh',
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
enabled => true,
comments => 'Move Archived Logs to a Different Directory'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'WONDERSII.UPDATE_MEDICAL_FOR_CLIAMS',
job_type => 'EXECUTABLE',
job_action => 'BEGIN WONDERSII.PCLMMED.SP_INSTTMEDCLM; END;',
start_date => TO_DATE('10/18/2010 09:30 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Update Medical for Claim'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'IDEAS.JOB_IDEAS_UPDATE_BUSINESSDATE',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN IDEAS.IDEAS_UPDATE_BUSINESSDATE; COMMIT; END;',
start_date => TO_DATE('11/13/2010 01:00 AM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'IDEAS_UPDATE_BUSINESSDATE'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'wondersii.UPDATE_MEDICAL_FOR_CLIAMS',
job_type => 'PLSQL_BLOCK',
job_action => 'begin wondersii.pclmmed.SP_INSTTMEDCLM; end;',
start_date => TO_DATE('10/30/2010 09:45 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Update Medical for Claim'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'JOB_SP_WONDERS_DATA_CHECK',
job_type => 'EXECUTABLE',
job_action => 'begin WONDERSII.SP_WONDERS_DATA_CHECK; end;',
start_date => TO_DATE('08/25/2010 4:21 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'freq=daily;byhour=6;byminute=30;bysecond=0',
enabled => true,
comments => 'Executes SP_WONDERS_DATA_CHECK Proc. daily at 6:30 AM'
);
end;
/
BEGIN
-- Job defined by existing schedule and inline program.
DBMS_SCHEDULER.create_job (
job_name => 'IDEAS.JOB_IDEAS_UPLOAD_RECEIPT',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN IDEAS.IDEAS_UPLOAD_RECEIPT; COMMIT; END;',
start_date => TO_DATE('04/14/2011 09:05 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=MINUTELY; INTERVAL=180',
enabled => TRUE ,
comments => 'Job defined for IDEAS Upload Receipt.');
END;
/
select to_char(sysdate,'dd-mm-yyyy hh24:mi:ss') from dual;
EXEC DBMS_SCHEDULER.DROP_JOB('IDEAS.JOB_IDEAS_UPLOAD_RECEIPT');
EXEC DBMS_SCHEDULER.RUN_JOB('WONDERSII.UPDATE_MEDICAL_FOR_CLIAMS');
EXEC DBMS_SCHEDULER.ENABLE('JOB_SCHEDULE_SMSAMSMAST');
EXEC DBMS_SCHEDULER.DISABLE('AMSLTS.REMOVEEXPIRED_ASPNET_SESSITEMS');
EXEC DBMS_SCHEDULER.DISABLE('AMS.AMS_PKG_UNIT_STATEMENT');
EXEC DBMS_SCHEDULER.ENABLE('AMS.AMS_PKG_UNIT_STATEMENT');
EXEC DBMS_SCHEDULER.STOP_JOB('SYS.JOB_IDEAS_UPLOAD_RECEIPT');
EXEC DBMS_SCHEDULER.STOP_JOB('IDEAS.JOB_IDEAS_UPLOAD_RECEIPT');
EXEC DBMS_SCHEDULER.RUN_JOB('IDEAS.JOB_IDEAS_UPDATE_BUSINESSDATE');
EXEC DBMS_SCHEDULER.DISABLE('JOB_IDEAS_UPLOAD_RECEIPT');
EXEC DBMS_SCHEDULER.DISABLE('UNAUTHCHECKJOB');
EXEC DBMS_SCHEDULER.ENABLE('IDEAS.JOB_IDEAS_UPDATE_BUSINESSDATE');
EXEC DBMS_SCHEDULER.DROP_JOB('CP.SMS_OFFLINE_USER_TXN');
EXEC DBMS_SCHEDULER.RUN_JOB('MFUNDMCY.EXP_MDEALING');
Farzad - 9867156217
SELECT name FROM dba_dependencies
WHERE referenced_name = 'DBMS_SCHEDULER'
UNION
SELECT referenced_name FROM dba_dependencies
WHERE name = 'DBMS_SCHEDULER';
set lines 200
set pages 200
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss') from dba_scheduler_jobs where JOB_NAME like '%RECEIPT%';
select owner,job_name,to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),JOB_ACTION from dba_scheduler_jobs where job_name like '%SP_WONDERS_DATA_CHECK%';
To show details on job run:
select log_date
, job_name
, status
, req_start_date
, actual_start_date
, run_duration
from dba_scheduler_job_run_details
To show running jobs:
select job_name
, session_id
, running_instance
, elapsed_time
, cpu_used
from dba_scheduler_running_jobs;
To show job history:
select log_date
, job_name
, status
from dba_scheduler_job_log;
show all schedules:
select schedule_name, schedule_type, start_date, repeat_interval
from dba_scheduler_schedules;
show all jobs and their attributes:
select *
from dba_scheduler_jobs
show all program-objects and their attributes
select *
from dba_scheduler_programs;
show all program-arguments:
select *
from dba_scheduler_program_args;
FREQ=DAILY
freq=daily;byhour=0;byminute=0;bysecond=0
FREQ=MINUTELY;INTERVAL=60
FREQ = HOURLY; INTERVAL = 1
FREQ=DAILY
FREQ=DAILY
freq=monthly;interval=1;bymonthday=1;byhour=01;byminute=01;bysecond=01
FREQ=DAILY;BYHOUR=11;BYMINUTE=24;
To run a job every Tuesday at 11:24, you could use any of the following (they are all equivalent):
FREQ=DAILY; BYDAY=TUE; BYHOUR=11; BYMINUTE=24;
FREQ=WEEKLY; BYDAY=TUE; BYHOUR=11; BYMINUTE=24;
FREQ=YEARLY; BYDAY=TUE; BYHOUR=11; BYMINUTE=24;
So far, this isn't much easier than the old-style Interval syntax. However, Calendaring syntax makes it much easier to specify more complex expressions. For example, to run a job every 3rd month on the 11th of the month, use the INTERVAL clause:
FREQ=MONTHLY; INTERVAL=3; BYMONTHDAY=11;
Varying intervals are much easier to express, too. To run a job Tuesday and Thursday at 11, 14 and 22 o'clock:
FREQ=WEEKLY; BYDAY=TUE,THUR; BYHOUR=11,14,22;
==============
creation2:
set long 999999
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS
where username like 'SWPROWHUB1';
set long 999999
select DBMS_METADATA.GET_DDL('TABLESPACE',tablespace_name) db_Tablespace
from dba_tablespaces
where tablespace_name like 'MFUND';
set long 999999
select DBMS_METADATA.GET_DDL('PROFILE',profile) db_SCHEMA
from dba_Profiles
where PROFILE like '&MFUND';
set long 999999
select DBMS_METADATA.GET_DDL('PROFILE',profile) db_SCHEMA
from dba_Profiles
where PROFILE like 'WONDERS';
@getprofile:
set long 999999
select DBMS_METADATA.GET_DDL('PROFILE',profile) db_SCHEMA
from dba_Profiles
where PROFILE like '&profile';
set long 999999
select DBMS_METADATA.GET_DDL('TYPE',object_name,'PRL_PROD') db_SCHEMA
from dba_objects
where object_type = 'TYPE' and owner like 'PRL%' and object_name = 'MYSCALARTYPE';
set long 999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,'SWPROWHUB1') db_SCHEMA
from dba_tables
where table_name = 'AUDIT_TRAIL';
set long 999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,'SAM_NEW') db_SCHEMA
from dba_tables
where table_name = 'ROOTWISE_AGENT_DETAILS';
set long 999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,'AMS') db_SCHEMA
from dba_external_tables
where table_name = 'AMS_ELA_COMMISSION_DETAILS';
set long 999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,owner) db_SCHEMA
from dba_external_tables
where table_name = upper('ams_lts_ext_lead_non_cc_upl');
set long 999999
select DBMS_METADATA.GET_DDL('SYNONYM',synonym_name,'PUBLIC') db_SCHEMA
from dba_synonyms
where synonym_name like 'AMS_PKG_ALT_LEAD_DETAILS';
set long 999999
select DBMS_METADATA.GET_DDL('SYNONYM',synonym_name,'PUBLIC') db_SCHEMA
from dba_synonyms
where synonym_name like 'TOAD_SPACE';
drop PUBLIC SYNONYM TOAD_SPACE;
CREATE OR REPLACE PUBLIC SYNONYM TOAD_SPACE FOR TOAD.TOAD_SPACE;
set long 999999
select DBMS_METADATA.GET_DDL('INDEX',index_name,'SWPROWHUB1') db_SCHEMA
from dba_indexes
where index_name like 'IDX_AUDIT_TRAIL_FK';
CREATE USER "WONDERSTEAM" IDENTIFIED BY VALUES '6A2F67D21BA72AD5'
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
PROFILE "APP_USER_PROFILE" ;
CREATE USER "WONDERSII_BKP" IDENTIFIED BY VALUES 'D6BA72C81E0C6EBE'
DEFAULT TABLESPACE "TS_WONDERSII_DATA"
TEMPORARY TABLESPACE "TEMP"
PROFILE "WONDERS"
ACCOUNT LOCK ;
CREATE USER "WONDERSII" IDENTIFIED BY VALUES '8CAB501D9F604C89'
DEFAULT TABLESPACE "TS_WONDERSII_DATA"
TEMPORARY TABLESPACE "TEMP"
PROFILE "WONDERS" ;
CREATE USER "SAM_NEW" IDENTIFIED BY VALUES 'S:9CD142D3F27506DE4CB7F42413909B58C3FA7D039E28C364376447677440;9E332FF57FAC41C4'
DEFAULT TABLESPACE "AMS_TRANSACTION_DATA"
TEMPORARY TABLESPACE "TEMPGRP5";
exec ams.Analyze_SB_Tables_rr; == VIVEK Execute this.
======= SCHEMA @creation SQL Script ==============
BIPLUS, HAAS, HPS, HSS
undefine USR
define USR=&USRS
set head off
set echo off
set feedback off
set long 999999
set lines 160
set pages 200
spool ./SSRINI_Creation_Script2.sql
select name,open_mode from gv$database;
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA from dba_USERS where username like '&&USR';
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like '&&USR';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = '&&USR';
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee = '&&USR';
spool off;
set head on
set echo on
set feedback on
================================================================================================================
============ Schema Creation SHELL Script =====================================
Both this Files to be created
$ cat SC.sh
echo "set head off" > ./Users.sql
echo "set feedback off" >> ./Users.sql
echo "set lines 30" >> ./Users.sql
echo "set pages 999" >> ./Users.sql
echo "spool ./Users_rr.out" >> ./Users.sql
echo "select username from dba_users order by 1;" >> ./Users.sql
echo "spool off " >> ./Users.sql
echo "exit" >> ./Users.sql
sqlplus "/ as sysdba" @./Users.sql
echo "`cat ./Users_rr.out"
v1=`cat Users_rr.out`
for filename in $v1
do
echo "Schema Creation in Process for : $filename"
echo "define USR=$filename" > ./Schema_Creation.sql
echo "`cat ./Schema_Creation.txt`" >> ./Schema_Creation.sql
sqlplus "/ as sysdba" @/u025/OWIP_rr/Schema_Creation.sql
done
$
$
$
$ cat Schema_Creation.txt
set lines 160
set pages 2002
set time on
column machine format a20
column event format a35
column program format a30
column schemaname for a10
column action format a50
set head off
set echo off
set feedback off
set long 999999
set lines 160
set pages 200
column FC_cdt new_value file_time noprint
column FC_DB new_value file_DB noprint
column FC_Usr new_value file_Usr noprint
select to_char(sysdate,'dd_mm_yyyy_hh24_mi_ss') FC_cdt from dual;
select instance_name FC_DB from gv$instance;
select username FC_Usr from dba_users where username = '&&USR';
spool ./&file_DB._&file_Usr._Session_Check_&file_time..sql
select name,open_mode from gv$database;
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA from dba_USERS where username like '&&USR';
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like '&&USR';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = '&&USR';
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee = '&&USR';
spool off;
set head on
set echo on
set feedback on
exit
================================================================================================================
spool c:\User_Priv.sql
select 'grant '|| PRIVILEGE || ' to SWPRO;' from DBA_SYS_PRIVS where grantee like 'SWPRO';
select 'grant '|| PRIVILEGE || ' to SWUSER;' from DBA_SYS_PRIVS where grantee like 'SYS';
spool off;
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to amslts1;' from DBA_TAB_PRIVS where grantee = 'AMSLTS';
select 'grant '|| GRANTED_ROLE || ' to amslts1;' from DBA_role_PRIVS where grantee = 'AMSLTS';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = 'PLANPROD';
select * from DBA_tab_PRIVS where grantee = 'HP_DBSPI';
select * from DBA_role_PRIVS where granted_role = 'HP_DBSPI';
select * from DBA_sys_PRIVS where grantee = 'HP_DBSPI';
SELECT 'grant CREATE VIEW,CREATE TABLE,ALTER SESSION,CREATE CLUSTER,CREATE SYNONYM,CREATE SEQUENCE,CREATE DATABASE LINK to '||grantee||';'
FROM dba_role_privs WHERE granted_role = 'CONNECT' AND grantee
NOT IN ('SYS', 'OUTLN', 'SYSTEM', 'CTXSYS', 'DBSNMP','LOGSTDBY_ADMINISTRATOR',
'ORDSYS','ORDPLUGINS', 'OEM_MONITOR', 'WKSYS', 'WKPROXY','WK_TEST',
'WKUSER', 'MDSYS', 'LBACSYS', 'DMSYS','WMSYS', 'OLAPDBA', 'OLAPSVR',
'OLAP_USER','OLAPSYS', 'EXFSYS', 'SYSMAN', 'MDDATA','SI_INFORMTN_SCHEMA',
'XDB', 'ODM');
select distinct grantee from dba_sys_privs
where privilege = 'CREATE VIEW'
and privilege = 'CREATE TABLE'
and privilege = 'ALTER SESSION'
and privilege = 'CREATE CLUSTER'
and privilege = 'CREATE SYNONYM'
and privilege = 'CREATE SEQUENCE'
and privilege = 'CREATE DATABASE LINK';
and grantee ;
select 'grant '|| GRANTED_ROLE || ' to SWUSER;' from DBA_role_PRIVS where grantee = 'SYS';
select owner,sum(bytes/1024/1024/1024) from dba_segments where owner in (select username from dba_users where default_tablespace like 'USERS%') group by owner order by 2;
define USR=&USRS
set head off
set echo off
set feedback off
set long 999999
spool c:\SAM_NEW_USER_Creation_Script.sql
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS
where username like '&&USR';
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like '&&USR';
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee = '&&USR';
spool off;
set head on
set echo on
set feedback on
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like 'LEAP';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where table_name = 'CP_DIR_CLIENT';
spool d:\Priv_Wondersii.txt
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like 'WONDERSII';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = 'WONDERSII';
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee = 'WONDERSII';
spool off;
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where table_name in (select directory_name from dba_directories);
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where table_name = 'AMS_ELA_COMMISSION_DETAILS';
set head off
set echo off
set feedback off
set lines 120
set pages 999
set long 999999
spool c:\USER_Creation_Script.sql
select 'Create tablespace ' || tablespace_name || ' datafile size 2G autoextend on;' from dba_tablespace;
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS where default_tablespace not like 'SYS%';
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
spool off;
set head on
set echo on
set feedback on
spool C:\Privs.txt
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
spool off
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = 'SWPROWHUB1';
=========================================
set long 999999
select DBMS_METADATA.GET_DDL('INDEX',index_name) db_SCHEMA
from dba_indexes
where table_name = 'AMS_LA_NGTV_CMSN_DETAILS';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = 'AMS';
======= PRIVILEGES ==============
set long 999999
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS
where username like 'SAM_NEW';
SET LONG 100000
SELECT DBMS_METADATA.get_ddl('PROCOBJ','MY_TEST_JOB', 'TEST') AS job_def FROM dual;
spool D:\Wipro-DBA\Privileges\DBA_SYS_PRIVS_All_Users.txt
select 'grant '|| PRIVILEGE || ' to SAM_NEW;' from DBA_SYS_PRIVS where grantee like 'AMS';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to SAM_NEW;' from DBA_TAB_PRIVS where grantee = 'ETL';
select 'grant '|| GRANTED_ROLE || ' to SAM_NEW;' from DBA_role_PRIVS where grantee = 'ETL';
spool D:\Wipro-DBA\Privileges\DBA_SYS_PRIVS_All_Users.txt
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS;
spool off;
spool D:\Wipro-DBA\Privileges\DBA_TAB_PRIVS_All_Users.txt
select 'grant ' || PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS;
spool off;
spool D:\Wipro-DBA\Privileges\DBA_ROLE_PRIVS_All_Users.txt
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS;
spool off;
==== PRIV Dynamic Query
select 'grant SELECT,INSERT,UPDATE,DELETE ON ' || owner || '.' || table_name || ' to SIUDCDGR with grant option;' from dba_tables where num_rows is not null and TABLESPACE_NAME is not null and owner in (select username from dba_users where default_tablespace not in ('SYSTEM','SYS','SYSAUX','RMAN'))
select 'grant SELECT,INSERT,UPDATE,DELETE ON ' || owner || '.' || table_name || ' to SIUDCDGR with grant option;' from dba_tables where num_rows is not null and TABLESPACE_NAME is not null and owner in (select username from dba_users where default_tablespace not in ('SYSTEM','SYS','SYSAUX','RMAN'))
set pages 200
set lines 200
col owner for a10
col db_link for a45
col host for a20
select * from dba_db_links;
select grantee,table_owner,table_name,PRIVILEGE from DBA_TAB_PRIVS where grantee = 'AMSLTS';
select grantee,table_owner,table_name,PRIVILEGE from DBA_TAB_PRIVS where grantee = 'LTSSEC';
select grantee,PRIVILEGE,ADMIN_OPTION from DBA_SYS_PRIVS where grantee = 'SAM_NEW';
select grantee,GRANTED_ROLE,ADMIN_OPTION from DBA_role_PRIVS where grantee = 'SAM_NEW';
select grantee,PRIVILEGE,table_name from DBA_TAB_PRIVS where table_name like 'AMS_DIR_CFY%';
select distinct PRIVILEGE from DBA_TAB_PRIVS;
select distinct PRIVILEGE from DBA_SYS_PRIVS;
select distinct GRANTED_ROLE from DBA_role_PRIVS;
Granyted in 11g System
grant GLOBAL QUERY REWRITE to system;
grant SELECT_CATALOG_ROLE to system;
grant CREATE PUBLIC SYNONYM to sam_sit;
select 'grant '|| PRIVILEGE || ' to sam_sit;' from DBA_SYS_PRIVS where grantee = 'SAM';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to ETL;' from DBA_TAB_PRIVS where grantee = 'ETL';
select 'grant '|| GRANTED_ROLE || ' to sam_sit;' from DBA_role_PRIVS where grantee = 'SAM';
DBMS_SWRF_INTERNAL
---NOTE : -----
To provide a user, select privilege on all the schemas -- Grant -- SELECT ANY TABLE -- This will provide select priv. on all the user except SYS Users
e.g :-
grant select any table to abc;
-- This will provide select on all the table in database except of tables owned by SYS.
create user sam_sit identified by sam_sit default tablespace ams_transaction_data quota unlimited on ams_transaction_data;
@fullexp
grant DATAPUMP_EXP_FULL_DATABASE to user;
grant DATAPUMP_IMP_FULL_DATABASE to user;
grant IMP_FULL_DATABASE to sam_sit;
grant CONNECT to sam_sit;
grant RESOURCE to sam_sit;
grant CREATE PUBLIC SYNONYM to sam_sit;
grant CREATE ANY CONTEXT to sam_sit;
grant UNLIMITED TABLESPACE to sam_sit;
grant CREATE ANY DIRECTORY to sam_sit;
grant DROP PUBLIC SYNONYM to sam_sit;
grant ALTER SESSION to sam_sit;
grant SELECT on V_$THREAD to SAM_SIT;
grant SELECT on V_$PROCESS to SAM_SIT;
grant SELECT on V_$SESSION to SAM_SIT;
grant SELECT on V_$LATCH to SAM_SIT;
grant SELECT on V_$MYSTAT to SAM_SIT;
grant SELECT on V_$STATNAME to SAM_SIT;
grant SELECT on V_$PARAMETER to SAM_SIT;
grant SELECT on V_$INSTANCE to SAM_SIT;
grant SELECT on V_$SESSION_WAIT to SAM_SIT;
grant SELECT on V_$SYSTEM_EVENT to SAM_SIT;
grant SELECT on GV_$THREAD to SAM_SIT;
grant SELECT on GV_$PROCESS to SAM_SIT;
grant SELECT on GV_$SESSION to SAM_SIT;
grant SELECT on GV_$LATCH to SAM_SIT;
grant SELECT on GV_$MYSTAT to SAM_SIT;
grant SELECT on GV_$STATNAME to SAM_SIT;
grant SELECT on GV_$PARAMETER to SAM_SIT;
grant SELECT on GV_$INSTANCE to SAM_SIT;
grant SELECT on GV_$SESSION_WAIT to SAM_SIT;
grant SELECT on GV_$SYSTEM_EVENT to SAM_SIT;
grant SELECT on V_$CONTEXT to SAM_SIT;
grant SELECT on GV_$CONTEXT to SAM_SIT;
grant EXECUTE on DBMS_SESSION to SAM_SIT;
grant EXECUTE on DBMS_LOCK to SAM_SIT;
grant READ on SAM_MASTERS to SAM_SIT;
grant WRITE on SAM_MASTERS to SAM_SIT;
======= LOCKS ========
column owner format a10
column object_name format a30
column machine format a15
column object_type format a10
column osuser format a15
column schemaname format a12
select c.owner,c.object_name,c.object_type,b.sid,b.serial#,b.schemaname,b.status,b.osuser,b.machine
from v$locked_object a,v$session b,sys.dba_objects c
where b.sid = a.session_id
and a.object_id = c.object_id
order by 2;
and object_name = 'M_USERS'
======= CPU UTIL Prasad ==========
set pages 400
set lines 300
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.osuser,1,23) USER_NM,
substr(ss.machine,1,23) MACHINE_NM,
substr(ss.program,1,17) program,
value
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%CPU used by this session%'
and se.sid = ss.sid
and ss.username is not null
and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >=10000
order by substr(name,1,25), value desc
/
======= Memory UTIL Prasad ==========
set pages 400
set lines 1000
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.osuser,1,23) USER_NM,
substr(ss.machine,1,23) MACHINE_NM,
substr(ss.program,1,17) program, name,
value
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and upper(name) like '%MEMORY%'
and se.sid = ss.sid
and ss.username is not null
and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >=10000
order by substr(name,1,25), value desc
/
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.osuser,1,23) USER_NM,
substr(ss.machine,1,23) MACHINE_NM,
substr(ss.program,1,17) program,
value,sn.name
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and (name like '%session connect time%' or name like '%CPU used by this session%')
and se.sid = ss.sid
and ss.username is not null
and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >= 10000
order by value
;
Jyotsna Lotilikar - 9833495581
select inst_id,sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi')
from gv$session where sid in (select session_id from gv$locked_object where object_id=229790) order by logon_time;
select inst_id,sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi'),schemaname
from gv$session where program not like '%w3wp%' and program not like '%ORACLE%' order by logon_time;
select sql_hash_value,event,action from v$session where sid=599;
select SQL_TEXT from v$sqltext where HASH_VALUE='3114014027' order by PIECE;
select SQL_TEXT from v$sqltext where HASH_VALUE='2440604873' order by PIECE;
select * from gv$locked_object order by 5;
select status,object_name,object_type,owner from dba_objects where object_name like '%CP_MAIL_PKG%';
select schemaname,inst_id,sid,serial#,program,event , to_char(logon_time,'dd-mm-yyyy hh24:mi') from gv$session where program like 'sqlplus.exe';
select status,object_name,object_type,owner from dba_objects where object_name like '%MV_PCRSTSH_PLAN_STORE_LIST%';
Truncat table Issue
ams_pkg_salesbinder.ams_sp_cal_salesbinder;
----CHECK Session working on--------
select inst_id,sid,serial#,sql_hash_value,event from gv$session where username = 'ALT';
----CHECK Session Hanged OR Working fine.-----
select * from v$sess_io where sid in (select sid from v$session where username = 'ETL');
------
ramesh.lakshmana@wipro.com - 9741494008
SQL> show parameter resou
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
resource_limit boolean FALSE
resource_manager_cpu_allocation integer 16
resource_manager_plan string SCHEDULER[0x3008]:DEFAULT_MAIN
TENANCE_PLAN
SQL>
select username,sid,serial#,program,event,action,to_char(logon_time,'DD-MM-YYYY hh24:mi:ss') from v$session where sid= &sid;
select inst_id,username,sid,serial#,program,event,action,to_char(logon_time,'DD-MM-YYYY hh24:mi:ss'),sql_hash_value from gv$session where sid = 1;
select * from DBA_DML_LOCKS order by 3;
select * from DBA_DDL_LOCKS where session_id = 1 order by 2;
-- Analyze Tables
BEGIN
DBMS_STATS.gather_table_stats('RSPROD_ARCH','REQUEST',
ESTIMATE_PERCENT => 0.1,
METHOD_OPT => 'FOR COLUMNS CLOSEDDATE SIZE 254');
END;
/
BEGIN
dbms_stats.Gather_table_stats('SH', 'SALES', -
method_opt => 'FOR ALL COLUMNS SIZE 1 FOR COLUMNS SIZE 254 CUST_ID');
END;
/
PL/SQL procedure successfully completed.
SELECT column_name, num_distinct, histogram
FROM user_tab_col_statistics
WHERE table_name = 'SALES';
There are several other cases where you may need to provide a more complex setting for the METHOD_OPT parameter. Take for example a scenario where you don’t want any form of statistics on a column. There is no way to tell Oracle don’t gather statistics on a particular column, so you need to do the reverse and explicitly list the column you want to have statistics gathered on using the FOR COLUMNS syntax. Let’s assume we don’t want statistics of any kind on the PROD_ID column of the SALES TABLE. Then the DBMS_STATS.GATHER_TABLE_STATS command would be as follows;
BEGIN
dbms_stats.delete_column_stats('SH', 'SALES', 'PROD_ID');
END;
/
PL/SQL procedure completed successfully.
BEGIN
dbms_stats.Gather_table_stats('SH', 'SALES',-
method_opt => 'FOR COLUMNS SIZE 254 CUST_ID TIME_ID CHANNEL_ID PROMO_ID
QUANTITY_SOLD AMOUNT_SOLD');
END;
/
PL/SQL procedure completed successfully.
-- The average row length still got recorded accurately even though we did not gather statistics on the PROD_ID column.
SELECT num_rows, avg_row_len
FROM user_tables
WHERE table_name = 'SALES';
SELECT column_name, num_distinct, histogram
FROM user_tab_col_statistics
WHERE table_name = 'SALES';
Note the FOR COLUMNS syntax is only valid for the GATHER_TABLE_STATS procedure.
Finally, at the start of this post I mentioned that the METHOD_OPT parameter can also be used to create extended statistics. Extended statistics encompasses two additional types of column statistics; column groups and expression statistics. In the example below, a column group will be automatically created on the PROD_ID and CUST_ID column in the SALES table. It will be given a system-generated name and will have all of the base column statistics gathered on it.
BEGIN
dbms_stats.Gather_table_stats('SH', 'SALES',
method_opt => 'FOR ALL COLUMNS SIZE 254 FOR COLUMNS SIZE 254(PROD_ID, CUST_ID)');
END;
/
PL/SQL procedure successfully completed.
SELECT column_name, num_distinct, histogram
FROM user_tab_col_statistics
WHERE table_name = 'SALES';
Rather than specifying the METHOD_OPT parameter in the statistics gathering command it is highly recommended that you specify any non-default value for the METHOD_OPT via DBMS_STATS.SET_TABLE_PREFS.
BEGIN
dbms_stats.Set_table_prefs('SH', 'SALES', 'METHOD_OPT', -
'FOR ALL COLUMNS SIZE 254 FOR COLUMNS SIZE 1 PROD_ID');
END;
/
scsprod
10.1.6.53
scs
EXEC DBMS_STATS.gather_schema_stats (ownname => 'SCS', cascade =>true,estimate_percent => 40);
EXEC DBMS_STATS.gather_schema_stats (ownname => 'PDMLINK80', cascade =>true,estimate_percent => 40);
create index ams.AMS_LA_COMMISSION_DETAILS_COL_2 on (agent_id,as_on_date);
@analyzedynamic:
---------------
SELECT 'EXEC DBMS_STATS.gather_table_stats(''' || owner || ''',''' || table_name || ''',cascade => true);' from dba_tables where to_char(LAST_ANALYZED,'DD-MON-YY') not like '%JUN-12' and owner='IDEAS';
select owner,table_name,last_analyzed from dba_tables where table_name = 'AMS_CONVERTED_RECEIPT_PREMIUM';
--EXEC DBMS_STATS.gather_table_stats('POS_PROD', 'POS_TRN_PLS_RES2');
--EXEC DBMS_STATS.gather_table_stats('POS_PROD', 'POS_TRN_CLS_RES2');
EXEC DBMS_STATS.gather_table_stats('LEAP', 'DW_WT_POS_FE_1');
EXEC DBMS_STATS.gather_table_stats('FCCPROD', 'STTB_UPLOAD_EXCEPTION');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_LA_COMMISSION_DETAILS');
EXEC DBMS_STATS.gather_table_stats('IDEAS', 'IDEAS_QC_FIELD_ERROR');
EXEC DBMS_STATS.gather_table_stats('PRL_PROD', 'PRL_CASE_AUDIT_TRAIL');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_PREMIUM_DEFECIT_HISTORY');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_PREMIUM_DEFECIT');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_CONVERTED_RECEIPT_PREMIUM');
EXEC DBMS_STATS.gather_table_stats('PRL_PROD', 'RESOURCE_MASTER_MIRROR');
EXEC DBMS_STATS.gather_table_stats('IDEAS', 'DW_WT_IDEAS_6');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_CONVERTED_RECEIPT_PREMIUM',estimate_percent => 15,cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_AGENT_HIERARCHY_TEMP',estimate_percent => 15,cascade => true);
EXEC DBMS_STATS.gather_table_stats('CP', 'CP_CLIENT_MASTER',cascade => true);
EXEC DBMS_STATS.gather_table_stats('CP', 'CP_USAGE_MASTER');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_RN_HRPRECS');
EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMPLOYEES');
EXEC DBMS_STATS.gather_table_stats('AMS', 'ROOTWISE_AGENT_DETAILS',estimate_percent => 15,cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_CLIENT_MASTER', estimate_percent => 15,cascade => true);
EXEC DBMS_STATS.gather_table_stats('IWAN_STG', 'ADDRESS_ROW_FORM', estimate_percent => dbms_stats.auto_sample_size,cascade => true);
EXEC DBMS_STATS.gather_table_stats('IWAN_STG', 'REPDB_CI', estimate_percent => dbms_stats.auto_sample_size,cascade => true);
--EXEC DBMS_STATS.gather_schema_stats (ownname => 'MFUNDMCY', cascade =>true,estimate_percent => dbms_stats.auto_sample_size);
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_CONVERTED_RECEIPT_PREMIUM',cascade => true);
EXEC DBMS_STATS.gather_table_stats('MFUNDMCY', 'WEB_T_PORTFOLIO',cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_PD_TOTALSCORECARD_RPT',cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'REPDB_CI',cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'ADDRESS_ROW_FORM',cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMH', 'AMS_SALES_AGGREGATION_MAIN',cascade => true);
EXEC DBMS_STATS.gather_table_stats('PRL_WF_PROD', 'INSTANCE_STATE',cascade => true);
EXEC DBMS_STATS.gather_table_stats('ETL', 'ETL_GTT_WAIT_STATS');
EXEC DBMS_STATS.gather_table_stats('ETL', 'ETL_RUN_STATS');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_AGENT_HIERARCHY');
EXEC DBMS_STATS.gather_table_stats('HSLRNRPROD', 'COL_MST_OTHERADDRESS');
EXEC DBMS_STATS.gather_table_stats('HSLRNRPROD', 'COL_MST_PHONENUMBERS');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_PRPSL_DETAILS',cascade => true);
EXEC DBMS_STATS.gather_table_stats('BHADRESHD', 'TFORECASTN',cascade => true);
EXEC DBMS_STATS.unlock_table_stats('FLEXPROD_HOST', 'XF_ST_CAP_INPUT_TXN');
EXEC DBMS_STATS.gather_table_stats('FLEXPROD_HOST', 'XF_ST_CAP_INPUT_TXN', estimate_percent => 15,cascade => true);
ams_policy_details_exclude
EXEC DBMS_STATS.gather_table_stats('MFUNDMCY', 'WEB_T_PORTFOLIO',cascade => true);
EXEC DBMS_STATS.gather_schema_stats (ownname => 'MFUNDMCY', cascade =>true,estimate_percent => dbms_stats.auto_sample_size);
select table_name
from dba_tables
where table_name like '%STAT%'
and table_name not like 'WRH%'
and table_name not like 'WRI%'
and owner='SYS';
Object Level
exec dbms_stats.create_stat_table('SYS','&stattablename');
exec dbms_stats.export_database_stats('&stattable','&statid','SYS');
exec dbms_stats.export_schema_stats('&owner','&stattablename','&statid','SYS');
======================= EVENT Check===========================
select event, total_waits,
round(time_waited/100) "TIME(s)",
average_wait*10 "AVG(ms)",
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') time
from v$system_event
where time_waited > 100 and (event like '%KSV%' or event like '%async%')
order by time_waited
============== Log Switch Time =================================
@dailyarch
set lines 120;
set pages 999;
select substr(time,1,5) day,
to_char(sum(decode(substr(time,10,2),'00',1,0)),'99') "00",
to_char(sum(decode(substr(time,10,2),'01',1,0)),'99') "01",
to_char(sum(decode(substr(time,10,2),'02',1,0)),'99') "02",
to_char(sum(decode(substr(time,10,2),'03',1,0)),'99') "03",
to_char(sum(decode(substr(time,10,2),'04',1,0)),'99') "04",
to_char(sum(decode(substr(time,10,2),'05',1,0)),'99') "05",
to_char(sum(decode(substr(time,10,2),'06',1,0)),'99') "06",
to_char(sum(decode(substr(time,10,2),'07',1,0)),'99') "07",
to_char(sum(decode(substr(time,10,2),'08',1,0)),'99') "08",
to_char(sum(decode(substr(time,10,2),'09',1,0)),'99') "09",
to_char(sum(decode(substr(time,10,2),'10',1,0)),'99') "10",
to_char(sum(decode(substr(time,10,2),'11',1,0)),'99') "11",
to_char(sum(decode(substr(time,10,2),'12',1,0)),'99') "12",
to_char(sum(decode(substr(time,10,2),'13',1,0)),'99') "13",
to_char(sum(decode(substr(time,10,2),'14',1,0)),'99') "14",
to_char(sum(decode(substr(time,10,2),'15',1,0)),'99') "15",
to_char(sum(decode(substr(time,10,2),'16',1,0)),'99') "16",
to_char(sum(decode(substr(time,10,2),'17',1,0)),'99') "17",
to_char(sum(decode(substr(time,10,2),'18',1,0)),'99') "18",
to_char(sum(decode(substr(time,10,2),'19',1,0)),'99') "19",
to_char(sum(decode(substr(time,10,2),'20',1,0)),'99') "20",
to_char(sum(decode(substr(time,10,2),'21',1,0)),'99') "21",
to_char(sum(decode(substr(time,10,2),'22',1,0)),'99') "22",
to_char(sum(decode(substr(time,10,2),'23',1,0)),'99') "23"
from
v$log_history
group by substr(time,1,5);
This log switch script is handy because it displays the log switch activity as a two-dimensional table, showing log switches by hours of the day and log switches by date:
--------------------------------------------
select nvl(ss.USERNAME,'ORACLE Back PROC') username,name,
se.SID,
VALUE cpu_usage
from v$session ss,
v$sesstat se,
v$statname sn
where se.STATISTIC# = sn.STATISTIC#
and (NAME like '%CPU used by this session%'
or NAME like 'session pga memory')
and se.SID = ss.SID and value <> 0
and ss.sid = &SID
order by sid desc;
SELECT
e.SID,
e.username,
e.status,
a.UGA_MEMORY,
b.PGA_MEMORY
FROM
(select y.SID, TO_CHAR(ROUND(y.value/1024),99999999) || ' KB' UGA_MEMORY from v$sesstat y, v$statname z where y.STATISTIC# = z.STATISTIC# and NAME = 'session uga memory') a,
(select y.SID, TO_CHAR(ROUND(y.value/1024),99999999) || ' KB' PGA_MEMORY from v$sesstat y, v$statname z where y.STATISTIC# = z.STATISTIC# and NAME = 'session pga memory') b,
v$session e
WHERE
e.sid=a.sid
AND
e.sid=b.sid
--and a.sid in (453,560,297,321)
and a.sid in (386,364)
ORDER BY
e.status,
a.UGA_MEMORY desc;
====== QUERY Taken Time =============
column username format a10
select sesion.sid,sesion.serial#,
sesion.username,
optimizer_mode,
hash_value,
address,
round(cpu_time/1000000/60,0) CPU_MIN,
round(elapsed_time/1000000/60,0) QURY_RUN_MIN,
sql_text
from v$sqlarea sqlarea, v$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null and sesion.sid = &SID;
-- Logon Time , STatus
select s.username "Oracle User",s.osuser "OS User",i.consistent_gets "Consistent Gets",
i.physical_reads "Physical Reads",s.status "Status",s.sid "SID",s.serial# "Serial#",
s.machine "Machine",s.program "Program",to_char(logon_time, 'DD/MM/YYYY HH24:MI:SS') "Logon Time",
w.seconds_in_wait "Idle Time", P.SPID "PROC",
name "Stat CPU", value
from v$session s, v$sess_io i, v$session_wait w, V$PROCESS P, v$statname n, v$sesstat t
where s.sid = i.sid
and s.sid = w.sid (+)
and 'SQL*Net message from client' = w.event(+)
and s.osuser is not null
and s.username is not null
and s.paddr=p.addr
and n.statistic# = t.statistic#
and n.name like '%cpu%'
and t.SID = s.sid
order by 6 asc, 3 desc, 4 desc;
=======================================================================================
=======================================================================================
=======================================================================================
=======================================================================================
=======================================================================================
-- Database HIT Ratio
select 100 * (1-(pr.value/(bg.value + cg.value))) || '%' as "Hit Ratio",
pr.value "Phys R",
bg.value "Bl. Gets",
cg.value "Cons Gets"
from
v$sysstat pr,
v$sysstat bg,
v$sysstat cg
where
pr.name='physical reads' and
bg.name='db block gets' and
cg.name ='consistent gets';
-- LOCKS
column osuser format a10
column owner format a10
column object_name format a15
column machine format a15
select c.owner,c.object_name,c.object_type,b.sid,b.serial#,b.status,b.osuser,b.machine
from v$locked_object a,v$session b,dba_objects c
where b.sid = a.session_id
and a.object_id = c.object_id
order by 2;
Here Log File means oracle Online Redo Log Files (this files records all the changes (transactions) done (like Inserts / Updates / Deletes) through any sessions inside the Oracle database). We observed that Oracle sessions where not able to read / Write in the Online redo log file, due to which the sessions got hanged / wait state, on this (Log File Sync) WAIT EVENT .
-- CPU Utilization
select * from
(SELECT se.username, ss.sid, value CPU_Usage
FROM v$session se, v$sesstat ss, v$statname st
WHERE ss.statistic# = st.statistic#
AND name LIKE '%roll%'
AND se.sid = ss.SID and value > 10000
AND se.username IS NOT NULL
ORDER BY value DESC) a;
-- INACTIVE Sessions Query Taking Time;
select * from
(SELECT se.username, ss.sid, value CPU_Usage
FROM v$session se, v$sesstat ss, v$statname st
WHERE ss.statistic# = st.statistic#
AND name LIKE '%CPU used by this session%'
AND se.sid = ss.SID and value <> 0
AND se.username IS NOT NULL and se.sid in (select sid from v$session where status = 'INACTIVE')
ORDER BY value DESC) a where rownum <= 15;
--QUERY Taking time & Inf. by SID
column username format a10
select sesion.sid,sesion.serial#,
sesion.username,
optimizer_mode,
hash_value,
address,
round(cpu_time/1000000/60,0) CPU_MIN,
round(elapsed_time/1000000/60,0) QURY_RUN_MIN,
sql_text
from v$sqlarea sqlarea, v$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null
and sesion.sid = &SID;
select SQL_TEXT from v$sqltext where HASH_VALUE='&HASH_VALUE' order by PIECE;
-- ACTIVE - INACTIVE --
select
s.username,
s.sid,
s.serial#,
p.pid ppid,
s.status,
s.osuser,
substr(s.program,1,20) client_program,
s.process client_process,
substr(p.program,1,20) server_program,
p.spid server_pid
from v$session s, v$process p
where s.username is not null
and p.addr(+) = s.paddr and s.sid = &sid
order by username, sid;
/
--ALL QUERY Taking TIME ---------
column username format a10
select sesion.sid,sesion.serial#,
sesion.username,
optimizer_mode,
hash_value,
address,
round(cpu_time/1000000/60,0) CPU_MIN,
round(elapsed_time/1000000/60,0) QURY_RUN_MIN,
sql_text
from v$sqlarea sqlarea, v$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null
order by elapsed_time desc;
================
@killinactive:
select 'alter system kill session ''' ||sid|| ',' || serial#|| ''' immediate;' from v$session where status='INACTIVE' and username='<>';
--- User Creation
18:42:46 SQL> create user USR28 identified by usr28 default tablespace AMS_BIG_MASTER_DATA;
User created.
18:43:54 SQL> grant create session to USR28;
Grant succeeded.
18:44:19 SQL> grant create any table, select any table, create any trigger to usr28;
set pages 200
set lines 200
column machine format a20
column event format a35
column program format a20
column action format a20
select sid,serial#,machine,program,event,action,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname
from v$session;
create table logon_tbl (who varchar2(30), when date);
create or replace trigger trg_logon_db
after insert on usr28.sess for each row
begin
insert into usr28.logon_tbl (who, when) values (user, sysdate);
end trg_logon_db;
/
Manoj - 9221081723
create or replace trigger trg_logon_db
after logon on database
begin
insert into usr28.logon_tbl (who, when) values (user, sysdate);
end trg_logon_db;
/
select TRIGGER_NAME,TABLE_OWNER,TABLE_NAME,STATUS,action_type from user_triggers where trigger_name = 'TRG_LOGON_DB';
create table sess(
sid number,
serial number,
USERNAME varchar2(20),
schemaname varchar2(20),
STATUS varchar2(8),
machine varchar2(64),
terminal varchar2(16),
program varchar2(64),
action varchar2(32),
SQL_HASH_VALUE number,
logon_time date
);
==== Final Trigger ===========
drop trigger usr28.USR28_LOGON_S10;
drop trigger usr28.trg_logon_db;
drop trigger sys.USR28_LOGON_S10;
drop trigger sys.trg_logon_db;
create or replace trigger USR28_LOGON_S10
before insert on usr28.logon_tbl for each row
begin
insert into usr28.sess (sid,serial,username,schemaname,status,machine,terminal,program,action,sql_hash_value,logon_time)
(select sid,serial#,username,schemaname,status,machine,terminal,program,action,sql_hash_value,logon_time from v$session
where logon_time = (select max(logon_time) from v$session) and (schemaname = 'USR28' or username = 'USR28'));
end;
/
create or replace trigger trg_logon_db
after logon on database
begin
insert into usr28.logon_tbl (who, when) values (user, sysdate);
end trg_logon_db;
/
====================================================================
-- With SID
column username format a10
select sesion.sid,sesion.serial#,
sesion.username,
optimizer_mode,
hash_value,
address,
round(cpu_time/1000000/60,0) CPU_MIN,
round(elapsed_time/1000000/60,0) QURY_RUN_MIN,
sql_text
from v$sqlarea sqlarea, v$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null and sesion.sid = &SID
order by elapsed_time desc;
-- Logon TIME, Status, by SID
column "Oracle User" format a10
column Program format a20
column "Stat CPU" format a20
column "OS User" format a10
select s.username "Oracle User",s.osuser "OS User",i.consistent_gets "Consistent Gets",
i.physical_reads "Physical Reads",s.status "Status",s.sid "SID",s.serial# "Serial#",
s.machine "Machine",s.program "Program",to_char(logon_time, 'DD/MM/YYYY HH24:MI:SS') "Logon Time",
w.seconds_in_wait "Idle Time", P.SPID "PROC",
name "Stat CPU", value
from v$session s, v$sess_io i, v$session_wait w, V$PROCESS P, v$statname n, v$sesstat t
where s.sid = i.sid
and s.sid = w.sid (+)
and 'SQL*Net message from client' = w.event(+)
and s.osuser is not null
and s.username is not null
and s.paddr=p.addr
and n.statistic# = t.statistic#
and n.name like '%cpu%'
and t.SID = s.sid
and s.sid = &SID
order by 6 asc, 3 desc, 4 desc;
-- CPU in Seconds.
select * from
(select
ss.username,
se.SID,
VALUE/100 cpu_usage_seconds
from
v$session ss,
v$sesstat se,
v$statname sn
where
se.STATISTIC# = sn.STATISTIC#
and
NAME like '%CPU used by this session%'
and
se.SID = ss.SID
and
ss.status='INACTIVE' and ss.username <> 'CP'
and
ss.username is not null
order by VALUE desc) where rownum <= 15;
select sid,serial#,program,status from v$session where status = 'INACTIVE';
-- Checking Tablespace Size
SET LINES 150
SET pages 300
col "Tablespace" FOR a30
col "Total MB" FOR a15
col "Used MB" FOR a15
col "% Used" FOR a15
SELECT
tablespace_name "Tablespace",
d.STATUS "Status",
TO_CHAR((a.bytes / 1048576),'99,999,990.900') "Total MB",
TO_CHAR(((a.bytes - DECODE(f.bytes, NULL, 0, f.bytes)) / 1048576),'99,999,990.900') "Used MB",
TO_CHAR((((a.bytes - DECODE(f.bytes, NULL, 0, f.bytes)) / 1048576)*100) / (a.bytes / 1048576),'999,999.9') "% Used"
FROM
(sys.dba_tablespaces d JOIN sys.sm$ts_avail a USING (tablespace_name))
LEFT OUTER JOIN sys.sm$ts_free f USING (tablespace_name)
ORDER BY 5;
Prompt ================Uptime==================
select to_char(STARTUP_TIME,'dd/mm/yyyy hh24:mm') from v$instance;
prompt ======================TEMP TABLESPACE=================================================
SELECT tablespace_name, SUM(bytes_used/1024/1024), SUM(bytes_free/1024/1024)
FROM V$temp_space_header
GROUP BY tablespace_name;
=======================================================================================
=======================================================================================
=======================================================================================
=======================================================================================
=======================================================================================
Good Links
===========
http://www.oraclefaq.net/2007/06/21/how-to-delete-a-node-from-3-node-rac-in-10gr2/
http://www.idevelopment.info/data/Oracle/DBA_tips/Oracle10gRAC/CLUSTER_22.shtml#Remove%20the%20Node%20from%20the%20Cluster
RMAN
======
SQL> create tablespace rman datafile size 1G autoextend on;
Tablespace created.
SQL> CREATE USER rman IDENTIFIED BY rman
2 TEMPORARY TABLESPACE temp1
3 DEFAULT TABLESPACE rman
4 QUOTA UNLIMITED ON rman;
User created.
SQL> GRANT connect, resource, recovery_catalog_owner TO rman;
Grant succeeded.
SQL> select count(*) from dba_objects where owner = 'RMAN';
COUNT(*)
----------
252
SQL>
C:\>set oracle_sid=hlportal1
C:\>rman catalog=rman/rman
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 21:13:15 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN> create catalog tablespace "rman";
error creating db
ORACLE error from recovery catalog database: ORA-00959: tablespace 'rman' does not exist
ORACLE error from recovery catalog database: ORA-00942: table or view does not exist
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-06433: error installing recovery catalog
RMAN> create catalog tablespace rman;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "rman": expecting one of: "double-quoted-string, identifier, single-quoted-string"
RMAN-01007: at line 1 column 27 file: standard input
RMAN> create catalog;
recovery catalog created
RMAN> exit
Recovery Manager complete.
C:\>rman catalog=rman/rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 21:15:59 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: HLPORTAL (DBID=214138538)
connected to recovery catalog database
RMAN> reister database;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "advise, allocate, alter, backup, @, catalog, chang
RMAN-01008: the bad identifier was: reister
RMAN-01007: at line 1 column 1 file: standard input
RMAN> exit
Recovery Manager complete.
C:\>rman catalog=rman/rman target=/
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 21:16:52 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: HLPORTAL (DBID=214138538)
connected to recovery catalog database
RMAN> create catalog;
recovery catalog created
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>
change backuppiece '' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16982_1_20100425_IMLC1N5E_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16983_1_20100425_INLC1N5E_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16984_1_20100425_IOLC1N5E_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16985_1_20100425_IPLC1PEF_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16986_1_20100425_IQLC1PGQ_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16987_1_20100425_IRLC1PJG_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16988_1_20100425_ISLC1RQB_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16989_1_20100425_ITLC1RS3_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16990_1_20100425_IULC1RUP_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16991_1_20100425_IVLC1U4L_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16992_1_20100425_J0LC1U7V_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16993_1_20100425_J1LC1U9D_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16994_1_20100425_J2LC20G3_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16995_1_20100425_J3LC20G4_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16996_1_20100425_J4LC20I6_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16997_1_20100426_J5LC235S_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16998_1_20100426_J6LC235T_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16999_1_20100426_J7LC2397_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_17000_1_20100426_J8LC25P4_1_1.BAK' uncatalog;
catalog start with '';
catalog start with 'E:\Backup\';
restore database;
crosscheck backup;
list backupset;
CROSSCHECK backup of database;
crosscheck backupset;
delete expired backupset;
catalog start with 'E:\Backup\';
restore database;
crosscheck archivelog all;
restore controlfile from 'E:\Backup\C-2213995706-20100426-00';
RMAN> run {
2> set newname for datafile '+DATA/hdfcprod/datafile/system.322.656800181' to 'E:\hdfcprod\datafile\system.322.656800181';
3> recover datafile 1;
4> switch datafile 1;
5> }
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update' UNTIL TIME 'SYSDATE-7';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_upd'
DATABASE;
}
RMAN> BACKUP SPFILE TO DESTINATION '/u01/backups';
RMAN> BACKUP TAG 'weekly_full_db_bkup' DATABASE ;
BACKUP tag 'Mdealing_Full_25102011' INCREMENTAL LEVEL 0 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
RUN {
RECOVER COPY OF DATABASE WITH TAG 'Mdealing_Full_25102011';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'Mdealing_Full_incr_25102011'
DATABASE;
}
BACKUP tag 'Mdealing_Full_25102011' INCREMENTAL LEVEL 0 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
BACKUP tag 'Mdealing_INCR1_25102011' INCREMENTAL LEVEL 1 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
FINAL Differential INCREMENTAL BACKUP;
backup as copy current controlfile format 'E:\Requets_Backup\Control_25102011.ctl';
----------- BACKUP ------------------
BACKUP tag 'Mdealing_FULL_25102011' INCREMENTAL LEVEL 0 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
BACKUP tag 'Mdealing_INCR1_25102011' INCREMENTAL LEVEL 1 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
BACKUP tag 'Mdealing_INCR1_25102011' INCREMENTAL LEVEL 1 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
----------- RESOTRE -----------------
RMAN> restore database;
RMAN> recover copy of database with tag 'Mdealing_INCR2_25102011';
==== Tablespace Level RMAN
-- Backup --
RMAN> BACKUP INCREMENTAL LEVEL 1 TABLESPACE tools FORMAT 'c:\RMANBKUP\tools_L1';
-- Restore --
RMAN> run { allocate channel t1 type 'sbt_tape' parms
2> 'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
3> sql "alter tablespace TEST_TS offline immediate";
4> restore tablespace TEST_TS;
5> recover tablespace TEST_TS;
6> sql "alter tablespace TEST_TS online";
7> release channel t1;
8> }
Normal RMAN Backup ====
BACKUP tag 'HLOPS2_BKP' DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
===================================================================
set newname for datafile '+DATA/hdfcprod/datafile/system.322.656800181' to 'D:\oracle\product\10.2.0\Oradata\hdfcprod\datafile\system.322.656800181';
connect target sys/sys@ORCL;
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
report obSOlete;
CROSSCHECK BACKUP;
CROSSCHECK COPY;
DELETE EXPIRED BACKUP;
DELETE EXPIRED COPY;
delete obsolete;
release channel;
CHANGE BACKUPPIECE '/oradata2/oft7qq' UNCATALOG;
RESTORING Through RMAN ARCHIVE BACKUPPIECE
===========================================
RMAN run{
RMAN set archivelog destination to 'F:\PRLPROD\ARCHIVE';
RMAN }
RMAN list backup of archivelog all; ## check Sequence
RMAN restore archivelog from sequence 11111 until sequence 222222;
SQL> recover database using backup controlfile;
Provide ARCH FileName;
Then Provide REDO Log File;
IT will show MEDIA RECOVERY COMPLETE
SQL> alter database open resetlogs;
SQL> shut immediate;
SQL> alter database open;
restore archivelog from logseq=100 until logseq=110;
restore archivelog from time='15-JUN-05' until time='20-JUN-05';
recover database;
restore archivelog from time='15-JUN-05' until time='20-JUN-05';
=== BACKUP Database / Controlfile / Archive log Files in BACKUPPIECES
======================================================================
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'F:\RMAN_Backup\HDFCAML_Controlfile\%F';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'TO YOUR PATH/%F';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
=== RCV File Riyaz
run
{
allocate channel ch1 type disk maxpiecesize 4G;
allocate channel ch2 type disk maxpiecesize 4G;
allocate channel ch3 type disk maxpiecesize 4G;
allocate channel ch4 type disk maxpiecesize 4G;
BACKUP AS COMPRESSED BACKUPSET DATABASE format 'TO YOU PATH\daily_FULL_DB_%s_%p_%T_%U.bak' filesperset 10;
BACKUP ARCHIVELOG from time 'sysdate-1' format 'TO YOU PATH\daily_ARCH_%s_%p_%T_%U.bak' filesperset 10 ;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
connect target /
HDFCBANK
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/fc_precut_dump/RMAN_06062013/FULL_DB_%s_%p_%T_%U.bak';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/fc_precut_dump/RMAN_06062013/FULL_DB_%s_%p_%T_%U.bak';
run
{
backup as compressed backupset database plus archivelog skip inaccessible including current controlfile;
backup current controlfile;
backup current controlfile for standby;
}
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/odgdump/SCN_19072013/%F';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/odgdump/SCN_19072013/SCN_DB_%s_%p_%T_%U.bak';
BACKUP INCREMENTAL FROM SCN 47987632 DATABASE;
==Perfect
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/odgdump/SCN_19072013/%F';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/odgdump/SCN_19072013/SCN_DB_%s_%p_%T_%U.bak';
BACKUP INCREMENTAL FROM SCN 47987632 DATABASE;
run
{
backup as compressed backupset database plus archivelog skip inaccessible;
backup current controlfile;
}
SCN RMAN RESTORE
=====================
1....On Standby Database.
select name,open_mode,CURRENT_SCN from v$database;
2....On Primary Database.
a. BACKUP DEVICE TYPE SBT INCREMENTAL FROM SCN 750923 DATABASE;
b. BACKUP INCREMENTAL FROM SCN 750923 DATABASE;
c. BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750983 DATABASE
FORMAT '/tmp/incr_standby_%U';
3....On Primary Database.
Backup Controlfile
3....On Standby Database.
RESTORE at STANDBY Side
RMAN> CATALOG START WITH '/standbydisk1/incrback/';
4....On Standby Database.
START RECOVER
RMAN> RECOVER DATABASE NOREDO;
========
backup as copy current controlfile format 'F:\RMAN_Backup\HDFCAML_Controlfile\HDFCAML_CTL.cfl';
backup as copy current controlfile format 'E:\Requets_Backup\Control_25102011.ctl';
============================================================================================================
Incremental Differential Backup
BACKUP INCREMENTAL LEVEL 0 DATABASE format 'D:\wipro-dba\RMAN_Incremental\daily_FULL_DB_%s_%p_%T_%U.bak' filesperset 10;
BACKUP INCREMENTAL LEVEL 1 DATABASE format 'D:\SAM_NEW\daily_FULL_DB_1_%s_%p_%T_%U.bak' filesperset 10;
Incremental CUMULATIVE Backup
BACKUP INCREMENTAL LEVEL 0 CUMULATIVE DATABASE format 'D:\wipro-dba\RMAN_Incremental\daily_FULL_DB_%s_%p_%T_%U.bak' filesperset 10;
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE format 'D:\SAM_NEW\daily_FULL_DB_1_%s_%p_%T_%U.bak' filesperset 10;
To store the change tracking file in the database area, set DB_CREATE_FILE_DEST in the target database. Then issue the following SQL statement to enable change tracking:
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
============================================================================================================
================== Parag Mail
Hi,
As discussed with Swapnil, he is Telling both ETL & CC Applications are running Slow.
As Analyzed, found that there is constant LOCK on below Tables with Session & also it is utilizing , Find details below:
SID SERIAL# PROCEDURE Running SCHEMA USER
====== ========= ======================== ========= ==========
214 479 begin AMS.AMS_PKG_BL.AMS_INCENTI ETL ETL
556 4512 begin cp_sch_pkg.sp_ia_payment; SYS ETL
Lock Acquired in Table:
========================
214 Session on Node 1:
ETL_RUN_STATS
ETL_WAIT_STATS
ETL_GTT_WAIT_STATS
556 Session on Node 2:
CP_IA_PAYMENT_ALERT_DTL
Revert if anything needs to be done from my side.
==================================================================
== Rename UNNAMED File to Proper File name.
alter database create datafile 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00012' as '+DATA_IDEAS/pinnacle/datafile/ideas.318.719999863';
select 'set newname for datafile ,' || name || ', to ,DOG'|| name || ';' from v$datafile;
select 'set newname for datafile ''' || name || ''' to ''DOG'|| name || ''';' from v$datafile;
select 'alter database rename file ''' || name || ''' to ''DOG'|| name || ''';' from v$tempfile;
select 'alter database rename file ''' || member || ''' to ''DOG'|| member || ''';' from v$logfile;
select tablespace_name||',set newname for datafile ,' || file_name || ', to ,DOG'|| file_name || ',;,' ||bytes/1024/1024/1024 from dba_data_files order by 1;
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 200
select tablespace_name||','||file_name||','||bytes/1024/1024/1024 from dba_data_files order by 1;
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
col FN for a15
select substr(file_name,1,4) FN, sum(bytes/1024/1024/1024) from dba_data_files group by substr(file_name,1,4);
== If alter database create datafile 'OLD File' as 'NEW File'; Doesnot work
RMAN> run {
2> set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00012' to '+DATA_IDEAS/pinnacle/datafile/ideas.318.719999863';
3> restore datafile 12;
4> recover datafile 12;
5> }
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history
where sequence# in (select max(sequence#) from v$log_history group by thread#);
=========================================================================
Oracle 11g
alter system set optimizer_features_enable='10.2.0.4' scope=memory
alter session set optimizer_features_enable='10.2.0.4'
VAR R REFCURSOR;
EXEC ALT_PKG_LGWISE_REPORTS.ALT_SP_GET_MTD_SUMMARY_REP('HD01',0,:r);
print r;
Oracle 11g AWR Report Starting
Assign Parameters:
SQL> show parameter CONTROL_MANAGEMENT_PAC
NAME_COL_PLUS_SHOW_PARAM TYPE VALUE_COL_PLUS_SHOW_PARAM
---------------------------------------- ----------- ------------------------------
control_management_pack_access string DIAGNOSTIC+TUNING
SQL>
SQL> show parameter statistics_level
NAME_COL_PLUS_SHOW_PARAM TYPE VALUE_COL_PLUS_SHOW_PARAM
---------------------------------------- ----------- ------------------------------
statistics_level string TYPICAL
SQL>
select distinct STAT_NAME,VALUE from V$sess_TIME_MODEL order by 1;
select snap_interval, retention from dba_hist_wr_control;
select distinct STAT_NAME,VALUE from V$Sys_TIME_MODEL order by 1;
col stat_name for a35
select * from V$OSSTAT ;
select * from v$license;
SELECT a.job_name, a.enabled, c.window_name, c.schedule_name, c.start_date, c.repeat_interval
FROM dba_scheduler_jobs a, dba_scheduler_wingroup_members b, dba_scheduler_windows c
WHERE job_name='GATHER_STATS_JOB'
And a.schedule_name=b.window_group_name
And b.window_name=c.window_name;
Execute Procedures
like:
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
END;
/
BEGIN
DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 1440,
interval => 60);
END;
/
@$ORACLE_HOME/rdbms/admin/awrextr.sql
@?/rdbms/admin/awrload.sql
@$ORACLE_HOME/rdbms/admin/awrrpt.sql
BEGIN
DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE (low_snap_id => 102, high_snap_id => 122, dbid => 8187786345);
END;
/
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.
Workload Repository Views
The following workload repository views are available:
V$ACTIVE_SESSION_HISTORY - Displays the active session history (ASH) sampled every second.
V$METRIC - Displays metric information.
V$METRICNAME - Displays the metrics associated with each metric group.
V$METRIC_HISTORY - Displays historical metrics.
V$METRICGROUP - Displays all metrics groups.
DBA_HIST_ACTIVE_SESS_HISTORY - Displays the history contents of the active session history.
DBA_HIST_BASELINE - Displays baseline information.
DBA_HIST_DATABASE_INSTANCE - Displays database environment information.
DBA_HIST_SNAPSHOT - Displays snapshot information.
DBA_HIST_SQL_PLAN - Displays SQL execution plans.
DBA_HIST_WR_CONTROL - Displays AWR settings.
=========================================================================
Oracle 11g Mail Sending
SELECT host, acl,
DECODE(
DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE_ACLID(aclid, 'ETL', 'resolve'),
1, 'GRANTED', 0, 'DENIED', NULL) privilege
FROM dba_network_acls
;
Example1
Grant the connect and resolve privileges for host www.us.oracle.com to SCOTT.
BEGIN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'www.xml',
description => 'WWW ACL',
principal => 'SCOTT',
is_grant => true,
privilege => 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'www.xml',
principal => 'SCOTT',
is_grant => true,
privilege => 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'www.xml',
host => 'www.us.oracle.com');
END;
/
COMMIT;
Example 2
Grant the resolve privilege for www.us.oracle.com to ADAMS. Since an ACL for www.us.oracle.com exists already, just add the privilege for ADAMS.
BEGIN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'www.xml',
principal => 'ADAMS',
is_grant => true,
privilege => 'resolve');
END;
/
COMMIT;
Example 3
Assign the ACL www.xml to www-proxy.us.oracle.com so that SCOTT and ADAMS can access www-proxy.us.oracle.com also.
BEGIN
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'www.xml',
host => 'www-proxy.us.oracle.com');
END;
/
COMMIT;
Example 4
Unassign the ACL from www.us.oracle.com so that no access to www.us.oracle.com is allowed.
BEGIN
DBMS_NETWORK_ACL_ADMIN.UNASSIGN_ACL(host => 'www.us.oracle.com');
END;
/
COMMIT;
BEGIN
DBMS_NETWORK_ACL_ADMIN.DELETE_PRIVILEGE(
acl => 'us-oracle-com-permissions.xml',
principal => 'ST_USERS')
END;
BEGIN
DBMS_NETWORK_ACL_ADMIN.DROP_ACL(
acl => 'us-oracle-com-permissions.xml');
END;
==============================================
Advantage of ASM :
Flexible --> Without shutting down database , can add new Disk / Space in ASM.
Fault Tolerance --> ASM handles the mirroring of data, Once datas Inserted in the datafiles it never / hardly gets lost.
Productivity increases --> Space management is taken care of by ASM.
In Oracle 10g Multiple ASM instance is possible so that if 1 ASM Instance needs to be stopped, others are not affected.
If I drop a tablespace, ASM will figure out which datafile(s) are no longer required and will then automatically remove the physical files without any intervention on my part.
=======
ed lock
select sid, user#, username, command, lockwait, status from gv$session
WHERE LOCKWAIT is not null
======
@edplan
set pages 0
set lines 10000
set long 10000
select plan_table_output from table(dbms_xplan.display_cursor('&sqlid'));
======
ed plan2
select plan_table_output from table(dbms_xplan.display_awr('&sqlid'));
======
@cpuutiliztion
set pages 400
set lines 300
col user_process for a14
col user_nm for a11
col machine_nm for a5
col program for a22
col event for a30
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
--SS.SQL_ID,
substr(ss.program,1,17) program,
event,
value, ss.sql_hash_value,ss.sql_id,
substr(ss.osuser,1,23) USER_NM,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),
substr(ss.machine,1,23) MACHINE_NM
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%CPU used by this session%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('ACTIVE')
-- and ss.username not in ('SYS','SYSTEM')
and value >=10000
order by substr(name,1,25), value desc;
col COLUMN_NAME for a30
select table_name,column_name,index_name from dba_ind_columns where table_name='MST_MSG_STOR_TBL' order by 3;
alter system kill session '378,12759' immediate;
519,6797
514,30636
513,20883
set pages 400
set lines 300
col user_process for a20
col user_nm for a20
col machine_nm for a20
col program for a30
col event for a40
col sidd for a55
select substr (ss.username||'('||se.sid||')',1,15) user_process, to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'), ss.program,
'alter system kill session ''' || ss.sid || ',' || ss.serial# || ''' immediate;' SIDD
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%CPU used by this session%'
and se.sid = ss.sid
and ss.username is not null
-- and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >=10000
and ss.logon_time not like sysdate
order by ss.logon_time;
order by substr(name,1,25), value asc;
======
set serverout on size 999999
declare
begin
dbms_output.put_line(’ ‘);
dbms_output.put_line(’************* Start report for WAITING sessions with current SQL ***************’);
for x in (select vs.inst_id, vs.sid || ‘,’ || vs.serial# sidser, vs.sql_address, vs.sql_hash_value,
vs.last_call_et, vsw.seconds_in_wait, vsw.event, vsw.state
from gv$session_wait vsw, gv$session vs
where vsw.sid = vs.sid
and vsw.inst_id = vs.inst_id
and vs.type <> ‘BACKGROUND’
and vsw.event NOT IN (’rdbms ipc message’
,’smon timer’
,’pmon timer’
,’SQL*Net message from client’
,’lock manager wait for remote message’
,’ges remote message’
,’gcs remote message’
,’gcs for action’
,’client message’
,’pipe get’
,’Null event’
,’PX Idle Wait’
,’single-task message’
,’PX Deq: Execution Msg’
,’KXFQ: kxfqdeq - normal deqeue’
,’listen endpoint status’
,’slave wait’
,’wakeup time manager’))
loop
begin
dbms_output.put_line(’Event WaitState InstID SidSerial LastCallEt SecondsInWait’);
dbms_output.put_line(’************************* ******************** ****** *********** ********** *************’);
dbms_output.put_line(rpad(x.event,25) ||’ ‘|| rpad(x.state,20) ||’ ‘|| lpad(x.inst_id,6) ||’ ‘|| lpad(x.sidser,11) ||’
‘|| lpad(x.last_call_et,10) ||’ ‘|| lpad(x.seconds_in_wait,13));
dbms_output.put_line(’ SQLText ‘);
dbms_output.put_line(’****************************************************************’);
for y in (select sql_text
from gv$sqltext
where address = x.sql_address
and hash_value = x.sql_hash_value
and inst_id = x.inst_id
order by piece)
loop
dbms_output.put_line(y.sql_text);
end loop;
end;
end loop;
dbms_output.put_line(’************** End report for sessions waiting with current SQL ****************’);
dbms_output.put_line(’ ‘);
end;
/
======
ed UTLMEMORY
set pages 400
set lines 300
col user_process for a12
col program for a30
col event for a30
col USER_NM for a14
col LOGON_TIME for a20
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.program,1,17) program,event,
value,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LOGON_TIME,
substr(ss.osuser,1,23) USER_NM
,substr(ss.machine,1,23) MACHINE_NM,ss.terminal
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%session pga memory%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('ACTIVE')
-- and ss.username not in ('SYS','SYSTEM')
and value >= 10339
and ss.logon_time not like sysdate
order by value;
set pages 400
set lines 300
col user_process for a15
col program for a21
col event for a30
col USER_NM for a14
col LOGON_TIME for a20
col machine_nm for a14
select ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.program,1,17) program,event,
value,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LOGON_TIME,
substr(ss.osuser,1,23) USER_NM
,substr(ss.machine,1,23) MACHINE_NM
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%session pga memory%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >= 10339
and ss.logon_time not like sysdate
order by value;
==================
ed POOLUsages, SHARED_POOL, LARGE_POOL
SELECT pool,name,bytes/1024/1024 FROM V$SGASTAT where name like 'free memory';
==================
ed UTLPROCESS
set pages 400
set lines 300
col user_process for a20
col program for a30
col event for a40
col USER_NM for a10
col schemaname for a15
col LOGON_TIME for a20
select distinct ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.program,1,17) program,event,
value,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LOGON_TIME,
substr(ss.osuser,1,23) USER_NM, schemaname
-- substr(ss.machine,1,23) MACHINE_NM
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%process%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('INACTIVE')
and ss.username not in ('SYS','SYSTEM')
-- and value >= 10339
and ss.logon_time not like sysdate
order by value;
=======================
ed UTLpool
set pages 400
set lines 300
col user_process for a20
col program for a30
col event for a40
col USER_NM for a10
col schemaname for a15
col LOGON_TIME for a20
select distinct ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.program,1,17) program,event,
value,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LOGON_TIME,
substr(ss.osuser,1,23) USER_NM, schemaname
-- substr(ss.machine,1,23) MACHINE_NM
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%pool%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('INACTIVE')
and ss.username not in ('SYS','SYSTEM')
-- and value >= 10339
and ss.logon_time not like sysdate
order by value;
======
select program,to_char(logon_time,'dd-mon-yyyy'),count(*) from gv$session where schemaname not like 'SYS%' group by program,to_char(logon_time,'dd-mon-yyyy') order by to_char(logon_time,'dd-mon-yyyy');
col logon_time for a25
select program,to_char(logon_time,'dd-mon-yyyy'),count(*) from gv$session where schemaname not like 'SYS%' group by program,to_char(logon_time,'dd-mon-yyyy') order by to_char(logon_time,'dd-mon-yyyy');
=================
ed usingtemp
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mi:ss'),a.program,a.event,(sum(b.extents)* 1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser, c.spid Process,
a.status --,'alter system kill session ''' || a.sid || ',' || a.serial# || ''' immediate;' "sids"
FROM gv$session a,gv$sort_usage b, gv$process c, dba_tablespaces d
WHERE a.saddr = b.session_addr
AND a.paddr = c.addr
AND b.tablespace=d.tablespace_name
-- and schemaname not like '%SYS%'
and b.extents*1024*1024 > 1000
group by a.username, a.osuser, a.sid||','||a.serial#,c.spid,
b.tablespace, a.status,a.program,a.event, a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mi:ss'),a.program,a.event,(sum(b.extents)* 1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser, c.spid Process,
a.status
FROM gv$session a,gv$sort_usage b, gv$process c, dba_tablespaces d
WHERE a.saddr = b.session_addr
AND a.paddr = c.addr
AND b.tablespace=d.tablespace_name
and schemaname not like '%SYS%'
-- and b.extents*1024*1024 > 10000
group by a.username, a.osuser, a.sid||','||a.serial#,c.spid,
b.tablespace, a.status,a.program,a.event, a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
For 8i
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mi:ss'),a.program,(sum(b.extents)* 1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser, c.spid Process,
a.status, 'alter system kill session ''' || a.sid || ',' || a.serial# || ''' immediate;' "sids"
FROM gv$session a,gv$sort_usage b, gv$process c, dba_tablespaces d
WHERE a.saddr = b.session_addr
AND a.paddr = c.addr
AND b.tablespace=d.tablespace_name
and schemaname not like '%SYS%'
and b.extents*1024*1024 > 1000
group by a.username, a.osuser, a.sid||','||a.serial#,c.spid,
b.tablespace, a.status,a.program,a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mi:ss'),a.program,(sum(b.extents)* 1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser,
a.status, 'alter system kill session ''' || a.sid || ',' || a.serial# || ''' immediate;' "sids"
FROM gv$session a,gv$sort_usage b
WHERE a.saddr = b.session_addr
and schemaname not like '%SYS%'
and b.extents*1024*1024 > 1000
group by a.username, a.osuser, a.sid||','||a.serial#,
b.tablespace, a.status,a.program,a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
=======
ed usingundo
col osuser for a15
col user for a10
col undo_tbs for a12
col SEGMENT_NM for a15
col command for a30
set pages 9999
set lines 200
SELECT ds.TABLESPACE_NAME "UNDO_TBS",ds.RELATIVE_FNO "File Nos",r.name "SEGMENT_NM", s.sid, s.serial#,s.osuser, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,substr(s.program, 1, 78) "COMMAND", c.sql_text
FROM sys.v_$session s, sys.v_$transaction t, sys.v_$rollname r,dba_segments ds,v$sql c
WHERE t.addr = s.taddr
and t.xidusn = r.usn
and s.sql_hash_value = c.hash_value
and ds.segment_name = r.name(+)
--and s.program not like 'ORACLE.EXE%'
ORDER BY t.cr_get, t.phy_io;
========
ed sofar
set time on
set lines 300
set pages 9999
col program for a30
col event for a35
col inst_id for 99
col context for 99999
col Wait_Secs for a10
col LT for a20
SELECT l.inst_id,l.sid, l.serial#, l.context, l.sofar, l.totalwork, l.sofar/l.totalwork*100 "% Complete",
s.program,s.event, s.seconds_in_wait || ' ' Wait_Secs,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT
-- ,s.blocking_session, s.client_info
--, s.p1, s.p2, s.p3,, s.client_info, s.module,l.opname
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND upper(l.opname) LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
--AND s.sid = 1566
--AND s.program like 'ORACLE.EXE (J0%'
--AND s.program like 'oracle@usclvwuca002 (D%'
--AND s.program like '%JDBC%'
--AND upper(l.opname) like '%EXP%'
--and logon_time not like sysdate
AND l.totalwork != 0
--AND l.totalwork <> l.sofar
ORDER BY logon_time desc;
09819741718
===
set time on
set lines 300
set pages 9999
col program for a50
col event for a35
col inst_id for 99
col context for 99999
col Wait_Secs for a10
col LT for a20
col CST for a20
SELECT l.inst_id,l.sid, l.serial#, l.context, l.sofar, l.totalwork, l.sofar/l.totalwork*100 "% Complete",
s.program,s.event, s.seconds_in_wait || ' ' Wait_Secs,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,to_char(logon_time-1/24,'dd-mm-yyyy hh24:mi:ss') CST
--, s.p1, s.p2, s.p3,, s.client_info, s.module
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND l.opname LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
--AND s.sid = 1045
--AND s.program like 'ORACLE.EXE (J0%'
AND l.totalwork != 0
ORDER BY 7 desc,logon_time;
select sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),osuser from gv$session where osuser='oracle' and program like 'rman%' order by logon_time;
select schemaname,username,sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),osuser from gv$session where sid=&sid order by logon_time;
Check rman TAPE backup
COLUMN EVENT FORMAT a40
COLUMN SECONDS_IN_WAIT FORMAT 999
COLUMN STATE FORMAT a20
COLUMN CLIENT_INFO FORMAT a20
COLUMN state FORMAT a10
SELECT p.SPID, s.sid, s.serial#,s.program,s.event, sw.SECONDS_IN_WAIT AS SEC_WAIT, sw.STATE, s.CLIENT_INFO
FROM V$SESSION_WAIT sw, V$SESSION s, V$PROCESS p
WHERE sw.EVENT LIKE '%sbt%'
AND s.SID=sw.SID
AND s.PADDR=p.ADDR;
select decode(backup_type||controlfile_included||incremental_level,'LNO','ARC', 'DYES', 'CTL', 'DNO', 'DBF_FULL', 'DNO0','DBF_LVL_0','INO1','DBF_LVL_1'),
round(sum(original_input_bytes)/1024/1024,2) "MB in",round(sum(output_bytes)/1024/1024,2) "MB out",status,min(start_time),max(completion_time),
round((sum(output_bytes)/1024/1024)/((max(completion_time)-min(start_time))*86400), 1) "MB/s"
from v$backup_set_details
group by backup_type, controlfile_included, incremental_level, status, session_key, session_recid, session_stamp
order by 5;
--ORDER BY inst_id,sid,serial#;
SELECT l.sid, l.serial#, l.sofar, l.totalwork, l.sofar/l.totalwork*100 "% Complete",s.program,s.event,s.p1, s.p2, s.p3
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND l.opname LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
--AND s.sid = 1632
--AND s.program like 'ORACLE.EXE (J0%'
AND l.totalwork != 0
ORDER BY 7 desc,logon_time;
SELECT l.sid, l.serial#, l.sofar, l.totalwork, l.sofar/l.totalwork*100 "% Complete",s.program,s.event,s.p1, s.p2, s.p3
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND l.opname LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
AND s.sid = 1166
--AND s.program like 'ORACLE.EXE (J0%'
AND l.totalwork != 0
ORDER BY 7 desc,logon_time;
================
select * from dba_jobs_running;
select * from dba_scheduler_running_jobs;
set lines 300
set pages 9999
col program for a30
col event for a35
col inst_id for 99
col context for 99999
col Wait_Secs for a10
SELECT l.inst_id,l.sid, l.serial#, l.context, l.sofar, l.totalwork,
s.program,s.event, s.seconds_in_wait || ' ' Wait_Secs,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss')
--, s.p1, s.p2, s.p3,, s.client_info, s.module
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND l.opname LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
AND s.sid = 1613
--AND s.program like 'ORACLE.EXE (J0%'
--AND l.totalwork != 0
ORDER BY logon_time;
--ORDER BY inst_id,sid,serial#;
=============
ed checkarchivelogstatus
set lines 200
set pages 9999
col r.sequence# for 999,999,999
col handle for a80
select r.sequence# sequence, p.handle handle, to_char(l.first_time,'DD-MON-YYYY HH24:MI:SS')
from v$backup_piece p, v$backup_redolog r, v$log_history l
where r.set_stamp = p.set_stamp
and r.set_count = p.set_count
and l.sequence# = r.sequence#
and r.sequence# = (select max(r.sequence#) from v$backup_redolog r)
order by 1;
--and r.sequence# = 63
set lines 200
set pages 9999
col r.sequence# for 999,999,999
col handle for a80
select r.sequence# sequence, p.handle handle, to_char(l.first_time,'DD-MON-YYYY HH24:MI:SS')
from v$backup_piece p, v$backup_redolog r, v$log_history l
where r.set_stamp = p.set_stamp
and r.set_count = p.set_count
and l.sequence# = r.sequence#
and l.sequence# = 140581
order by 1;
===============
ed open_Cursor_Check
col hwm_open_cur format 99,999
col max_open_cur format 99,999
select
max(a.value) as hwm_open_cur,
p.value as max_open_cur
from
v$sesstat a,
v$statname b,
v$parameter p
where
a.statistic# = b.statistic#
and
b.name = 'opened cursors current'
and
p.name= 'open_cursors'
group by p.value;
===============
ed logswitch
set linesize 112
set pagesize 100
column day format a15 heading ' Day'
column d_0 format a3 heading ' 00'
column d_1 format a3 heading ' 01'
column d_2 format a3 heading ' 02'
column d_3 format a3 heading ' 03'
column d_4 format a3 heading ' 04'
column d_5 format a3 heading ' 05'
column d_6 format a3 heading ' 06'
column d_7 format a3 heading ' 07'
column d_8 format a3 heading ' 08'
column d_9 format a3 heading ' 09'
column d_10 format a3 heading ' 10'
column d_11 format a3 heading ' 11'
column d_12 format a3 heading ' 12'
column d_13 format a3 heading ' 13'
column d_14 format a3 heading ' 14'
column d_15 format a3 heading ' 15'
column d_16 format a3 heading ' 16'
column d_17 format a3 heading ' 17'
column d_18 format a3 heading ' 18'
column d_19 format a3 heading ' 19'
column d_20 format a3 heading ' 20'
column d_21 format a3 heading ' 21'
column d_22 format a3 heading ' 22'
column d_23 format a3 heading ' 23'
select
substr(to_char(FIRST_TIME,'YYYY/MM/DD, DY'),1,15) day,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'00',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'00',1,0))) d_0,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'01',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'01',1,0))) d_1,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'02',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'02',1,0))) d_2,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'03',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'03',1,0))) d_3,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'04',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'04',1,0))) d_4,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'05',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'05',1,0))) d_5,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'06',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'06',1,0))) d_6,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'07',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'07',1,0))) d_7,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'08',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'08',1,0))) d_8,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'09',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'09',1,0))) d_9,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'10',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'10',1,0))) d_10,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'11',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'11',1,0))) d_11,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'12',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'12',1,0))) d_12,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'13',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'13',1,0))) d_13,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'14',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'14',1,0))) d_14,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'15',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'15',1,0))) d_15,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'16',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'16',1,0))) d_16,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'17',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'17',1,0))) d_17,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'18',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'18',1,0))) d_18,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'19',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'19',1,0))) d_19,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'20',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'20',1,0))) d_20,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'21',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'21',1,0))) d_21,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'22',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'22',1,0))) d_22,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'23',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'23',1,0))) d_23
from
gv$log_history
where
FIRST_TIME >= sysdate - 15
group by
substr(to_char(FIRST_TIME,'YYYY/MM/DD, DY'),1,15)
order by
substr(to_char(FIRST_TIME,'YYYY/MM/DD, DY'),1,15) desc;
set linesize 150
set pagesize 9999
clear columns
OI@4c3ss.13
W3lc0m3.oi@13
=========
ed rmanbackup
set lines 999
set pages 200
column START_TIME format a30;
column END_TIME format a30;
column INPUT_BYTES for 999999999999
select *
from (select to_char(START_TIME,'DD-MON-YYYY:HH24:MI:SS') START_TIME,to_char(END_TIME,'DD-MON-YYYY:HH24:MI:SS') END_TIME,
ELAPSED_SECONDS/60 ELAPSED_MINS,INPUT_TYPE,OUTPUT_DEVICE_TYPE,STATUS,TRUNC(START_TIME) BKP_DATE, INPUT_BYTES/1024/1024 I_MB , OUTPUT_BYTES/1024/1024 O_MB
from V$RMAN_BACKUP_JOB_DETAILS order by BKP_DATE desc)
where rownum <25 --0 and INPUT_TYPE like '%INCR%'
order by BKP_DATE desc;
set lines 999
column START_TIME format a30;
column END_TIME format a30;
column INPUT_BYTES for 999999999999
select *
from (select to_char(START_TIME,'DD-MON-YYYY:HH24:MI:SS') START_TIME,to_char(END_TIME,'DD-MON-YYYY:HH24:MI:SS') END_TIME,
ELAPSED_SECONDS/60 ELAPSED_MINS,INPUT_TYPE,OUTPUT_DEVICE_TYPE,STATUS,TRUNC(START_TIME) BKP_DATE, INPUT_BYTES/1024/1024 I_MB , OUTPUT_BYTES/1024/1024 O_MB
from V$RMAN_BACKUP_JOB_DETAILS where start_time like sysdate order by BKP_DATE desc)
where rownum <25
order by 1 desc;
set lines 999
column START_TIME format a30;
column END_TIME format a30;
column INPUT_BYTES for 999999999999
select *
from (select to_char(START_TIME,'DD-MON-YYYY:HH24:MI:SS') START_TIME,to_char(END_TIME,'DD-MON-YYYY:HH24:MI:SS') END_TIME,
ELAPSED_SECONDS/60 ELAPSED_MINS,INPUT_TYPE,OUTPUT_DEVICE_TYPE,STATUS,TRUNC(START_TIME) BKP_DATE, INPUT_BYTES/1024/1024 I_MB , OUTPUT_BYTES/1024/1024 O_MB
from V$RMAN_BACKUP_JOB_DETAILS order by BKP_DATE desc)
where rownum <= 25
order by BKP_DATE;
Darpan - ITO DBA:
SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo01.log'' TO ''?/oradata/test/redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo02.log'' TO ''?/oradata/test/redo02.log'' ";
Darpan - ITO DBA: https://www.rooms.hp.com/attend/default.aspx?key=RPQ9YJJMDF
----- 1/16/14 12:17 AM -----
Darpan - ITO DBA: SQL> col media for a15
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YY HH24:MI';
Session altered.
select b.media, b.db_key,' ', b.tag, b.start_time,' ', b.completion_time
from bp b, rc_database r
where start_time > '11-JAN-14 23:30' and completion_time < '12-JAN-14 2:00'
and b.db_key=r.db_key
--and r.dbid=2724273581
order by 1;
=========
ed rmantape ----- PERFECT rr
set lines 200
set pages 9999
col PKEY for 9999999
col BACKUP_TYPE for a20
col STATUS for a10
col FNAME for a45
col TAG for a30
Col MEDIA for a15
col Complete for a20
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME,OBSOLETE, TAG, MEDIA,to_char(COMPLETION_TIME,'dd-mm-yyyy hh24:mi:ss') Complete FROM V$BACKUP_FILES
WHERE COMPLETION_TIME between sysdate - 60 and sysdate
AND BACKUP_TYPE <> 'COPY'
--and FNAME like '%lvl%'
order by completion_time;
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME,OBSOLETE, TAG, MEDIA,to_char(COMPLETION_TIME,'dd-mm-yyyy hh24:mi:ss') Complete FROM V$BACKUP_FILES
WHERE COMPLETION_TIME between sysdate - 30 and sysdate
AND BACKUP_TYPE <> 'COPY'
--and FNAME like '%lvl%'
order by completion_time;
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME,OBSOLETE, TAG, MEDIA,to_char(COMPLETION_TIME,'dd-mm-yyyy hh24:mi:ss') Complete FROM V$BACKUP_FILES
WHERE COMPLETION_TIME like (sysdate - 4)
order by completion_time;
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME, TAG, MEDIA,to_char(COMPLETION_TIME,'dd-mm-yyyy hh24:mi:ss') Complete FROM V$BACKUP_FILES
WHERE TO_CHAR(COMPLETION_TIME,'YYYY-MM-DD') = '2014-01-12'
and FNAME like '%arch%'
order by completion_time;
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME, TAG, MEDIA FROM V$BACKUP_FILES
WHERE TO_CHAR(COMPLETION_TIME,'YYYY-MM-DD') = '2014-01-12'
and FNAME like '%arch%'
order by media;
143260 BACKUP SET AVAILABLE P44_ustlsoi010_arch_<P44_al_ncat_t836692211_s190946_p1>.bak TAG20140112T223011 70553
===695147
=========
ed lockholder
set lines 1000
SELECT /*+ rule */
DECODE(request,
0,
'Holder: ',
'Waiter: ')||sid sess,
type,
INST_ID,
id1,
id2,
lmode,
request,
ctime,
block
FROM
gv$lock
WHERE
(id1, id2, type) IN
(SELECT id1, id2, type FROM gv$lock WHERE request >0)
and lmode=6
ORDER BY id1, request
/
=======
ed rmanstatus
set line 300
SELECT SID, SERIAL#, CONTEXT,opname, SOFAR, TOTALWORK,
ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE"
FROM V$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%'
AND OPNAME NOT LIKE '%rman%'
AND TOTALWORK != 0
AND SOFAR <> TOTALWORK;
========
ed order
set serveroutput on size 50000
set echo off feed off veri off
accept SID prompt 'Enter Oracle SID: '
DECLARE
v_sid number;
s sys.v_$session%ROWTYPE;
p sys.v_$process%ROWTYPE;
BEGIN
begin
select sid into v_sid
from sys.v_$session s
where sid = &&SID;
exception
when no_data_found then
dbms_output.put_line('Unable to find SID &&SID!!!');
return;
when others then
dbms_output.put_line(sqlerrm||'naaaaaaaaaaaaaaaaaaaaa');
return;
end;
select * into s from sys.v_$session where sid = v_sid;
select * into p from sys.v_$process where addr = s.paddr;
dbms_output.put_line('=====================================================================');
dbms_output.put_line('SID/Serial : '|| s.sid||','||s.serial#);
dbms_output.put_line('Foreground : '|| 'PID: '||s.process||' - '||s.program);
dbms_output.put_line('Shadow : '|| 'PID: '||p.spid||' - '||p.program);
dbms_output.put_line('Terminal : '|| s.terminal || '/ ' || p.terminal);
dbms_output.put_line('OS User : '|| s.osuser||' on '||s.machine);
dbms_output.put_line('Ora User : '|| s.username);
dbms_output.put_line('Status Flags: '|| s.status||' '||s.server||' '||s.type);
dbms_output.put_line('Tran Active : '|| nvl(s.taddr, 'NONE'));
dbms_output.put_line('Login Time : '|| to_char(s.logon_time, 'Dy HH24:MI:SS'));
dbms_output.put_line('Last Call : '|| to_char(sysdate-(s.last_call_et/60/60/24), 'Dy HH24:MI:SS') || ' - ' || to_char(s.last_call_et/60, '9999999999.0') || ' min');
dbms_output.put_line('Lock/ Latch : '|| nvl(s.lockwait, 'NONE')||'/ '||nvl(p.latchwait, 'NONE'));
dbms_output.put_line('Latch Spin : '|| nvl(p.latchspin, 'NONE'));
dbms_output.put_line('Current SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.sql_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Previous SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.prev_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Session Waits:');
for c1 in ( select * from sys.v_$session_wait where sid = s.sid) loop
dbms_output.put_line(chr(9)||c1.state||': '||c1.event);
end loop;
dbms_output.put_line('Connect Info:');
for c1 in ( select * from sys.v_$session_connect_info where sid = s.sid) loop
dbms_output.put_line(chr(9)||': '||c1.network_service_banner);
end loop;
dbms_output.put_line('Locks:');
for c1 in ( select
decode(l.type,
-- Long locks
'TM', 'DML/DATA ENQ', 'TX', 'TRANSAC ENQ',
'UL', 'PLS USR LOCK',
-- Short locks
'BL', 'BUF HASH TBL', 'CF', 'CONTROL FILE',
'CI', 'CROSS INST F', 'DF', 'DATA FILE ',
'CU', 'CURSOR BIND ',
'DL', 'DIRECT LOAD ', 'DM', 'MOUNT/STRTUP',
'DR', 'RECO LOCK ', 'DX', 'DISTRIB TRAN',
'FS', 'FILE SET ', 'IN', 'INSTANCE NUM',
'FI', 'SGA OPN FILE',
'IR', 'INSTCE RECVR', 'IS', 'GET STATE ',
'IV', 'LIBCACHE INV', 'KK', 'LOG SW KICK ',
'LS', 'LOG SWITCH ',
'MM', 'MOUNT DEF ', 'MR', 'MEDIA RECVRY',
'PF', 'PWFILE ENQ ', 'PR', 'PROCESS STRT',
'RT', 'REDO THREAD ', 'SC', 'SCN ENQ ',
'RW', 'ROW WAIT ',
'SM', 'SMON LOCK ', 'SN', 'SEQNO INSTCE',
'SQ', 'SEQNO ENQ ', 'ST', 'SPACE TRANSC',
'SV', 'SEQNO VALUE ', 'TA', 'GENERIC ENQ ',
'TD', 'DLL ENQ ', 'TE', 'EXTEND SEG ',
'TS', 'TEMP SEGMENT', 'TT', 'TEMP TABLE ',
'UN', 'USER NAME ', 'WL', 'WRITE REDO ',
'TYPE='||l.type) type,
decode(l.lmode, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
4, 'S', 5, 'RSX', 6, 'X',
to_char(l.lmode) ) lmode,
decode(l.request, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
4, 'S', 5, 'RSX', 6, 'X',
to_char(l.request) ) lrequest,
decode(l.type, 'MR', o.object_name,
'TD', o.object_name,
'TM', o.object_name,
'RW', 'FILE#='||substr(l.id1,1,3)||
' BLOCK#='||substr(l.id1,4,5)||' ROW='||l.id2,
'TX', 'RS+SLOT#'||l.id1||' WRP#'||l.id2,
'WL', 'REDO LOG FILE#='||l.id1,
'RT', 'THREAD='||l.id1,
'TS', decode(l.id2, 0, 'ENQUEUE', 'NEW BLOCK ALLOCATION'),
'ID1='||l.id1||' ID2='||l.id2) objname
from sys.v_$lock l, dba_objects o
where sid = s.sid
and l.id1 = o.object_id(+) ) loop
dbms_output.put_line(chr(9)||c1.type||' H: '||c1.lmode||' R: '||c1.lrequest||' - '||c1.objname);
end loop;
dbms_output.put_line('=====================================================================');
END;
/
undef SID
===========
====== MPHASIS 19/09/2013 ======
Create HP_DBSPI User for DBMON DB Monitoring
set verify off;
whenever sqlerror CONTINUE
create user hp_dbspi. identified by "hp_dbspi"
default tablespace temp
temporary tablespace temp;
grant create session to hp_dbspi;
grant select on DBA_2PC_NEIGHBORS to hp_dbspi;
grant select on DBA_2PC_PENDING to hp_dbspi;
grant select on DBA_ANALYZE_OBJECTS to hp_dbspi;
grant select on DBA_AUDIT_EXISTS to hp_dbspi;
grant select on DBA_AUDIT_OBJECT to hp_dbspi;
grant select on DBA_AUDIT_SESSION to hp_dbspi;
grant select on DBA_AUDIT_STATEMENT to hp_dbspi;
grant select on DBA_AUDIT_TRAIL to hp_dbspi;
grant select on DBA_CATALOG to hp_dbspi;
grant select on DBA_CLU_COLUMNS to hp_dbspi;
grant select on DBA_CLUSTER_HASH_EXPRESSIONS to hp_dbspi;
grant select on DBA_CLUSTERS to hp_dbspi;
grant select on DBA_COL_COMMENTS to hp_dbspi;
grant select on DBA_COL_PRIVS to hp_dbspi;
grant select on DBA_COLL_TYPES to hp_dbspi;
grant select on DBA_CONS_COLUMNS to hp_dbspi;
grant select on DBA_CONSTRAINTS to hp_dbspi;
grant select on DBA_DATA_FILES to hp_dbspi;
grant select on DBA_DB_LINKS to hp_dbspi;
grant select on DBA_DEPENDENCIES to hp_dbspi;
grant select on DBA_DIRECTORIES to hp_dbspi;
grant select on DBA_ERRORS to hp_dbspi;
grant select on DBA_EXP_FILES to hp_dbspi;
grant select on DBA_EXP_OBJECTS to hp_dbspi;
grant select on DBA_EXP_VERSION to hp_dbspi;
grant select on DBA_EXTENTS to hp_dbspi;
grant select on DBA_FREE_SPACE to hp_dbspi;
grant select on DBA_FREE_SPACE_COALESCED to hp_dbspi;
grant select on DBA_FREE_SPACE_COALESCED_TMP1 to hp_dbspi;
grant select on DBA_FREE_SPACE_COALESCED_TMP2 to hp_dbspi;
grant select on DBA_HISTOGRAMS to hp_dbspi;
grant select on DBA_IND_COLUMNS to hp_dbspi;
grant select on DBA_IND_PARTITIONS to hp_dbspi;
grant select on DBA_INDEXES to hp_dbspi;
grant select on DBA_JOBS to hp_dbspi;
grant select on DBA_JOBS_RUNNING to hp_dbspi;
grant select on DBA_LIBRARIES to hp_dbspi;
grant select on DBA_LOBS to hp_dbspi;
grant select on DBA_METHOD_PARAMS to hp_dbspi;
grant select on DBA_METHOD_RESULTS to hp_dbspi;
grant select on DBA_MVIEWS to hp_dbspi;
grant select on DBA_NESTED_TABLES to hp_dbspi;
grant select on DBA_OBJ_AUDIT_OPTS to hp_dbspi;
grant select on DBA_OBJECT_SIZE to hp_dbspi;
grant select on DBA_OBJECT_TABLES to hp_dbspi;
grant select on DBA_OBJECTS to hp_dbspi;
grant select on DBA_PART_COL_STATISTICS to hp_dbspi;
grant select on DBA_PART_HISTOGRAMS to hp_dbspi;
grant select on DBA_PART_INDEXES to hp_dbspi;
grant select on DBA_PART_KEY_COLUMNS to hp_dbspi;
grant select on DBA_PART_TABLES to hp_dbspi;
grant select on DBA_PENDING_TRANSACTIONS to hp_dbspi;
grant select on DBA_PRIV_AUDIT_OPTS to hp_dbspi;
grant select on DBA_PROFILES to hp_dbspi;
grant select on DBA_QUEUE_SCHEDULES to hp_dbspi;
grant select on DBA_QUEUE_TABLES to hp_dbspi;
grant select on DBA_QUEUES to hp_dbspi;
grant select on DBA_RCHILD to hp_dbspi;
grant select on DBA_REFRESH to hp_dbspi;
grant select on DBA_REFRESH_CHILDREN to hp_dbspi;
grant select on DBA_REFS to hp_dbspi;
grant select on DBA_REGISTERED_SNAPSHOTS to hp_dbspi;
grant select on DBA_REPCATLOG to hp_dbspi;
grant select on DBA_RESUMABLE to hp_dbspi;
grant select on DBA_RGROUP to hp_dbspi;
grant select on DBA_ROLE_PRIVS to hp_dbspi;
grant select on DBA_ROLES to hp_dbspi;
grant select on DBA_ROLLBACK_SEGS to hp_dbspi;
grant select on DBA_SEGMENTS to hp_dbspi;
grant select on DBA_SEQUENCES to hp_dbspi;
grant select on DBA_SNAPSHOT_LOG_FILTER_COLS to hp_dbspi;
grant select on DBA_SNAPSHOT_LOGS to hp_dbspi;
grant select on DBA_SNAPSHOT_REFRESH_TIMES to hp_dbspi;
grant select on DBA_SNAPSHOTS to hp_dbspi;
grant select on DBA_SOURCE to hp_dbspi;
grant select on DBA_STMT_AUDIT_OPTS to hp_dbspi;
grant select on DBA_SYNONYMS to hp_dbspi;
grant select on DBA_SYS_PRIVS to hp_dbspi;
grant select on DBA_TAB_COL_STATISTICS to hp_dbspi;
grant select on DBA_TAB_COLUMNS to hp_dbspi;
grant select on DBA_TAB_COMMENTS to hp_dbspi;
grant select on DBA_TAB_HISTOGRAMS to hp_dbspi;
grant select on DBA_TAB_PARTITIONS to hp_dbspi;
grant select on DBA_TAB_PRIVS to hp_dbspi;
grant select on DBA_TABLES to hp_dbspi;
grant select on DBA_TABLESPACES to hp_dbspi;
grant select on DBA_TRIGGER_COLS to hp_dbspi;
grant select on DBA_TRIGGERS to hp_dbspi;
grant select on DBA_TS_QUOTAS to hp_dbspi;
grant select on DBA_TYPE_ATTRS to hp_dbspi;
grant select on DBA_TYPE_METHODS to hp_dbspi;
grant select on DBA_TYPES to hp_dbspi;
grant select on DBA_UPDATABLE_COLUMNS to hp_dbspi;
grant select on DBA_USERS to hp_dbspi;
grant select on DBA_VIEWS to hp_dbspi;
grant select on FILEXT$ to hp_dbspi;
grant select on SYS.DEFTRAN to hp_dbspi;
grant select on SYS.DEFERROR to hp_dbspi;
grant select on SYS.FET$ to hp_dbspi;
grant select on SYS.FILE$ to hp_dbspi;
grant select on SYS.FILEXT$ to hp_dbspi;
grant select on SYS.OBJ$ to hp_dbspi;
grant select on SYS.SEG$ to hp_dbspi;
grant select on SYS.SYS_DBA_SEGS to hp_dbspi;
grant select on SYS.SYS_OBJECTS to hp_dbspi;
grant select on SYS.TS$ to hp_dbspi;
grant select on SYS.UNDO$ to hp_dbspi;
grant select on SYS.USER$ to hp_dbspi;
grant execute on SYS.DBMS_SPACE_ADMIN to hp_dbspi;
grant select on V_$_LOCK to hp_dbspi;
grant select on V_$ACCESS to hp_dbspi;
grant select on V_$ACTIVE_INSTANCES to hp_dbspi;
grant select on V_$AQ1 to hp_dbspi;
grant select on V_$ARCHIVE to hp_dbspi;
grant select on V_$ARCHIVE_DEST to hp_dbspi;
grant select on V_$ARCHIVED_LOG to hp_dbspi;
grant select on V_$BACKUP to hp_dbspi;
grant select on V_$BACKUP_CORRUPTION to hp_dbspi;
grant select on V_$BACKUP_DATAFILE to hp_dbspi;
grant select on V_$BACKUP_DEVICE to hp_dbspi;
grant select on V_$BACKUP_PIECE to hp_dbspi;
grant select on V_$BACKUP_REDOLOG to hp_dbspi;
grant select on V_$BACKUP_SET to hp_dbspi;
grant select on V_$BGPROCESS to hp_dbspi;
grant select on V_$BH to hp_dbspi;
grant select on V_$BUFFER_POOL to hp_dbspi;
grant select on V_$CIRCUIT to hp_dbspi;
grant select on V_$CLASS_PING to hp_dbspi;
grant select on V_$COMPATIBILITY to hp_dbspi;
grant select on V_$COMPATSEG to hp_dbspi;
grant select on V_$CONTROLFILE to hp_dbspi;
grant select on V_$CONTROLFILE_RECORD_SECTION to hp_dbspi;
grant select on V_$COPY_CORRUPTION to hp_dbspi;
grant select on V_$CURRENT_BUCKET to hp_dbspi;
grant select on V_$DATABASE to hp_dbspi;
grant select on V_$DATAFILE to hp_dbspi;
grant select on V_$DATAFILE_COPY to hp_dbspi;
grant select on V_$DATAFILE_HEADER to hp_dbspi;
grant select on V_$DB_OBJECT_CACHE to hp_dbspi;
grant select on V_$DB_PIPES to hp_dbspi;
grant select on V_$DBFILE to hp_dbspi;
grant select on V_$DBLINK to hp_dbspi;
grant select on V_$DELETED_OBJECT to hp_dbspi;
grant select on V_$DISPATCHER to hp_dbspi;
grant select on V_$DISPATCHER_RATE to hp_dbspi;
grant select on V_$DLM_CONVERT_LOCAL to hp_dbspi;
grant select on V_$DLM_CONVERT_REMOTE to hp_dbspi;
grant select on V_$DLM_LATCH to hp_dbspi;
grant select on V_$DLM_LOCKS to hp_dbspi;
grant select on V_$DLM_MISC to hp_dbspi;
grant select on V_$ENABLEDPRIVS to hp_dbspi;
grant select on V_$ENQUEUE_LOCK to hp_dbspi;
grant select on V_$EVENT_NAME to hp_dbspi;
grant select on V_$EXECUTION to hp_dbspi;
grant select on V_$FILE_PING to hp_dbspi;
grant select on V_$FILESTAT to hp_dbspi;
grant select on V_$FIXED_TABLE to hp_dbspi;
grant select on V_$FIXED_VIEW_DEFINITION to hp_dbspi;
grant select on V_$GLOBAL_TRANSACTION to hp_dbspi;
grant select on V_$INDEXED_FIXED_COLUMN to hp_dbspi;
grant select on V_$INSTANCE to hp_dbspi;
grant select on V_$LATCH to hp_dbspi;
grant select on V_$LATCH_CHILDREN to hp_dbspi;
grant select on V_$LATCH_MISSES to hp_dbspi;
grant select on V_$LATCH_PARENT to hp_dbspi;
grant select on V_$LATCHHOLDER to hp_dbspi;
grant select on V_$LATCHNAME to hp_dbspi;
grant select on V_$LIBRARYCACHE to hp_dbspi;
grant select on V_$LICENSE to hp_dbspi;
grant select on V_$LOADCSTAT to hp_dbspi;
grant select on V_$LOADPSTAT to hp_dbspi;
grant select on V_$LOADTSTAT to hp_dbspi;
grant select on V_$LOCK to hp_dbspi;
grant select on V_$LOCK_ACTIVITY to hp_dbspi;
grant select on V_$LOCK_ELEMENT to hp_dbspi;
grant select on V_$LOCKED_OBJECT to hp_dbspi;
grant select on V_$LOCKS_WITH_COLLISIONS to hp_dbspi;
grant select on V_$LOG to hp_dbspi;
grant select on V_$LOG_HISTORY to hp_dbspi;
grant select on V_$LOGFILE to hp_dbspi;
grant select on V_$LOGHIST to hp_dbspi;
grant select on V_$MTS to hp_dbspi;
grant select on V_$SHARED_SERVER_MONITOR to hp_dbspi;
grant select on V_$MYSTAT to hp_dbspi;
grant select on V_$NLS_PARAMETERS to hp_dbspi;
grant select on V_$NLS_VALID_VALUES to hp_dbspi;
grant select on V_$OBJECT_DEPENDENCY to hp_dbspi;
grant select on V_$OFFLINE_RANGE to hp_dbspi;
grant select on V_$OPEN_CURSOR to hp_dbspi;
grant select on V_$OPTION to hp_dbspi;
grant select on V_$PARAMETER to hp_dbspi;
grant select on V_$PQ_SESSTAT to hp_dbspi;
grant select on V_$PQ_SLAVE to hp_dbspi;
grant select on V_$PQ_SYSSTAT to hp_dbspi;
grant select on V_$PQ_TQSTAT to hp_dbspi;
grant select on V_$PROCESS to hp_dbspi;
grant select on V_$PWFILE_USERS to hp_dbspi;
grant select on V_$QUEUE to hp_dbspi;
grant select on V_$RECENT_BUCKET to hp_dbspi;
grant select on V_$RECOVER_FILE to hp_dbspi;
grant select on V_$RECOVERY_FILE_STATUS to hp_dbspi;
grant select on V_$RECOVERY_LOG to hp_dbspi;
grant select on V_$RECOVERY_PROGRESS to hp_dbspi;
grant select on V_$RECOVERY_STATUS to hp_dbspi;
grant select on V_$REQDIST to hp_dbspi;
grant select on V_$RESOURCE to hp_dbspi;
grant select on V_$RESOURCE_LIMIT to hp_dbspi;
grant select on V_$ROLLSTAT to hp_dbspi;
grant select on V_$ROWCACHE to hp_dbspi;
grant select on V_$ROWCACHE_PARENT to hp_dbspi;
grant select on V_$ROWCACHE_SUBORDINATE to hp_dbspi;
grant select on V_$SESS_IO to hp_dbspi;
grant select on V_$SESSION to hp_dbspi;
grant select on V_$SESSION_CONNECT_INFO to hp_dbspi;
grant select on V_$SESSION_CURSOR_CACHE to hp_dbspi;
grant select on V_$SESSION_EVENT to hp_dbspi;
grant select on V_$SESSION_LONGOPS to hp_dbspi;
grant select on V_$SESSION_OBJECT_CACHE to hp_dbspi;
grant select on V_$SESSION_WAIT to hp_dbspi;
grant select on V_$SESSTAT to hp_dbspi;
grant select on V_$SGA to hp_dbspi;
grant select on V_$SGASTAT to hp_dbspi;
grant select on V_$SGA_DYNAMIC_COMPONENTS to hp_dbspi;
grant select on V_$SHARED_POOL_RESERVED to hp_dbspi;
grant select on V_$SHARED_SERVER to hp_dbspi;
grant select on V_$SORT_SEGMENT to hp_dbspi;
grant select on V_$SORT_USAGE to hp_dbspi;
grant select on V_$SQL to hp_dbspi;
grant select on V_$SQL_BIND_DATA to hp_dbspi;
grant select on V_$SQL_BIND_METADATA to hp_dbspi;
grant select on V_$SQL_CURSOR to hp_dbspi;
grant select on V_$SQL_SHARED_MEMORY to hp_dbspi;
grant select on V_$SQLAREA to hp_dbspi;
grant select on V_$SQL_PLAN to hp_dbspi;
grant select on V_$SQLTEXT to hp_dbspi;
grant select on V_$SQLTEXT_WITH_NEWLINES to hp_dbspi;
grant select on V_$STATNAME to hp_dbspi;
grant select on V_$SUBCACHE to hp_dbspi;
grant select on V_$SYSSTAT to hp_dbspi;
grant select on V_$SYSTEM_CURSOR_CACHE to hp_dbspi;
grant select on V_$SYSTEM_EVENT to hp_dbspi;
grant select on V_$SYSTEM_PARAMETER to hp_dbspi;
grant select on V_$TABLESPACE to hp_dbspi;
grant select on V_$THREAD to hp_dbspi;
grant select on V_$TIMER to hp_dbspi;
grant select on V_$TRANSACTION to hp_dbspi;
grant select on V_$TRANSACTION_ENQUEUE to hp_dbspi;
grant select on V_$TYPE_SIZE to hp_dbspi;
grant select on V_$VERSION to hp_dbspi;
grant select on V_$WAITSTAT to hp_dbspi;
grant select on V$ROLLNAME to hp_dbspi;
grant select on GV_$INSTANCE to hp_dbspi;
grant select on V_$ROLLNAME to hp_dbspi;
grant select on V_$TEMPFILE to hp_dbspi;
grant select on GV_$SYSSTAT to hp_dbspi;
grant select on V_$FILE_CACHE_TRANSFER to hp_dbspi;
grant select on GV_$ARCHIVED_LOG to hp_dbspi;
grant select on V_$ARCHIVED_LOG to hp_dbspi;
grant select on GV_$ARCHIVE_DEST to hp_dbspi;
grant select on V_$ARCHIVE_DEST to hp_dbspi;
grant select on DBA_LOGSTDBY_PROGRESS to hp_dbspi;
grant select on DBA_LOGSTDBY_LOG to hp_dbspi;
grant select on V_$DATABASE to hp_dbspi;
grant select on V_$ARCHIVE_DEST_STATUS to hp_dbspi;
grant select on V_$RECOVERY_FILE_DEST to hp_dbspi;
grant select on SYS.DEFTRAN to hp_dbspi;
grant select on SYS.DEFERROR to hp_dbspi;
grant select on SYS.DBA_REPCATLOG to hp_dbspi;
grant select on V_$STREAMS_POOL_ADVICE to hp_dbspi;
grant select on DBA_CAPTURE to hp_dbspi;
grant select on DBA_PROPAGATION to hp_dbspi;
grant select on DBA_APPLY to hp_dbspi;
grant select on DBA_APPLY_ERROR to hp_dbspi;
grant select on DBA_APPLY_PROGRESS to hp_dbspi;
exit;
HomeOracle 11gR2RAC ScenariosVirtualBoxAbout MeB.N.A.I.R 's Oracle blog
Stay updated via RSS
--------------------------------------------------------------------------------
Recent PostsOracle APPS Patching
Oracle APPLICATIONS R12 Installation
RMAN – Tablespace Point-In-Time Recovery
Managing 11gR1 Grid Control – Commands, Log files & Directory Structure
Oracle 11gR1 Enterprise Manager Grid Control (OEM) Installation – Part 3
Oracle 11gR1 Enterprise Manager Grid Control (OEM) Installation – Part 2
Oracle 11gR1 Enterprise Manager Grid Control (OEM) Installation – Part 1
DNS Configuration for 11gR2 SCAN & VIP
crsctl start crs Vs start cluster
11gR2 Modify / Add Scan IP & Listeners
Clusterware Startup Sequence
Replace / Migrate OCR
Create shared disks in Virtualbox
Replace / Migrate Voting Disk
Oracle 11gR2 RAC on VirtualBox with Role Seperation (grid & oracle)
11gR2 DataGuard Build on Oracle Restart [With data guard Broker setup]
Install 11gR2 Oracle Restart (Grid Infrastructure for Standalone) on Centos 5.5 with role seperation
CategoriesOracle 11gR2
Oracle Apps DBA
RAC Scenarios
RMAN
VirtualBox
February 2011 M T W T F S S
« Jan Mar »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28
11gR2 Modify / Add Scan IP & ListenersPosted: Saturday in Oracle 11gR2
011gR2
The current configuration of SCAN is 1 IP address (192.168.2.201) defined in /etc/hosts file.
Aim is to re-configure SCAN using the 3 new IP addresses defined through DNS. New IPs addresses are 192.168.2.121, 192.168.2.122 and 192.168.2.123
The current SCAN name, ‘rac-scan’ will not be changed and the three new IPs are in the same subnet as before.However, if your changes include SCAN name change and/or new IPs in different subnet, procedure to tackle these are mentioned towards the end of this post.
Configuring DNS is not explained here. That’ll be posted as a separate topic.
Step 1: Current Configuration
From Node 1
[grid@rac1 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac2
[grid@rac1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac2
[grid@rac1 ~]$ srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.2.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /rac-scan.localdomain/192.168.2.201
[grid@rac1 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
[grid@rac1 ~]$ more /etc/hosts
# Public
192.168.2.101 rac1.localdomain rac1
192.168.2.102 rac2.localdomain rac2
# Private
192.168.0.101 rac1-priv.localdomain rac1-priv
192.168.0.102 rac2-priv.localdomain rac2-priv
# Virtual
192.168.2.111 rac1-vip.localdomain rac1-vip
192.168.2.112 rac2-vip.localdomain rac2-vip
# SCAN
192.168.2.201 rac-scan.localdomain rac-scan
[grid@rac1 ~]$
Validating SCAN on second Node
[grid@rac2 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac2
[grid@rac2 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac2
[grid@rac2 ~]$ srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.2.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /rac-scan.localdomain/192.168.2.201
[grid@rac2 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
Step 2: Stop SCAN and SCAN_LISTENER
As Root
[grid@rac1 ~]$ srvctl stop scan_listener
[grid@rac1 ~]$ srvctl stop scan
[grid@rac1 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is not running
[grid@rac1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
[grid@rac1 ~]$ srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.2.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /rac-scan.localdomain/192.168.2.201
[grid@rac1 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
[grid@rac1 ~]$
Step 3: Update /etc/hosts and enable DNS
At this point, I removed the entries for VIP and SCAN from /etc/hosts file. Then I started DNS service and verified using nslookup that the 2 IPs for VIP and 3 new IPs for SCAN are working properly.
Step 4: Modify / Change SCAN
As ROOT
[root@rac1 ~]# srvctl modify scan -n rac-scan
[root@rac1 ~]# srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.2.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /rac-scan.localdomain/192.168.2.121
SCAN VIP name: scan2, IP: /rac-scan.localdomain/192.168.2.122
SCAN VIP name: scan3, IP: /rac-scan.localdomain/192.168.2.123
[root@rac1 ~]# srvctl modify scan_listener –u
[root@rac1 ~]# srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521
Step 5: Restarting SCAN and SCAN_LISTENER
As ROOT
[root@rac1 ~]# srvctl start scan
[root@rac1 ~]# srvctl start scan_listener
Step 6: Validate
[root@rac1 ~]# srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac2
SCAN VIP scan2 is enabled
SCAN VIP scan2 is running on node rac1
SCAN VIP scan3 is enabled
SCAN VIP scan3 is running on node rac1
[root@rac1 ~]# srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac2
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node rac1
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node rac1
Listener.ora
Instance 1
[root@rac1 admin]# more $GRID_HOME/network/admin/listener.ora
LISTENER_SCAN3=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN3)))) # line added by Agent
LISTENER_SCAN2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN2)))) # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN2=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN3=ON # line added by Agent
Instance 2
[root@rac2 admin]# more $GRID_HOME/network/admin/listener.ora
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
----------------------------------------------------------------------------
Change SCAN name or new IPs on different subnet?
If you intend to change SCAN name, for 11.2.0.1 as root execute:
# $GRID_HOME/bin/crsctl modify type ora.scan_vip.type -attr "ATTRIBUTE=SCAN_NAME,DEFAULT_VALUE=<new SCAN name>"
Example:
# $GRID_HOME/bin/crsctl modify type ora.scan_vip.type -attr "ATTRIBUTE=SCAN_NAME,DEFAULT_VALUE=rac-scan"
Note: if you modified SCAN name, make sure to update database init.ora parameter remote_listener as well.
If new SCAN IPs are in a different subnet, as root execute:
# $GRID_HOME/bin/crsctl modify resource ora.net1.network -attr "USR_ORA_SUBNET=<new subnet id>"
# $GRID_HOME/bin/crsctl modify resource ora.net1.network -attr "USR_ORA_NETMASK=<new subnet mask>"
Example:
# $GRID_HOME/bin/crsctl modify resource ora.net1.network -attr "USR_ORA_SUBNET=10.2.1.0"
# $GRID_HOME/bin/crsctl modify resource ora.net1.network -attr "USR_ORA_NETMASK=255.255.255.0"
Then Update and start
$ $GRID_HOME/bin/srvctl modify scan_listener -u
$ $GRID_HOME/bin/srvctl start scan_listener
About these ads
Like this:
Like Loading...RelatedDNS Configuration for 11gR2 SCAN & VIP
In "Oracle 11gR2"
Replace / Migrate OCR
In "Oracle 11gR2"
crsctl start crs Vs start cluster
In "Oracle 11gR2"
Leave a Reply Cancel reply
Enter your comment here...
Fill in your details below or click an icon to log in:
Email (required) (Address never made public) Name (required) Website You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
CancelConnecting to %s
Notify me of follow-up comments via email.
.Clusterware Startup Sequencecrsctl start crs Vs start cluster
--------------------------------------------------------------------------------
Blog at WordPress.com. | The Greyzed Theme. Follow
Follow “B.N.A.I.R 's Oracle blog”
Get every new post delivered to your Inbox.
Powered by WordPress.com%d bloggers like this:
===== ISSUES Worked on:
1. ASYNC Descriptor , for RMAN Backup Slowness : We changed ASYNC_IO Parameter to true so that it wil not check the blocks, It Will keep on taking backup
2. High CPU Utilizaion , Foud with My Query on QUERY Utilizing high CPU & done the needfull
2. NODE 2 was down, So Copied BIN Folder from NODE 1 & CReated scripts to change the hostname in all the readable files & NODE came UP
3. RAC Installation time, resolv.conf file was missing, UNIX Team added & Put DNS Entry in the File & RAC Installation started
4.
3. WHile IMPDP TABLE_EXIST_ACTION was used automatically & Tables Structure was Skipped, Data Updated & Object CReated Timings updated in Database in DBA_OBJECTS Table, SO Used TABLE_EXIST_ACTION=REPLACE & DOne with it at that time, & Created Oracle SR for this Unusall behaviour
4. ORA-07445 for Media Failure, & Transfered the Ticket to BUR (TAPE Drive team)
5. lsnrctl start : SYSTEM/6000 Error 29 Illegal SEEK : SOLUTION : Asked UNIX Team to check & Added LOCAL Entry in /etc/hosts by UNIX Team ,file 127.0.0.1 (LOOPBACK) Entry was missing #Changed /etc/hosts Perission to 666 from 664 , & Asked restart TCPIP by UNIX Team
6. Solved Many INVALID Objects Issues, By Checking Proc. , Etc..
7.
================================================
IF STANDBY DATAFILE RECOVERY to be done
IF PROD DATAFILE RECOVERY to be done
IF SYSTEM DATAFILE RECOVERY to be done
RAC CACHE FUSION :- Cache Fusion is transfering Datas from 1 Node to another by Interconnect (Private IP Address)
http://www.dba-oracle.com/t_gupta_oracle_rac_cache_fusion.htm
We know that every instance of the RAC database has its own local buffer cache which performs the usual cache functionality for that instance. Now there could be occasions when a transaction/user on instance A needs to access a data block which is being owned/locked by the other instance B. In such cases, the instance A will request instance B for that data block and hence accesses the block through the interconnect mechanism. This concept is known as CACHE FUSION where one instance can work on or access a data block in other instance?s cache via the high speed interconnect.
Cache Fusion architecture helps resolve each possible type of contentions that could be thought of in a multi-node RAC setup. We will look at them in detail in coming sections but first let us understand few very important terms/concepts which will be useful in understanding the contentions which we are going to discuss in later sections.
Global Cache Service
Global Cache Service (GCS) is the heart of Cache Fusion concept. It is through GCS that data integrity in RAC is maintained when more than one instance need a particular data block. Instances look up to the GCS for fulfilling their data block needs.
RAC BACKGROUND PROCESS
LMS , LMD , LMON , LCK0 ,
ASM ATTRIBUTES
DATAGAURD Concepts
ANS :- Datagaurd is Applying Online redo logs from Prod to Standby
Datagaurd Types:
ACTIVE DATAGAURD :- When Archives Applying is happening , when DB is in READ ONLY Mode. Applications Peoples can Use it for Report Purpose.
PASSiVE DATAGAURD :- When Archives Applying is happening , when DB is in MOUNT Mode . Applications Peoples cannot Use it for Report Purpose.
DATAGAURD CONFIGURING
Example 3-1 Primary Database: Primary Role Initialization Parameters
DB_NAME=chicago
DB_UNIQUE_NAME=chicago
LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)'
CONTROL_FILES='/arch1/chicago/control1.ctl', '/arch2/chicago/control2.ctl'
LOG_ARCHIVE_DEST_1=
'LOCATION=/arch1/chicago/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=chicago'
LOG_ARCHIVE_DEST_2=
'SERVICE=boston ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=boston'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
Example 3-2 Primary Database: Standby Role Initialization Parameters
FAL_SERVER=boston
DB_FILE_NAME_CONVERT='boston','chicago'
LOG_FILE_NAME_CONVERT=
'/arch1/boston/','/arch1/chicago/','/arch2/boston/','/arch2/chicago/'
STANDBY_FILE_MANAGEMENT=AUTO
Example 3-3 Modifying Initialization Parameters for a Physical Standby Database
DB_NAME=chicago
DB_UNIQUE_NAME=boston
LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)'
CONTROL_FILES='/arch1/boston/control1.ctl', '/arch2/boston/control2.ctl'
DB_FILE_NAME_CONVERT='chicago','boston'
LOG_FILE_NAME_CONVERT=
'/arch1/chicago/','/arch1/boston/','/arch2/chicago/','/arch2/boston/'
LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
LOG_ARCHIVE_DEST_1=
'LOCATION=/arch1/boston/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=boston'
LOG_ARCHIVE_DEST_2=
'SERVICE=chicago ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=chicago'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=chicago
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
==========================================
C:\ >dbv file=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\MANA_DATA01.DBF blocksize=8192
DBVERIFY: Release 10.2.0.2.0 - Production on Mon Sep 13 14:29:22 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\MANA_DATA01.DBF
DBV-00200: Block, dba 17268885, already marked corrupted
DBVERIFY - Verification complete
Total Pages Examined : 1685504
Total Pages Processed (Data) : 1295633
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 84554
Total Pages Failing (Index): 0
Total Pages Processed (Other): 29475 Total Pages Processed (Other): 29475
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 275842
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Highest block SCN : 100371677 (0.100371677)
RMAN> connect target sys/****
connected to target database: TAXPROD (DBID=3492187718)
RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE FILESPERSET=10;
Starting backup at 13-SEP-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=485 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\MANA_DATA01.DBF
input datafile fno=00005 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\MANA_NDX01.DBF
input datafile fno=00002 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\UNDOTBS01.DBF
input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\SYSTEM01.DBF
input datafile fno=00003 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\SYSAUX01.DBF
input datafile fno=00006 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\USERS01.DBF
channel ORA_DISK_1: backup set complete, elapsed time: 00:05:55
Finished backup at 13-SEP-10
RMAN>
SQL> select * from V$DATABASE_BLOCK_CORRUPTION;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
4 491669 1 0 CORRUPT
select
dbms_utility.data_block_address_file(17268885) RFN,
dbms_utility.data_block_address_block(17268885) BL
from dual;
RFN BL
---------- ----------
4 491669
select /*+ RULE CURSOR_SHARING_EXACT */
substrb(dbe.owner,1,15) DB_OWNER,
substrb(dbe.segment_name,1,30 ) OBJ_NAME,
substrb(dbe.partition_name,1,20 ) PART_NAME,
substrb(dbe.segment_type,1,3) TYP,
substrb(dbe.tablespace_name,1,10) TS_NAME
from dba_extents dbe
where dbe.file_id = 4
and 491669 between dbe.block_id and dbe.block_id+dbe.blocks-1
/
DB_OWNER OBJ_NAME PART_NAME TYP TS_NAME
--------------- ------------------------------ -------------------- --- ----------
MANA TAXINQUIRY_LOG TAB MANA_DATA
SQL> analyze table APEX_040000.WWV_FLOW_ACTIVITY_LOG1$ validate structure;
analyze table APEX_040000.WWV_FLOW_ACTIVITY_LOG1$ validate structure
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 2595)
ORA-01110: data file 7: '/u01/app/oracle/admin/refat/db/apex_tbs_01.dbf'
SELECT SEGMENT_TYPE,OWNER||'.'||SEGMENT_NAME
FROM DBA_EXTENTS
WHERE FILE_ID = *<FILE_ID>* AND *<BLOCK_NR*> BETWEEN BLOCK_ID
AND BLOCK_ID+BLOCKS -1;
====== RAC
Short answer:
1. private IP address is used only for internal clustering processing (Cache Fusion) (aka as interconnect)
2. VIP is used by database applications to enable fail over when one cluster node fails
http://www.dbametrix.com/oracle-rac-vip.html
3. public IP adress is the normal IP address typically used by DBA and SA to manage storage, system and database.
4. SCAN Name : SCAN Name is Single Client Access Name which has Single name with 3 Virtual IP Address, SCAN Names was Introduced in 11.2 Oracle Version,
ADV: Can Put single NAME in TNS ENTRY , either then adding 2 for 2 & 4 for 4 Node RAC.
No need for any changes in TNS Entry in Application / Client side, incase of NODE Add / Del.
We want to use Oracle ASM but not RAC on our 11gR2 (Oracle 11.2.0.3) Linux server. We have downloaded 7 zip files for complete software (database, RAC, ASM) package.
p10404530_112030_Linux-x86-64_1of7.zip
p10404530_112030_Linux-x86-64_2of7.zip
p10404530_112030_Linux-x86-64_3of7.zip
p10404530_112030_Linux-x86-64_4of7.zip
p10404530_112030_Linux-x86-64_5of7.zip
p10404530_112030_Linux-x86-64_6of7.zip
p10404530_112030_Linux-x86-64_7of7.zip
What is the detailed procedure of install ASM only without the clusterware? Thanks!
1. unzip
p10404530_112030_Linux-x86-64_1of7.zip
p10404530_112030_Linux-x86-64_2of7.zip
p10404530_112030_Linux-x86-64_3of7.zip
2. Install Asmlib packages and configure asm disks:
in http://docs.oracle.com/cd/E11882_01/install.112/e22489/typinstl.htm#BABDDFIJ
go to "1.3.6 Prepare Storage for Oracle Automatic Storage Management"
3. Install Grid infractructure from grid unzipped folder and choose "GI for Standalone Server"
this will configure ASM
4. Install database software from database unzipped folder, when creating database choose ASM for datafiles
Report Abuse
========================================
saikrishna.loya@hp.com
Computer@1234
MBFS CSI :- 18421215
select count(*),MODULE from v$active_session_history where sample_time between to_date('06-JUL-14 07:30','DD-MON-YY HH24:MI') and to_date('06-JUL-14 08:00','DD-MON-YY HH24:MI') group by MODULE;
select count(*),MODULE from v$active_session_history where sample_time like '%JUL%' group by MODULE;
select u.name USERNAME,ss.program,ss.event,ss.cnt SESSION_Count,ss.Sample_time
from user$ u, (select s.user_id,count(*) cnt,to_char(s.sample_time,'dd-mon-yyyy') Sample_time,s.event,s.program
from v$active_session_history s
where s.sample_time like '15-JUL%'
group by to_char(s.sample_time,'dd-mon-yyyy'),s.user_id,s.event,s.program) ss
where u.user# = ss.user_id
order by 3;
select program,count(*) cnt,to_char(sample_time,'dd-mon-yyyy') Sample_time
from v$active_session_history
where sample_time like '15-JUL%'
group by to_char(sample_time,'dd-mon-yyyy'),program
order by 2;
select user_id,event,count(*) cnt,to_char(sample_time,'dd-mon-yyyy') Sample_time
from v$active_session_history
where sample_time like '15-JUL%'
group by to_char(sample_time,'dd-mon-yyyy'),event,user_id
order by 3;
select count(*) from v$active_session_history where sample_time like '06-JUL%';
@usersession:
http://www.oracle.com/technetwork/issue-archive/2013/13-jan/o13dba-1871177.html
select user_id
from dba_users
where username = '&SAMPLE';
select sample_time, session_state, event, consumer_group_id
from v$active_session_history
where user_id = 92
and sample_time between
to_date('29-SEP-12 04.55.02 PM','dd-MON-yy hh:mi:ss PM')
and
to_date('29-SEP-12 05.05.02 PM','dd-MON-yy hh:mi:ss PM')
and session_id = 44
order by 1;
-------------------------
select event, count(1)
from v$active_session_history
where machine = 'prolaps01'
and sample_time between
to_date('29-SEP-12 04.55.00 PM','dd-MON-yy hh:mi:ss PM')
and
to_date('29-SEP-12 05.05.00 PM','dd-MON-yy hh:mi:ss PM')
group by event
order by event;
========================================
7506736591
Ronak Darji - 9820144324
Chetan Mundhe - 9820263732
ManojKumar Lakkakula - 9029705243
drop table alert_lg1;
CREATE TABLE alert_lg1
(
Alert_Text varchar2(3000)
)
ORGANIZATION EXTERNAL
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ALERT_LG
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
FIELDS
(
Alert_Text CHAR(3000)
)
)
LOCATION ('alert_SFMS.log')
);
col ALERT_TEXT for a180
col rownum for a10
SELECT *
FROM (SELECT rownum, alert_text FROM alert_lg1 order by 1 desc)
WHERE rownum <= 20
order by 1;
SELECT * FROM (SELECT * FROM alert_lg1 ORDER BY ROWID DESC) WHERE ROWnum<30 order by rowid;
select count(*) from alert_lg1 where ;
select count(*) from alert_lg1
where rownum > 111900;
between 111800 and 111956;
<= 111956 and rownum >= 111900;
delete archivelog all backed up 2 times to device type sbt_tape;
==============================
http://satya-dba.blogspot.in/2010/04/rman-commands.html
NECS DB Configurations:
RMAN> show all;
RMAN configuration parameters for database with db_unique_name ORCLKHAR are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\APP\TCSORACLESUPPORT\PRODUCT\11.2.0\DBHOME_1\DATABASE\SNCFORCL.ORA'; # default
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters are successfully stored
RMAN>
##################################################################
patch:
-------
Take the OH backup before applying this patch.
$cd $ORACLE_HOME
$tar –cvf /u01/oracle/ora_bin_bkup/11.1_b4psu112.tar 11.1.0
Note: If oracle home size is very huge, you can cleanup some old patch details from OH.
select owner,object_name,object_type from dba_objects where status='INVALID'
Ask application team to bring down all the applications belongs to the database.
Stop the LISTENER
$lsnrctl stop LISTENER
Shutdown the database
Apply the PSU Patch
$opatch apply
Start the database and run the below statements.
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL@?/rdbms/admin/catbundle.sql psu apply
Compile the invalid objects
SQL>@?/rdbms/admin/utlrp.sql
SELECT * FROM registry$history where ID = '6452863'; IF returns no rows, we can recompile the views, otherwise no need
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP UPGRADE
SQL>@?/cpu/view_recompile/view_recompile_jan2008cpu.sql
SQL> SHUTDOWN;
SQL> STARTUP;
Check the invalid objects list and compare the existing taken report.
Start the listener
Check and monitor the alert logs for next few hours.
Ask Application team to bring up their application.
########################################################################################################################################################
ALTER TABLESPACE TSCBSDATA ADD DATAFILE '+DATA' size 5G AUTOEXTEND ON MAXSIZE 30G;
BREAK ON tablespace_name SKIP 2
COMPUTE SUM OF allocated_bytes, free_bytes ON tablespace_name
COLUMN allocated_bytes FORMAT 9,999,999,999
COLUMN free_bytes FORMAT 9,999,999,999
SELECT a.tablespace_name, a.file_name, a.bytes allocated_bytes,
b.free_bytes
FROM dba_data_files a,
(SELECT file_id, SUM(bytes) free_bytes
FROM dba_free_space b GROUP BY file_id) b
WHERE a.file_id=b.file_id
ORDER BY a.tablespace_name;
=================================
@rtbs:
-----
set lines 132
set pages 105
set pause off
set echo off
set feedb on
column "TOTAL ALLOC (GB)" format 9,999,990.00
column "TOTAL PHYS ALLOC (GB)" format 9,999,990.00
column "USED (GB)" format 9,999,990.00
column "FREE (GB)" format 9,999,990.00
column "% USED" format 990.00
select
a.tablespace_name,
a.bytes_alloc/(1024*1024*1024) "TOTAL ALLOC (GB)",
a.physical_bytes/(1024*1024*1024) "TOTAL PHYS ALLOC (GB)",
nvl(b.tot_used,0)/(1024*1024*1024) "USED (GB)",
(nvl(b.tot_used,0)/a.bytes_alloc)*100 "% USED"
from
(select
tablespace_name,
sum(bytes) physical_bytes,
sum(decode(autoextensible,'NO',bytes,'YES',maxbytes)) bytes_alloc
from
dba_data_files
group by
tablespace_name ) a,
(select
tablespace_name,
sum(bytes) tot_used
from
dba_segments
group by
tablespace_name ) b
where
a.tablespace_name = b.tablespace_name (+)
and
a.tablespace_name not in
(select distinct
tablespace_name
from
dba_temp_files)
--and
-- a.tablespace_name not like 'UNDO%'
order by 1;
TABLESPACE_NAME TOTAL ALLOC (GB) TOTAL PHYS ALLOC (GB) USED (GB) % USED
------------------------------ ---------------- --------------------- ------------- -------
SYSAUX 2.00 1.56 1.48 74.17
SYSTEM 2.00 0.83 0.78 38.84
TSCBSDATA 90.00 40.68 9.73 10.81
TSCBSIDX 30.00 12.91 3.00 9.99
USERS 0.00 0.00 0.00 0.00
set line 180
col file_name for a55
col TABLESPACE_NAME for a25
set pages 100
set verify off
select df.FILE_ID,df.FILE_NAME,df.TABLESPACE_NAME,round(df.BYTES/1024/1024) Allocated,
round(nvl(dfs.BYTES/1024/1024,0)) FREE_SPACE, round(((df.BYTES/1024/1024)-nvl((dfs.BYTES/1024/1024),0))) USED_SPACE
from dba_data_files df,
(select file_id,tablespace_name,sum(bytes) bytes
from dba_free_space
group by file_id,tablespace_name) dfs
where df.FILE_ID=dfs.FILE_ID (+)
--AND df.TABLESPACE_NAME in('TABLESPACE_NAME')
order by df.FILE_ID;
============================
col name for a10
SELECT
NAME,
TO_CHAR( (SPACE_LIMIT)/1024/1024/1024, '9999999999999') AS "SPACE_LIMIT in GB",
TO_CHAR((SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE)/1024/1024/1024, '9999999999999')
AS "SPACE_AVAILABLE in GB",
To_CHAR((SPACE_USED)/1024/1024/1024, '9999999999999') AS "SPACE_USED in GB" ,
ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1)
AS PERCENT_FULL
FROM V$RECOVERY_FILE_DEST ;
NAME SPACE_LIMIT in SPACE_AVAILABL SPACE_USED in PERCENT_FULL
---------- -------------- -------------- -------------- ------------
+FRA 200 189 11 5.3
=====
column Name format a17
SELECT Name, (SPACE_LIMIT/1024/1024/1024) Space_Limit_GB, SPACE_USED/1024/1024/1024 Space_Used_GB, SPACE_RECLAIMABLE, NUMBER_OF_FILES
FROM V$RECOVERY_FILE_DEST;
NAME SPACE_LIMIT_GB SPACE_USED_GB SPACE_RECLAIMABLE NUMBER_OF_FILES
----------------- -------------- ------------- ----------------- ---------------
+FRA 200 10.6416016 0 105
==
set linesize 100
select * from V$RECOVERY_AREA_USAGE;
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
-------------------- ------------------ ------------------------- ---------------
CONTROL FILE 0 0 0
REDO LOG 0 0 0
ARCHIVED LOG 5.2 0 94
BACKUP PIECE .13 0 11
IMAGE COPY 0 0 0
FLASHBACK LOG 0 0 0
FOREIGN ARCHIVED LOG 0 0 0
=======================================================
select file_name, bytes, maxbytes,
increment_by*(bytes/blocks) "INCREMENT",
maxbytes-bytes remaining,
(maxbytes-bytes)/(increment_by*(bytes/blocks)) EXTENSIONS
from dba_data_files
where autoextensible = 'YES' ;
=================================
FNSONLS.INVM
column "Percent of Total Disk Usage" justify right format 999.99
column "Space Used (MB)" justify right format 9,999,999.99
column "Total Object Size (MB)" justify right format 9,999,999.99
set linesize 150
set pages 80
set feedback off
select * from (select to_char(end_interval_time, ‘MM/DD/YY’) mydate, sum(space_used_delta) / 1024 / 1024 "Space used (MB)", avg(c.bytes) / 1024 / 1024 "Total Object Size (MB)",
round(sum(space_used_delta) / sum(c.bytes) * 100, 2) "Percent of Total Disk Usage"
from
dba_hist_snapshot sn,
dba_hist_seg_stat a,
dba_objects b,
dba_segments c
where begin_interval_time > trunc(sysdate) – &days_back
and sn.snap_id = a.snap_id
and b.object_id = a.obj#
and b.owner = c.owner
and b.object_name = c.segment_name
and c.segment_name = ‘segment_name’
group by to_char(end_interval_time, ‘MM/DD/YY’))
order by to_date(mydate, ‘MM/DD/YY’);
=========================
UNDO space check
column file_name format a55
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&UNDO%' ;
set time on
column host_name format a25
select name,open_mode from gv$database;
select host_name,status,logins from gv$instance;
set pages 500
set lines 120
set heading on
column tablespace_name for a30
column tbsize for 999999999.999
column tbfree for 999999999.999
column Largest for 99999.999
column ratio for 9999.99
column Required for 99999.999
select
a.tablespace_name ,
tbsize ,
tbfree ,
b.tbfree/a.tbsize*100 "% Free TBS" ,
b.Largest "Largest space"
from
( select tablespace_name,sum(bytes)/1024/1024 tbsize
from dba_data_files
group by tablespace_name) a,
( select tablespace_name,nvl(sum(bytes)/1024/1024,0) tbfree,
nvl(max(bytes)/1024/1024,0) Largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name(+)
TABLESPACE_NAME TBSIZE TBFREE % Free TBS Largest space
------------------------------ -------------- -------------- ---------- -------------
SFMS_BR_ARCH_NDX 12288.000 11751.625 95.6349691 3968
UNDOTBS1 20480.000 19190.438 93.7033081 3968
SFMS_BR_ARCH_DATA 168759.000 147594.125 87.4585207 3968
USERS 800.000 686.625 85.828125 499
UNDOTBS2 66881.000 43030.063 64.3382463 3968
SYSTEM 2500.000 1547.438 61.8975 1547
SYSAUX 6144.000 1815.375 29.5471191 750
SFMS_BR_NDX 19732.000 5308.063 26.900783 1605
SFMS_BR_DATA 197295.000 24109.125 12.2198358 3968
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where tablespace_name=
============================================
undo usage query by session :=
col osuser for a15
col user for a10
col undo_tbs for a12
col SEGMENT_NM for a15
col command for a30
set pages 9999
set lines 200
SELECT ds.TABLESPACE_NAME "UNDO_TBS",ds.RELATIVE_FNO "File Nos",r.name "SEGMENT_NM", s.sid, s.serial#,s.osuser, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,substr(s.program, 1, 78) "COMMAND", c.sql_text
FROM sys.v_$session s, sys.v_$transaction t, sys.v_$rollname r,dba_segments ds,v$sql c
WHERE t.addr = s.taddr
and t.xidusn = r.usn
and s.sql_hash_value = c.hash_value
and ds.segment_name = r.name(+)
--and s.program not like 'ORACLE.EXE%'
ORDER BY t.cr_get, t.phy_io;
UNDO_TBS File Nos SEGMENT_NM SID SERIAL# OSUSER USER STATUS CR_GET PHY_IO USED_UBLK NOU COMMAND
------------ ---------- --------------- ---------- ---------- --------------- ---------- ---------------- ---------- ---------- ---------- --- ------------------------------
SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
UNDOTBS2 5 _SYSSMU401_2783 61 29 oracle SFMSBR ACTIVE 56371674 1970139 42916 NO sqlplus@P25O.localdomain (TNS
765022$ V1-V3)
DELETE FROM SMD_SYS_MSG_DTLS WHERE TO_DATE(SMD_CRTN_DATE) = :B1
======== For UsingTemp
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mis'),a.program,a.event,(sum(b.extents)*1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser, c.spid Process,
a.status --,'alter system kill session ''' || a.sid || ',' || a.serial# || ''' immediate;' "sids"
FROM gv$session a,gv$sort_usage b, gv$process c, dba_tablespaces d
WHERE a.saddr = b.session_addr
AND a.paddr = c.addr
AND b.tablespace=d.tablespace_name
-- and schemaname not like '%SYS%'
and b.extents*1024*1024 > 1000
group by a.username, a.osuser, a.sid||','||a.serial#,c.spid,
b.tablespace, a.status,a.program,a.event, a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
@changeawr:
----------
Then, execute the following command to create a manual snapshot.
EXECUTE dbms_workload_repository.create_snapshot();
Then wait for 30 min ( or required time period ) and create another manual snapshot by following command.
EXECUTE dbms_workload_repository.create_snapshot();
execute dbms_workload_repository.modify_snapshot_settings(interval => 60,
retention => 20160);
========PARTION===========
@part
select PARTITION_NAME,TABLESPACE_NAME,HIGH_VALUE from DBA_TAB_PARTITIONS where TABLE_NAME='&MHB_MSG_HDR_BR_AR';
=====
ls -lrt 1_10[5-8]*
=========================************************************************************=========================================
find . -type f -name "*.aud" -mtime +15 -exec rm -rf {} \;
========================================
http://select-star-from.blogspot.in/search/label/ISSUE
ORA-16191: Primary log shipping client not logged on standby
==============
pdc backup
run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup as compressed backupset database format 'E:\RMANCOLDBKP\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'E:\RMANCOLDBKP\ctl_%d_%D_%M_%Y_%s.bkp';
release channel c1;
release channel c2;
release channel c3;
}
===================https://sites.google.com/site/oraclerac009/rac-q-a=============================
ls -ltr *0402* | awk '{print $5,$NF}'
select PARTITION_NAME,TABLESPACE_NAME,HIGH_VALUE from DBA_TAB_PARTITIONS where TABLE_NAME='MST_MSG_STOR_TBL_AR';
======================
hashval
SELECT sql_text
FROM V$SQLTEXT
WHERE hash_value = 228801498
ORDER BY piece;
################################################################################################################################################################################################################
dlp:
===
*************Script to get objects info of an owner***********************************
select object_type,count(*) from dba_objects where owner='ENFOS' group by object_type;
select owner,object_type,count(*) from dba_objects group by object_type,owner order by owner;
set linesize 100 pages 100
col owner for a10
col object_name for a20
col object_type for a15
select owner,object_name,object_type,status from dba_objects where object_name='TEST';
[Query to find object count,object type]
set pages 4999 linesize 300
col owner for a20
col object_name for a25
col object_type for a25
select owner,count(*),object_type from dba_objects group by owner,object_type order by 1;
[Query to find object/schema size]
select owner,sum(bytes)/(1024*1024) "BYTES IN MB" from dba_segments group by owner;
===========================================================================================================================
******************************Script to get the DDL to create objects in Database******************
set heading off;
set echo off;
Set pages 999;
set long 90000;
select dbms_metadata.get_ddl('TABLESPACE','AV78H1IS_1996') from dual;
===========================================================================================================================
*****************************Freespace Scripts****************************************************
Datafiles in Tablespace:
-------------------------
select distinct status from v$backup;
col file_name for a55
set pages 100
select file_name,bytes/1024/1024 from dba_data_files where tablespace_name='&tablespace_name';
Freespace For a tablespace only:
-------------------------------
COL TS_NAME FOR A20
COL AVAILABLE FOR A15
COL USED FOR A15
COL FREE FOR A15
set linesize 300
select
a.tablespace_name TS_NAME,
a.bytes/1024/1024||' MB' AVAILABLE,
b.bytes/1024/1024||' MB' USED,
c.bytes/1024/1024||' MB' FREE
from
sm$ts_avail a,
sm$ts_used b,
sm$ts_free c
where a.tablespace_name=b.tablespace_name
and b.tablespace_name=c.tablespace_name
and a.tablespace_name='REFIND1';
---------------------------------------------------------------------------------------------------------------------------
Freespace in tablespace with Datafiles:
--------------------------------------
SET LINESIZE 300
SET PAGESIZE 60
COL TABLESPACE_NAME FOR A28
COL FILE_NAME FOR A55
COL TOTAL FOR A10
COL FREE FOR A10
SELECT dd.tablespace_name TABLESPACE_NAME,
dd.file_name FILE_NAME,
dd.bytes/1024/1024||' MB' TOTAL,
SUM(fs.bytes)/1024/1024||' MB' FREE
FROM sys.dba_free_space fs, sys.dba_data_files dd
WHERE dd.tablespace_name = fs.tablespace_name
AND dd.file_id = fs.file_id
GROUP BY dd.tablespace_name, dd.file_name, dd.bytes/1024
ORDER BY dd.tablespace_name, dd.file_name;
---------------------------------------------------------------------------------------------------------------------------
Freespace in Temporary tablespace:
---------------------------------
select TABLESPACE_NAME,
sum(BYTES_USED)/1024/1024,
sum(BYTES_FREE)/1024/1024 from v$temp_space_header group by tablespace_name;
col tablespace_name for a20
col USED_MB for 99999999
col FREE_MB for 99999999
set linesize 300
select tablespace_name,sum(bytes_used)/1024/1024 used_mb,sum(bytes_free)/1024/1024 free_mb from v$temp_space_header group by tablespace_name;
select name from v$tempfile;
select file_name,bytes/1024/1024 from dba_temp_files where tablespace_name='TEMP';
---------------------------------------------------------------------------------------------------------------------------
Freespace in all the tablespaces:
--------------------------------
COLUMN pct_free FORMAT 999.99 HEADING "% Free"
COLUMN name FORMAT A16 HEADING "Tablespace Name"
COLUMN mbytes FORMAT 99,999,999 HEADING "Total MBytes"
COLUMN used FORMAT 99,999,999 HEADING "Used Mbytes"
COLUMN free FORMAT 99,999,999 HEADING "Free Mbytes"
BREAK ON REPORT
COMPUTE SUM OF mbytes ON REPORT
COMPUTE SUM OF free ON REPORT
COMPUTE SUM OF used ON REPORT
SELECT fs.tablespace_name name, df.totalspace mbytes, (df.totalspace - fs.freespace) used,
fs.freespace free, 100 * (fs.freespace / df.totalspace) pct_free
FROM (SELECT tablespace_name, ROUND(SUM(bytes) / 1048576) TotalSpace FROM dba_data_files GROUP BY tablespace_name ) df,
(SELECT tablespace_name, ROUND(SUM(bytes) / 1048576) FreeSpace FROM dba_free_space GROUP BY tablespace_name ) fs
WHERE df.tablespace_name = fs.tablespace_name(+);
set pages 49999 linesize 200
select nvl(b.tablespace_name,
nvl(a.tablespace_name,'UNKOWN')) "TablespaceName",
kbytes_alloc "AllocatedSpace(MB)",
kbytes_alloc-nvl(kbytes_free,0) "UsedSpace(MB)",
nvl(kbytes_free,0) "FreeSpace(MB)",
((kbytes_alloc-nvl(kbytes_free,0))/kbytes_alloc)*100 " %Used "
from ( select sum(bytes)/1024/1024 Kbytes_free,max(bytes)/1024/1024 largest,tablespace_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024/1024 Kbytes_alloc,tablespace_name
from sys.dba_data_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
and a.tablespace_name='AV78C1TS';
----------------------------------------------------------------------------------------------------------------------------
Add Datafile Check:
------------------
select name from v$datafile where name like '%ops_stg_tab_36%';
ls -ltr /dba*/DBF/cseblpr2/eim_im06*
---------------------------------------------------------------------------------------------------------------------------
Tablespaces Freespace Report:
--------------------------------
set linesize 1000
set trimspool on
set pagesize 32000
set verify off
set feedback off
SELECT df.tablespace_name tsname
, sum(df.bytes)/1024/1024 tbs_size_mb
, nvl(sum(e.used_bytes)/1024/1024,0) used
, nvl(sum(f.free_bytes)/1024/1024,0) avail
, rpad(' '||rpad('X',round(sum(e.used_bytes)
*10/sum(df.bytes),0), 'X'),11,'-') used_visual
, nvl((sum(e.used_bytes)*100)/sum(df.bytes),0) pct_used
FROM sys.dba_data_files df
, (SELECT file_id
, sum(nvl(bytes,0)) used_bytes
FROM sys.dba_extents
GROUP BY file_id) e
, (SELECT max(bytes) free_bytes
, file_id
FROM dba_free_space
GROUP BY file_id) f
WHERE e.file_id(+) = df.file_id
AND df.file_id = f.file_id(+)
GROUP BY df.tablespace_name
ORDER BY 6
/
---------------------------------------------------------------------------------------------------------------------------
Freespace in Datafiles in a Database:
--------------------------------------
set linesize 1000
set trimspool on
set pagesize 32000
set verify off
set feedback off
column tsname format a20 heading 'Tablespace Name'
column flname format a50 heading 'Filename'
column siz format 999,999,990 heading 'File Size|(MB)'
column maxsiz format 999,999,990 heading 'Max Size|(MB)'
column pctmax format 990 heading 'Pct|Max'
select file_name flname
, tablespace_name tsname
, bytes/1024/1024 siz
, decode(maxbytes,0,0,maxbytes/1024/1024) maxsiz
, decode(maxbytes,0,0,bytes/maxbytes*100) pctmax
from dba_data_files
/
==========================================================================================================================================
******************Database Startup time***********************************
select instance_name,status,to_char(startup_time,'DD/MM/YYYY HH24:MM:SS') from v$instance;
select to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual;
==========================================================================================================================================
********************************Script Execution***************************************************
vi stats.sql
conn ra/p8rick;
set timing on
set verify on
set feedback on head on
set echo on
spool stats.log
select name from v$database;
show user;
exec dbms_stats.gather_schema_stats('WCADMIN');
spool off;
exit;
==========================================================================================================================================
***********************************User Account Scripts************************************************
set lines 200
set pages 1000
select USERNAME,PASSWORD,ACCOUNT_STATUS,EXPIRY_DATE from dba_users where username in ('CSHEKA','RPEDDI','PCHAKR','ASHAST,'RMAHAL');
select username,account_status from dba_users where username like '******';
select TEMPORARY_TABLESPACE,count(1) from dba_users group by TEMPORARY_TABLESPACE;
select DEFAULT_TABLESPACE,count(1) from dba_users group by DEFAULT_TABLESPACE;
select count(*) from dba_users;
CREATE USER CSHEKA IDENTIFIED BY nike123
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP;
===========================================================================================================================================
**********************************Max Extents for Table/Index**********************************************
select owner,table_name,MAX_EXTENTS from dba_tables where table_name='MLOG$_CMFP';
alter table NIKE.NICLRTX storage(maxextents 500);
select OWNER,INDEX_NAME,MAX_EXTENTS from dba_indexes where index_name='*******';
alter index KORODS.LCUSTPX0 storage(maxextents 200);
===========================================================================================================================================
*********************************Gather Statistics/Stats****************************************************
Tables:
SELECT DISTINCT(TRUNC(LAST_ANALYZED)),COUNT(1) from dba_tables where owner='SYSADM' GROUP BY TRUNC(LAST_ANALYZED);
select owner,table_name, LAST_ANALYZED from dba_tables where LAST_ANALYZED<=sysdate-7;
EXEC DBMS_STATS.gather_schema_stats(ownname => 'SYSADM', estimate_percent => 10);
EXEC DBMS_STATS.gather_schema_stats('SYSADM');
analyze table SYSADM."PSAPMSGPUBDATA" compute statistics;
Indexes:
SELECT DISTINCT(TRUNC(LAST_ANALYZED)),COUNT(1) from dba_indexes where owner='SYSADM' GROUP BY TRUNC(LAST_ANALYZED);
select owner,index_name from dba_indexes where last_analyzed<=sysdate-7;
analyze index sysadm."PS_PSAPMSGPUBDATA" compute statistics;
spool stats_gather.log
select name from v$database;
show user;
set timing on;
EXEC DBMS_UTILITY.analyze_schema('SYSADM','ESTIMATE', estimate_percent => 10);
spool off;
set timing off;
exit;
==========================================================================================================================================
*****************************Schema Analyze********************************
EXEC DBMS_UTILITY.analyze_schema('TEST','COMPUTE');
EXEC DBMS_UTILITY.analyze_schema('TEST','ESTIMATE', estimate_percent => 10);
=============================================================================================================================================
******************************Kill Sesion{gadmp}********************************************************************
To get Server Process Id(SPID) using the oracle session id (sid):
@getpid:
------
select spid
from v$process
where background is null
and addr in (select paddr
from v$session
where sid=&session_id);
@getsid:
------
select sid
from v$session
where paddr in (select addr
from v$process
where spid=&sp_id);
select sid,serial# from v$session where sid=***;
ps -ef|grep spid
alter system kill session 'sid,serial#';
Eg: alter system kill session '815,4221';
select sid,serial#,status from v$session where sid=***;
ps -ef|grep spid
kill -9 spid
select sid,serial#,status from v$session where sid=***;
=============================================================================================================================================
********************To View all the views************************************************************
select tname from tab where tname like '%JOB%';
=============================================================================================================================================
********************************Session Monitoring Scripts*******************************************
Session Monitoring Scripts--All the Sessions
--------------------------------------------
SET LINESIZE 500
SET PAGESIZE 1000
COLUMN username FORMAT A10
COLUMN osuser FORMAT A10
COLUMN SID for 99999
COLUMN SERIAL# for 99999
COLUMN SPID for 99999
COLUMN lockwait FORMAT A18
COLUMN status FORMAT A10
COLUMN module FORMAT A15
COLUMN machine FORMAT A15
COLUMN program FORMAT A15
SELECT NVL(s.username, '(oracle)') AS username,s.osuser,s.sid,s.serial#,p.spid,s.lockwait,s.status,s.module,s.machine,s.program,
TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time FROM v$session s,v$process p WHERE s.paddr = p.addr;
Session Monitoring Scripts--Active Sessions
-------------------------------------------
set linesize 500 pages 49999
col username for a15
col status for a10
col schemaname for a15
col osuser for a10
col process for 99999
col program for a35
SELECT SID,SERIAL#,USERNAME,STATUS,SCHEMANAME,OSUSER,PROCESS,PROGRAM,
PQ_STATUS "PARALLEL",TO_CHAR(LOGON_TIME,'DD-MM-YYYY HH24:MI:SS')
FROM V$SESSION ;
WHERE TYPE <>'BACKGROUND'
AND STATUS='ACTIVE';
Details os SQL executed currently by an SID
-------------------------------------------
SELECT b.sid,b.username,a.SQL_TEXT,a.ROWS_PROCESSED
FROM V$SQL a, v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value
AND b.sid in ('1421');
=============================================================================================================================================
***************************************Privileges to a user**********************************
---------------------------------------------------------------------------------------------
GRANTEE
User to whom access was granted
OWNER
Owner of the object
TABLE_NAME
Name of the object
GRANTOR
Name of the user who performed the grant
PRIVILEGE
Table Privilege
GRANTABLE
Privilege is grantable
HIERARCHY
Privilege is with hierarchy option
--------------------------------------------------------------------------------------------
set linesize 500 pages 49999
col grantee for a20
col owner for a20
select * from dba_tab_privs where GRANTEE='******';
=============================================================================================================================================
***********************************Segment Information for a Tablespace*******************************
set linesize 500 pages 49999
col owner a25
col segment_name for a30
select owner,segment_name,segment_type from dba_segments where tablespace_name='******';
=============================================================================================================================================
************************************List of Invalid Objects in the Database*****************************
SET LINESIZE 145
SET PAGESIZE 9999
clear columns
clear breaks
clear computes
column owner format a25 heading 'Owner'
column object_name format a30 heading 'Object Name'
column object_type format a20 heading 'Object Type'
column status format a10 heading 'Status'
break on owner skip 2 on report
compute count label "" of object_name on owner
compute count label "Grand Total: " of object_name on report
SELECT
owner
, object_name
, object_type
, status
FROM dba_objects
WHERE status <> 'VALID'
and owner not in ('SYS','SYSTEM','DBSNMP')
ORDER BY owner, object_name
/
=============================================================================================================================================
************************************Online Backup status of Datafiles*****************************
column "File No" format 9999 wrapped
column "File Name" format a50 wrapped
column "Size (bytes)" format 99999999999 wrapped
column "Backup Status" format a10 wrapped heading "Backup|Status"
column "Start Time" format a18 wrapped
set linesize 1000
set pagesize 32000
set trimspool on
select b.file# "File No"
, d.name "File Name"
, d.bytes "Size (bytes)"
, b.status "Backup Status"
, to_char(b.time,'DD-MON-YY HH24:MI:SS') "Start Time"
from v$backup b
, v$datafile d
where b.file# = d.file#
order by b.time
/
column "File No" clear
column "File Name" clear
column "Size (bytes)" clear
column "Backup Status" clear
column "Start Time" clear
=============================================================================================================================================
************************************Growth of Database*****************************
#Provides a report on physical database growth with respect to the date that data files have been added.
@monthlygrowth
----------------
SET LINESIZE 145
SET PAGESIZE 9999
SET VERIFY OFF
COLUMN month FORMAT a7 HEADING 'Month'
COLUMN growth FORMAT 999,999,999,999,999 HEADING 'Growth (MB)'
BREAK ON report
COMPUTE SUM OF growth ON report
SELECT
TO_CHAR(creation_time, 'RRRR-MM') month
, SUM(bytes)/1024/1024 growth
FROM sys.v_$datafile
GROUP BY TO_CHAR(creation_time, 'RRRR-MM')
ORDER BY TO_CHAR(creation_time, 'RRRR-MM');
=============================================================================================================================================
************************************Query all the tables within a Schema*****************************
SET LINESIZE 145
SET PAGESIZE 9999
COLUMN owner FORMAT A15 HEADING "Owner"
COLUMN table_name FORMAT A30 HEADING "Table Name"
COLUMN tablespace_name FORMAT A28 HEADING "Tablespace"
COLUMN last_analyzed FORMAT A20 HEADING "Last Analyzed"
COLUMN num_rows FORMAT 999,999,999 HEADING "# of Rows"
SELECT
owner
, table_name
, tablespace_name
, TO_CHAR(last_analyzed, 'DD-MON-YYYY HH24:MI:SS') last_analyzed
, num_rows
FROM all_tables
WHERE owner = UPPER('&owner')
ORDER BY owner, table_name
/
=============================================================================================================================================
@archgen
************************************Query to find out number of arch files generated every hour*****************************
set lines 120;
set pages 999;
SELECT
to_char(first_time,'YYYY-MON-DD') day,
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'99') "00",
to_char(sum(decode(to_char(first_time,'HH24'),'01',1,0)),'99') "01",
to_char(sum(decode(to_char(first_time,'HH24'),'02',1,0)),'99') "02",
to_char(sum(decode(to_char(first_time,'HH24'),'03',1,0)),'99') "03",
to_char(sum(decode(to_char(first_time,'HH24'),'04',1,0)),'99') "04",
to_char(sum(decode(to_char(first_time,'HH24'),'05',1,0)),'99') "05",
to_char(sum(decode(to_char(first_time,'HH24'),'06',1,0)),'99') "06",
to_char(sum(decode(to_char(first_time,'HH24'),'07',1,0)),'99') "07",
to_char(sum(decode(to_char(first_time,'HH24'),'08',1,0)),'99') "08",
to_char(sum(decode(to_char(first_time,'HH24'),'09',1,0)),'99') "09",
to_char(sum(decode(to_char(first_time,'HH24'),'10',1,0)),'99') "10",
to_char(sum(decode(to_char(first_time,'HH24'),'11',1,0)),'99') "11",
to_char(sum(decode(to_char(first_time,'HH24'),'12',1,0)),'99') "12",
to_char(sum(decode(to_char(first_time,'HH24'),'13',1,0)),'99') "13",
to_char(sum(decode(to_char(first_time,'HH24'),'14',1,0)),'99') "14",
to_char(sum(decode(to_char(first_time,'HH24'),'15',1,0)),'99') "15",
to_char(sum(decode(to_char(first_time,'HH24'),'16',1,0)),'99') "16",
to_char(sum(decode(to_char(first_time,'HH24'),'17',1,0)),'99') "17",
to_char(sum(decode(to_char(first_time,'HH24'),'18',1,0)),'99') "18",
to_char(sum(decode(to_char(first_time,'HH24'),'19',1,0)),'99') "19",
to_char(sum(decode(to_char(first_time,'HH24'),'20',1,0)),'99') "20",
to_char(sum(decode(to_char(first_time,'HH24'),'21',1,0)),'99') "21",
to_char(sum(decode(to_char(first_time,'HH24'),'22',1,0)),'99') "22",
to_char(sum(decode(to_char(first_time,'HH24'),'23',1,0)),'99') "23"
from
v$log_history
GROUP by
to_char(first_time,'YYYY-MON-DD') order by day asc;
============================================================================================================================================
2nd
---
alter session set NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS';
select trunc(first_time, 'HH') , count(*)
from v$loghist
group by trunc(first_time, 'HH')
order by trunc(first_time, 'HH');
=============================================================================================================================================
************************************Query to find out number of DBLINKS*****************************
set pages 100
set linesize 800
col owner for a20
col db_link for a30
col username for a20
col host for a20
select * from dba_db_links where db_link='SWFTW_DDL';
=============================================================================================================================================
************************************Crontab entries in UNIX*****************************
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
=============================================================================================================================================
***********************************EXTENTS***********************************
SQL> select owner,table_name,MAX_EXTENTS from dba_tables where table_name='NICLRTX';
OWNER TABLE_NAME MAX_EXTENTS
------------------------------ ------------------------------ -----------
NIKE NICLRTX 249
SQL> alter table NIKE.NICLRTX storage(maxextents 500);
Table altered.
=============================================================================================================================================
***********************************Sapreorg/Saparch***********************************
bdf|grep %|grep arch
ls -ltr /oracle/BIP/sapreorg/ARCH_SPLIT/sap*
ls -altr /oracle/PTA/sapreorg/seb*/*.new
ls -altr /oracle/PTA/sapreorg/seb*/*.old
nohup compress /oracle/PTA/sapreorg/seb*/*.new &
nohup compress /oracle/PTA/sapreorg/seb*/*.old &
=============================================================================================================================================
***********************************High Water Mark(HVM)***********************************
@watermark
set verify off
column file_name format a50 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings format 999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report
column value new_val blksize
select value from v$parameter where name = 'db_block_size';
select file_name, hwm, bytes/1024/1024,blocks total_blocks, ((blocks-hwm+1)*(&&blksize) )/1024/1024 shrinkage_possible_MB
from dba_data_files a,
( select file_id, max(block_id+blocks) hwm
from dba_extents group by file_id ) b
where a.file_id = b.file_id
and a.tablespace_name='&tbs';
SIZE TO BE SHRINKED IS shrinkage_possible*db_block_size ( in bytes)
=============================================================================================================================================
**********************************Tuning Queries******************************************
SELECT distinct b.sid,b.username,a.SQL_TEXT,a.ROWS_PROCESSED--,a.SQL_ID
FROM V$SQL a, v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value;
set linesize 500 pages 49999
col username for a15
col status for a10
col schemaname for a15
col osuser for a12
col process for 99999
col program for a35
SELECT SID,SERIAL#,USERNAME,STATUS,SCHEMANAME,OSUSER,PROCESS,PROGRAM,
PQ_STATUS "PARALLEL",TO_CHAR(LOGON_TIME,'DD-MM-YYYY HH24:MI:SS')
FROM V$SESSION where SID in (165);
;
WHERE TYPE <>'BACKGROUND'
AND USERNAME='BRIOSVR_BATCH';
--where sid ='1009';
set linesize 800 pages 49999
set lines 1000
col USERNAME for a14
col status for a10
col schemaname for a15
col OSUSER for a15
col process for 99999
col program for a12
SELECT SID,SERIAL#,USERNAME,STATUS,SCHEMANAME,OSUSER,PROCESS,PROGRAM,
TO_CHAR(LOGON_TIME,'DD-MM-YYYY HH24:MI:SS')
FROM V$SESSION
WHERE SID=93;
WHERE TYPE <>'BACKGROUND'
AND USERNAME='BRIOSVR_BATCH';
select * from v$sess_io where sid ='57';
COLUMN sid FORMAT 999,99999
COLUMN serial# FORMAT 9999999
COLUMN machine FORMAT A15
COLUMN OPNAME FOR A45
COLUMN progress_pct FORMAT 99999999.00
COLUMN elapsed FORMAT A10
COLUMN remaining FORMAT A20
COLUMN REM_MIN FOR A10
set linesize 300
SELECT distinct s.username,
s.sid,
s.serial#,
sl.opname,
s.machine,
sl.SOFAR,
sl.TOTALWORK,
TRUNC(sl.elapsed_seconds/60) || ':' || MOD(sl.elapsed_seconds,60) elapsed,
TRUNC(sl.time_remaining/60) || ':' || MOD(sl.time_remaining,60) REM_MIN
--ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct
FROM v$session s,v$session_longops sl
WHERE s.sid = sl.sid
AND s.serial# = sl.serial#
and s.username='OPS$ORACLE'
and sl.sofar<>sl.totalwork;
SET LINESIZE 200
SET PAGESIZE 1000
COLUMN username FORMAT A20
COLUMN event FORMAT A30
COLUMN wait_class FORMAT A15
SELECT NVL(s.username, '(oracle)') AS username,
s.sid,
s.serial#,
sw.event,
--sw.wait_class,
sw.wait_time,
sw.seconds_in_wait,
sw.state
FROM v$session_wait sw,
v$session s
WHERE s.sid = sw.sid
and s.TYPE<>'BACKGROUND'
--and s.SID ='11'
---and sw.event!='SQL*Net message from client'
---and s.sid in (select sid from v$px_session where qcsid ='1357')
ORDER BY s.sid,sw.seconds_in_wait DESC;
@which blocking
select l1.sid, ' IS BLOCKING ', l2.sid from v$lock l1, v$lock l2 where l1.block =1 and l2.request > 0 and l1.id1=l2.id1 and l1.id2=l2.id2;
SET LINESIZE 500
SET PAGESIZE 1000
SET VERIFY OFF
COLUMN owner FORMAT A20
COLUMN username FORMAT A20
COLUMN object_owner FORMAT A20
COLUMN object_name FORMAT A30
COLUMN locked_mode FORMAT A15
SELECT distinct b.session_id AS sid, NVL(b.oracle_username, '(oracle)') AS username, a.owner AS object_owner,a.object_name,
Decode(b.locked_mode, 0, 'None',
1, 'Null (NULL)',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share (S)',
5, 'S/Row-X (SSX)',
6, 'Exclusive (X)',
b.locked_mode) locked_mode, b.os_user_name
FROM dba_objects a, v$locked_object b
WHERE a.object_id = b.object_id
ORDER BY 1, 2, 3, 4;
set pages 4999 linesize 300
col owner for a20
col segment_name for a25
col segment_type for a25
select owner,segment_name,segment_type from dba_segments where segment_name ='PLAN_TABLE';
SET PAGESIZE 100
SET LINESIZE 200
SET VERIFY OFF
COLUMN plan FORMAT A50
COLUMN object_name FORMAT A30
COLUMN object_type FORMAT A15
COLUMN bytes FORMAT 9999999999
COLUMN cost FORMAT 9999999
COLUMN partition_start FORMAT A20
COLUMN partition_stop FORMAT A20
SELECT LPAD(' ', 2 * (level - 1)) ||
DECODE (level,1,NULL,level-1 || '.' || pt.position || ' ') ||
INITCAP(pt.operation) ||
DECODE(pt.options,NULL,'',' (' || INITCAP(pt.options) || ')') plan,
pt.object_name,
pt.object_type,
pt.bytes,
pt.cost,
pt.partition_start,
pt.partition_stop
FROM plan_table pt
START WITH pt.id = 0
AND pt.statement_id = '&1'
CONNECT BY PRIOR pt.id = pt.parent_id
AND pt.statement_id = '&1';
=============================================================================================================================================
---------------------------------------------------Session_Info-------------------------------------------------------
set pages 300
set lines 300
col sid for 9999
col serial# for 999999
col USERNAME for a15
col OSUSER for a10
col LOGON_TIME for a20
col PROGRAM for a27
col MACHINE for a10
col status for a20
select sid,serial#,username,osuser,TO_CHAR(logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,program,machine,status from v$session where sid in (651,1259);
select sid,serial#,username,osuser,TO_CHAR(logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,program,machine,status from v$session where sid in (1503,1642,1682);
---------------------------------------------------Long_run_Info--------------------------------------------------------------
COLUMN sid FORMAT 999,99999
COLUMN serial# FORMAT 9999999
COLUMN machine FORMAT A20
COL USERNAME for a15
COLUMN OPNAME FOR A20
COLUMN progress_pct FORMAT 99999999.00
COLUMN elapsed FORMAT A10
COLUMN remaining FORMAT A20
COLUMN REM_MIN FOR A10
set linesize 300
SELECT distinct s.username,
s.sid,
s.serial#,
sl.opname,
s.machine,
sl.SOFAR,
sl.TOTALWORK,
TRUNC(sl.elapsed_seconds/60) || ':' || MOD(sl.elapsed_seconds,60) elapsed,
TRUNC(sl.time_remaining/60) || ':' || MOD(sl.time_remaining,60) REM_MIN
--ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct
FROM v$session s,v$session_longops sl
WHERE s.sid = sl.sid
AND s.serial# = sl.serial#
--and s.sid in ('403','432','291','190','462','56','507','476','1305')
--AND s.sid in (select sid from v$px_session where qcsid ='1723')
and sl.sofar<>sl.totalwork;
SQL Info
SELECT distinct b.sid,b.username,a.SQL_TEXT,a.ROWS_PROCESSED--,a.SQL_ID
FROM V$SQL a, v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value
and b.sid ='386'
---and b.sid in (select sid from v$px_session where qcsid='1081')
---------------------------------------------------Locked_object_Info--------------------------------------------------------------
SET LINESIZE 500
SET PAGESIZE 1000
SET VERIFY OFF
COLUMN owner FORMAT A20
COLUMN username FORMAT A20
COLUMN object_owner FORMAT A20
COLUMN object_name FORMAT A30
COLUMN locked_mode FORMAT A15
SELECT b.session_id AS sid,NVL(b.oracle_username, '(oracle)') AS username,a.owner AS object_owner,a.object_name,
Decode(b.locked_mode, 0, 'None',
1, 'Null (NULL)',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share (S)',
5, 'S/Row-X (SSX)',
6, 'Exclusive (X)',
b.locked_mode) locked_mode,
b.os_user_name
FROM dba_objects a,
v$locked_object b
WHERE a.object_id = b.object_id and b.session_id=3047
ORDER BY 1, 2, 3, 4;
SET PAGESIZE 14
SET VERIFY ON
=================LOCKED OBJECTS=======================
select c.owner,c.object_name,c.object_type,
b.sid,b.serial#,b.status,b.osuser,b.machine
from v$locked_objects a,v$session b,dba_objects c
where b.sid=a.session_id and a.object_id=s.object_id
==
select sid,serial#,username from v$session where sid=140;
alter system kill session 'sid,serial#';
------------------------------------------I/O-------------------------------------------------------------------------
--if physicalgets changes then some select statement is running
--if block_change and consistentgets changing then some update or delete statement is going on.
col SID for 99999
col BLOCK_GETS for 9999999999
col CONSISTENT_GETS for 9999999999
col PHYSICAL_READS for 9999999999
col BLOCK_CHANGES for 9999999999
col CONSISTENT_CHANGES for 9999999999
select SID,BLOCK_GETS,CONSISTENT_GETS,PHYSICAL_READS,BLOCK_CHANGES,CONSISTENT_CHANGES from v$sess_io where sid in (514,492,487,466,458,611,533,627):;
select * from v$sess_io where sid in (select sid from v$px_session where qcsid=1305);
select SID,BLOCK_GETS,CONSISTENT_GETS,PHYSICAL_READS,BLOCK_CHANGES,CONSISTENT_CHANGES from v$sess_io where sid in (949);
---------------------------SQL_TEXT_BASED_ON_SQL_ID------------------------------------------------------------------------------
set pages 300
set lines 300
col sid for 9999
col user_opening for 9999
col users_executing for 9999
col elapsed_time for 99999999999999
col loads for 99999999
col rows_processed 9999999
col last_Active_time for a30
set long 99999999999999
select
se.sid,
s.SQL_FULLTEXT,
s.USERS_OPENING,
s.USERS_EXECUTING,
s.ELAPSED_TIME,
s.LOADS,ROWS_PROCESSED,
to_char(s.LAST_ACTIVE_TIME,'DD:MM:YYYY HH24:MI:SS') LAST_ACTIVE_TIME
from v$sql s,
v$session se
where s.sql_id=se.sql_id
and se.sid in ( );
---------------Query to find out the session info including the SQL TEXT and the amount of time elapsed since the SID is running.-------------------
set pages 10000
col username form a20
col machine form a30
col osuser form a10
col gets_per_exec form 99999999999
select s.username,s.sid,s.serial#,s.osuser,p.spid,s.machine,
sql_text,v$sqlarea.hash_value,
to_char(logon_time, 'mm/dd/yyyy hh24:mi:ss') "LOGON TIME",
to_char(trunc(last_call_et/3600,0))||' '||' HRS '||
to_char(trunc((last_call_et - trunc(last_call_et/3600,0)*3600) /
60,0))|| ' MINS' "Running Time"
from v$sqlarea , v$session s,v$process p
where s.sql_address = address
and s.status = 'ACTIVE'
and s.paddr = p.addr
and s.username is not null
and last_call_et > 60*&minutes and s.sid=625;
-- Pass the minutes value as an input and 0 will display everything
order by last_call_et
/
---------------Query to find out the SID from Process ID-------------------
SET LINESIZE 500
SET PAGESIZE 1000
COLUMN username FORMAT A10
COLUMN osuser FORMAT A10
COLUMN SID for 99999
COLUMN SERIAL# for 99999
COLUMN SPID for 99999
COLUMN lockwait FORMAT A18
COLUMN status FORMAT A10
COLUMN module FORMAT A15
COLUMN machine FORMAT A15
COLUMN program FORMAT A15
select * from v$session,v$process where addr=paddr and process='13091';
==========================================================================================================================================
From process id-find SID
select sid
from v$session
where paddr in (select addr
from v$process
where spid=&sp_id);
From SID using v$px_session find qcsid(parent sid);
select SID,SERIAL#,QCSID from v$px_session where SID=610;
Using qcsid we can find all child process of qcsid
SQL> select SID,SERIAL#,QCSID from v$px_session where qcsid=587;
SID SERIAL# QCSID
---------- ---------- ----------
482 15737 587
610 45962 587
614 39150 587
618 38354 587
587 30314 587
From SID-Find ProcessID
select spid
from v$process
where addr in (select paddr
from v$session
where sid=&sid);
==========================================================================================================================================
***UNDO MONITORING****
set linesize 450 pages 99999
col sid_serial format a20
col orauser format a20
col program format a30
col undoseg format a20
col Undo format a20
col undoseg format a10
col undoseg format a20
SELECT distinct TO_CHAR(s.sid)||','||TO_CHAR(s.serial#) sid_serial, NVL(s.username, 'None') orauser, s.program,
r.name undoseg,t.used_ublk * TO_NUMBER(x.value)/1024||'K' "Undo(KB)"
FROM sys.v_$rollname r, sys.v_$session s, sys.v_$transaction t,sys.v_$parameter x
WHERE s.taddr = t.addr
AND r.usn = t.xidusn(+)
AND x.name = 'db_block_size';
undoneeded:
===========
SELECT
ROUND(d.undo_size/(1024*1024),2) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
ROUND((TO_NUMBER(e.value)*TO_NUMBER(f.value)*g.undo_block_per_sec)/(1024*1024),2) "NEEDED UNDO SIZE [MByte]"
FROM
(
SELECT
SUM(a.bytes) undo_size
FROM
v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE
c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.TS# = b.TS#
) d,
v$parameter e,
v$parameter f,
(
SELECT
MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
FROM
v$undostat
) g
WHERE
e.name = 'undo_retention'
AND f.name = 'db_block_size'
;
============
undoretention(optimal):
============
SELECT d.undo_size/(1024*1024) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
ROUND((d.undo_size / (to_number(f.value) *
g.undo_block_per_sec))) "OPTIMAL UNDO RETENTION [Sec]"
FROM (
SELECT SUM(a.bytes) undo_size
FROM v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.ts# = b.ts#
) d,
v$parameter e,
v$parameter f,
(
SELECT MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
FROM v$undostat
) g
WHERE e.name = 'undo_retention'
AND f.name = 'db_block_size'
/
=========================================================================================================================================
***Roles/Privileges****
***General***
SELECT grantee "User",
granted_role "Role",
admin_option "Adm"
FROM dba_role_privs a
WHERE grantee='DM_COMMON';
SELECT grantee "User",
privilege "Privilege",
admin_option "Adm"
FROM dba_sys_privs where grantee='DM_COMMON';
***User Specified***
SET SERVEROUTPUT ON
SET VERIFY OFF
SELECT a.granted_role "Role",
a.admin_option "Adm"
FROM user_role_privs a;
SELECT a.privilege "Privilege",
a.admin_option "Adm"
FROM user_sys_privs a;
SET VERIFY ON
==========================================================================================================================================
-----------------------------High water mark in datafile -------------------------------------------
set verify off
column file_name format a50 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings format 999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report
column value new_val blksize
select value from v$parameter where name = 'db_block_size'
/
select file_name,
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest,
ceil( blocks*&&blksize/1024/1024) currsize,
ceil( blocks*&&blksize/1024/1024) -
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savings
from dba_data_files a,
( select file_id, max(block_id+blocks-1) hwm
from dba_extents
group by file_id ) b
where a.file_id = b.file_id(+)
and a.tablespace_name='&Tablespace_Name';
######################################################################################################################
currenttab:
----------
select table_name,round((blocks*8),2)||'kb' "size" from user_tables where table_name = 'BIG1';
actualtab:
---------
select table_name,round((num_rows*avg_row_len/1024),2)||'kb' "size" from user_tables where table_name = 'BIG1';
==========================================================================================================================================
---------------------------------------------dba_directories-------------------------------------------
set lines 100
set linesize 500
col owner for a10
col DIRECTORY_NAME for a20
col DIRECTORY_PATH for a70
select * from dba_directories;
==========================================================================================================================================
---------------------------------------------reorg_checks-------------------------------------------
cl scr
set verify off feed off
undef 1
column SEGMENT_NAME format a25
column tablespace_name format a20
set line 200
set pages 1000
select a.segment_name,c.tablespace_name,a.bytes/1024/1024,a.extents,b.last_analyzed
from dba_segments a,dba_tables b,dba_tablespaces c
where a.segment_name = '&&1'
and a.segment_name = b.table_name and a.tablespace_name = c.tablespace_name;
set pages 0
select a.segment_name,c.tablespace_name,a.bytes/1024/1024,a.extents,b.last_analyzed
from dba_segments a,dba_indexes b,dba_tablespaces c
where a.segment_name in
(select index_name from dba_indexes
where table_name = '&&1')
and a.segment_name = b.index_name and a.tablespace_name = c.tablespace_name
order by a.segment_name;
set pages 0
set echo off
col DATA_TYPE for a15
select DATA_TYPE ||' Type YES' from dba_Tab_columns where table_name='&&1'
and data_type like ('%RAW');
==========================================================================================================================================
----------------Most fragmented tables---------------
select table_name,round((blocks*8),2) "size (kb)" ,
round((num_rows*avg_row_len/1024),2) "actual_data (kb)",
(round((blocks*8),2) - round((num_rows*avg_row_len/1024),2)) "wasted_space (kb)"
from dba_tables
where (round((blocks*8),2) > round((num_rows*avg_row_len/1024),2))
order by 4 desc
===========================================================================================================================================
-----------------Long running queries---------------
SELECT s.SID,
s.serial#,
s.machine,
ROUND(sl.elapsed_seconds/60) || ':' ||
MOD(sl.elapsed_seconds,60) elapsed,
ROUND(sl.time_remaining/60) || ':' ||
MOD(sl.time_remaining,60) remaining,
ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct
FROM v$session s,
v$session_longops sl
WHERE s.SID = sl.SID
AND s.serial# = sl.serial#
ORDER BY 4 DESC
And then run the following query
SELECT a.sql_text
FROM v$sqltext a,
v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value
AND b.sid = &1 --> From above sql
ORDER BY a.piece;
BASH_PROFILE:
============
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
PATH=$PXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>TRUE);
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>FALSE);
================
@metatbs:
-------
declare c clob;
begin
for t in( select tablespace_name from dba_tablespaces)
loop
select dbms_metadata.get_ddl('TABLESPACE', t.tablespace_name) into c from dual;
dbms_output.put_line(c);
dbms_output.put(';');
end loop;
end;
=========================
https://www.scribd.com/doc/187559341/How-to-Change-Dbname-Dbid-and-Instance-Name
=======IMP===ASM========
https://www.youtube.com/watch?v=ll_orkRC3ro
=================== TRASPORTABLE TABLESPACE============
@transportable tbs
http://dba-expert.blogspot.in/2012/02/cross-platform-migration-using-rman.html
SQL> COLUMN PLATFORM_NAME FORMAT A36
SQL> SELECT * FROM V$TRANSPORTABLE_PLATFORM ORDER BY PLATFORM_NAME;
SQL> select * from v$transportable_platform order by 3,1;
#######################################################################################################################################
cms:
----
create table ACC_ER_UR_PREMIUM_HIST as select * from ACC_ER_UR_PREMIUM where 1=2;
create table ACC_ER_UR_PREMIUM_TEMP as select * from ACC_ER_UR_PREMIUM where 1=2;
/
insert /*+ APPEND */ FIRST
WHEN DAT_CALCULATION_DATE <= to_date('31/03/2014','dd/mm/yyyy')
THEN INTO ACC_ER_UR_PREMIUM_HIST
ELSE INTO ACC_ER_UR_PREMIUM_TEMP
SELECT /*+ FULL */ * from ACC_ER_UR_PREMIUM;
JOB_SCHEDULE_DTLS to check batchjob
select * from dba_scheduler_running_jobs;
select * from gv$session_longops where time_remaining>1;
select count(1) from v$session where status='ACTIVE' and username is not null ;
select sql_id,value_string from DBA_HIST_SQLBIND where sql_id = '98kn006gbj438'
select * from table(dbms_xplan.display_awr('6gurz7cb0jgbt'));
select userid,acfunc_decoder(upassword) from cnfgtr_user_mstr where UPPER(userid) like 'APPSUP%';
https://www.rediffmail.com/cgi-bin/login.cgi
1)cd /home/ias/IasHome/opmn/bin
2)./opmnctl startproc process-type=cms
or
3)./opmnctl startproc ias-component=dcm-daemon
//////////////////////////////////////////////////////////////////////////
--Execute the procedure with payment id & cheque date.
DECLARE
L_NUM_INSTRUMENT_ID NUMBER;
L_CHANGED_TO_DATE DATE;
BEGIN
L_NUM_INSTRUMENT_ID := 1001052070;
L_CHANGED_TO_DATE := to_date('','dd/mm/rrrr');
INS.ACC_CHQ_DATE_CHANGE ( L_NUM_INSTRUMENT_ID, L_CHANGED_TO_DATE );
COMMIT;
END;
/
--After execution please run the below select query to verify the modification of cheque date.
--------------------------------------------------------------------------
/
SELECT num_instrument_id, dat_instrument_date original_chq_date,
dat_changed_to_date changed_chq_date, txt_proc_run,
num_r_u_ape "Rows in Payment_entry", num_r_u_acd "Rows in Collection",
num_r_u_agl "Rows in Ledger", dat_log_date "RUN DATE"
FROM chq_date_change_log
WHERE num_instrument_id = 1000945370;
/
appsupport@universalsompo.com
C789fHLT
absalkar@in.ibm.com
asif.ahmed@in.ibm.com
customer.first@indiafirstlife.com
SELECT username U_NAME, owner OBJ_OWNER,
object_name, object_type, s.osuser,
DECODE(l.block,
0, 'Not Blocking',
1, 'Blocking',
2, 'Global') STATUS,
DECODE(v.locked_mode,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive', TO_CHAR(lmode)
) MODE_HELD
FROM gv$locked_object v, dba_objects d,
gv$lock l, gv$session s
WHERE v.object_id = d.object_id
AND (v.object_id = l.id1)
AND v.session_id = s.sid
ORDER BY username, session_id;
//////////////////////// blocked sessions//////////////////////////////
Select blocking_session, sid, serial#, wait_class,seconds_in_wait From v$session where blocking_session is not NULL
order by blocking_session;
SELECT BLOCKS
FROM DBA_SEGMENTS
WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
ANALYZE TABLE owner.table ESTIMATE STATISTICS;
SELECT EMPTY_BLOCKS
FROM DBA_TABLES
WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
select a.sid,a.program,b.sql_text from v$session a, v$sqltext b where a.sql_hash_value = b.hash_value
--and a.sid=485 order by a.sid,hash_value,piece;
Select wait_class, sum(time_waited), sum(time_waited)/sum(total_waits) Sum_Waits From v$system_wait_class
Group by wait_class
Order by 3 Asc;
select a.sid, a.event, a.total_waits, a.time_waited, a.average_wait from v$session_event a, v$session b where time_waited > 0
and a.sid=b.sid and b.username is not NULL and a.event='enq: TX - row lock contention';
Select blocking_session, sid, serial#, wait_class, seconds_in_wait From v$session where blocking_session is not NULL
order by blocking_session;
select sid, serial#, username, osuser, machine from v$session where username is not NULL;
SELECT
wait_class,NAME,ROUND (time_secs, 2) time_secs,ROUND (time_secs * 100 / SUM (time_secs) OVER (), 2) pct FROM
(SELECT n.wait_class,e.event NAME,e.time_waited / 100 time_secs FROM v$system_event e, v$event_name n WHERE
n.NAME = e.event AND n.wait_class <> 'Idle' AND time_waited > 0 UNION SELECT 'CPU',
'server CPU',SUM (VALUE / 1000000) time_secs FROM v$sys_time_model WHERE
stat_name IN ('background cpu time', 'DB CPU')) ORDER BY time_secs DESC;
grep -H -r "srvconfig" /home/ias/
////////////// LOCKED OBJECTS /////////////////////////////
select count(*) cnt,
session_id sid,
substr(event,1,30) event,
mod(p1,16) as lm,
sql_id,
CURRENT_OBJ# || ' ' || object_name obj
, o.object_type type
, CURRENT_FILE# file#
, CURRENT_BLOCK# block#
, blocking_session bsid
from dba_hist_active_sess_history ash,
all_objects o
where
event like 'enq: T%'
and o.object_id (+)= ash.current_obj#
and ash.snap_id between 44559 and 44560
group by event,session_id,p1,sql_ID,CURRENT_OBJ#,OBJECT_NAME,OBJECT_TYPE,CURRENT_FILE#, CURRENT_BLOCK#, BLOCKING_SESSION
order by count(*) desc
/u01/app/oracle/admin/configdb/bdump prod DB
/testdb/configdb/admin/udump //configdv
/testdb/configdev/dump/udump //dev
/oradata6/uattest/admin/udump // uattest
Ultimatix.Helpdesk@cmcltd.com
///////// after opmn/bin/......................////////////////////
bin]$./opmnctl start ias-component=performance_server
for uattest-refresh: cd /orasan2/uattest_refresh/expdump
POLICY_DOC_MNGMT_DTL
/home/ias/IasHome/Apache/Apache/logs/httpd.pid
/home/ias/IasHome/Apache/Apache/conf
http://172.16.8.19:1811/emd/console/ias/clusters/farm$farm=IasHome.reportserver.sompo
http://172.16.4.11:1810/emd/console/ias/clusters/farm$farm=IasHome.srvconfigrp1
proposal num 2311108805842
SELECT l.session_id||','||v.serial# sid_serial,
l.ORACLE_USERNAME ora_user,
o.object_name,
o.object_type,
DECODE(l.locked_mode,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive',
TO_CHAR(l.locked_mode)
) lock_mode,
o.status,
to_char(o.last_ddl_time,'dd.mm.yy') last_ddl
FROM dba_objects o, gv$locked_object l, v$session v
WHERE o.object_id = l.object_id
and l.SESSION_ID=v.sid
--AND object_name in ('CLAIM_GENERAL_DETAILS')
order by 2,3;
appsupport@universalsompo.com
C789fHLT
User ID - APPSUP03
Password - YU7808N37O
User ID - APPSUP04
Password - UH8059R73X
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_name,b.object_type,a.locked_mode from
(select object_id, SESSION_ID, ORACLE_USERNAME, OS_USER_NAME, LOCKED_MODE from v$locked_object) a,
(select object_id, owner, object_name,object_type from dba_objects) b
where a.object_id=b.object_id
select *
from CLAIM_TPA_LOG
where TXT_XML_ID in (
select TXT_XML_ID
from CLAIM_TPA_LOG
where DAT_INSERT_DATE = to_date('12/02/2013','dd/mm/yyyy') --Change Date here
and NUM_TPA_CLAIM_NO = 'USGI016153' -- change tpa claim number here
AND TXT_XML_TYPE = 'INTIMATION') --Change type
select object_name,object_type from dba_objects where owner = '&user'
order by object_type, object_name
////////////////////////////////////////////////////
select * from user_objects where OBJECT_TYPE = 'PACKAGE' and OBJECT_NAME like
'%HLTH_PROCESSING%'
select * from v$archive_gap;
for DR: cd /rmanbackup/archive
for prod: cd /archive
select username, count(*) from V$SESSION group by username ;
select username,osuser,terminal, from v$session where username is not null order by username,osuser;
select * from v$session where program='w3wp.exe'
select * from v$session where program='w3wp.exe' and OSUSER='IUSR_SRVCONFIGAS2';
select * from (
select
ash.SQL_ID ,
sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
sum(decode(ash.session_state,'WAITING',1,0)) "All_Waits",
sum(decode(ash.session_state,'WAITING', decode(wait_class, 'Cluster',1,0),0)) "Cluster" ,
sum(decode(ash.session_state,'WAITING', decode(wait_class, 'User I/O',1,0),0)) "User_I/O" ,
sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"
from dba_hist_active_sess_history ash
where SQL_ID is not NULL
and snap_id between 25814 and 25816
group by sql_id
order by sum(decode(session_state,'ON CPU',1,1)) desc
)
where rownum <=5
alter system kill session '105,23597';
{{ CMS PEOPLE )
SELECT txt_user_id, cms.cms_decode_str (txt_password, TO_DATE (dat_creation_date, 'dd/mm/yyyy')) FROM cms.cms_user_mst
select * from table(dbms_xplan.display_cursor('6gurz7cb0jgbt'));
select userid,acfunc_decoder(upassword) from cnfgtr_user_mstr where UPPER(userid) like 'PRAGOP%';
(((( PSW INF for cms
SELECT CNFGTR_DECODER('pK< //qq ') FROM CNFGTR_USER_MSTR WHERE USERID = 'CONCON80';
))
SQL> create index indb_transaction_id_old on cnfgtr_tran_stat_hist(transaction_id_old) tablespace indx nologging;
Index created.
TKPROF
go to bdump or udump or adump
$tkprof filename.trc filename.txt sys=no sort=fchela
tkprof mydb_ora_29951_ORDERS_QUERY.trc ORDERS_QUERY.tkp waits=yes
sys=no sort=fchela,exeela,prsela
explain plan for select * from emp:
SQL> select * from table(dbms_xplan.display);
////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\///////////////////
Trace the file.....................................................
set heading on
set timing on
alter session set tracefile_identifier = 'SUMAN_21092012';
alter session set events '10046 trace name context forever,level 8';
execute script (select statment)
//////////////////////////////////////////////////////////////////////////////////////////
select to_date(LOGON_TIME,'dd/mm/yyyy') LOGON_TIME,status,TYPE,STATE,count(*)
from v$session
group by to_date(LOGON_TIME,'dd/mm/yyyy'),status,TYPE,STATE
order by 1,2
Select -- s.username, s.LOGON_TIME,
'alter system kill session '''||s.sid||','||s.serial#||''';' "Kill Statement"
FROM V$SESSION s , V$PROCESS p
WHERE s.paddr = p.addr
AND s.username IS NOT NULL
AND s.username = 'INS'
AND s.last_call_et > 900
and s.status='INACTIVE';
rem session.sql - displays all connected sessions
set echo off;
set termout on;
set linesize 80;
set pagesize 60;
set newpage 0;
/////\\\\\\\\\\\\\\\/////////////////\\\\\\\\\\\\\\\////////////////\\\\\\\\\\\\\
select rpad(c.name||':',11)||rpad(' current logons='|| (to_number(b.sessions_current)),20)||'cumulative logons='||
rpad(substr(a.value,1,10),10)||'highwater mark='||
b.sessions_highwater Information
from
v$sysstat a,
v$license b,
v$database c
where
a.name = 'logons cumulative'
;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
select a.USERNAME,substr(a.spid,1,9) pid, substr(b.sid,1,5) sid,substr(b.serial#,1,5) ser#,
substr(b.machine,1,6) box,substr(b.username,1,10) username,substr(b.osuser,1,8) os_user,
substr(b.program,1,30) program from v$session b,
v$process a
where b.paddr = a.addr and type='USER'
AND a.USERNAME IS NOT NULL order by spid
;
ttitle off;
set heading off;
select 'To kill, enter SQLPLUS> ALTER SYSTEM KILL SESSION',
''''||'SID, SER#'||''''||';' from dual;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
select‘alter system kill session ‘’’|| sess.sid||’, ‘||sess.serial#||’;’
from v$locked_object lo, dba_objects ao, v$session sess where ao.object_id = lo.object_id
and lo.session_id = sess.sid;
select count(*) from v$session where status='INACTIVE' and username is not null ;
select username,osuser,terminal from v$session where username is not null order by username,osuser;
select * from v$session where program='w3wp.exe';
select * from v$session where program='w3wp.exe' and OSUSER='IUSR_SRVCONFIGAS2';
select * from v$session where status='ACTIVE' and username is not null ;
select count(1) from v$session where username is not null ;
select count(*) from v$session where status='ACTIVE' and username is not null ;
///////////////////////////////
CMC Limited
C-18, Bandra Kurla Complex
Bandra (E), Mumbai - 400051
Mobile: +91 9619992270
Direct Line: +91 22 67811780
BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB
(
job_name => 'PSP_GANESH_01'
,start_date => TO_TIMESTAMP_TZ('2009/09/02 15:30:00.000000 +05:30','yyyy/mm/dd hh24:mi:ss.ff tzh:tzm')
,repeat_interval => 'freq=daily;byhour=00;byminute=30;'
,end_date => NULL
,job_class => 'DEFAULT_JOB_CLASS'
,job_type => 'PLSQL_BLOCK'
,job_action => 'declare
I_RUN_DATE DATE;
BEGIN
I_RUN_DATE := to_date(sysdate,''dd/mm/rrrr'')-1;
PSP.PROC_FETCH_POLICY_DATA_g1 ( I_RUN_DATE );
COMMIT;
end;'
,comments => 'Job scheduler for ganesh Request'
);
END;
/
NUM_POL_PREMIUM -- Policy Data
TXT_OCC_SRL_NO_OCCUPANCY -- occupancy data filter by code 1
NUM_OCC_PREMIUM -- replace with NUM_POL_PREMIUM -- Policy Data
TXT_OCC_SRL_NUMBER_OCCUPANCY -- Perils
NUM_COVER_PERIL_PREMIUM - replace with NUM_POL_PREMIUM -- Policy Data
9830866750 surajit mallik
emd_web_site.xml
AGENT_HOME/bin/emctl start agent
$ORACLE_HOME/bin/emctl start iasconsole
emctl resetTZ agent
emctl istop agent
emctl stop oms
/////////////////////////////////// Bulk patch log Script//////////////////////////
select
*
from
confsys.CNFGTR_PATCH_LOG
where
to_date(RUN_DATE,'dd/mm/yyyy') = to_date('15/07/2013','dd/mm/yyyy')
General Manager (Personnel), The Singareni Collieries Co. Ltd., Recruitment
Cell, Kothagudem 507 101, Khammam Dist. (AP) only by POST / COURIER to
reach on or before 19/08/2013, super scribing the application registration
ACC_PAYMENT_ENTRY
ACC_MAP_INSTRPROPOSAL
CHQ_DATE_CHANGE_LOG
ACC_RTGS_REVERSE_FILE
Z:\Mumbai\CommonShare\Daily_Reports\Accounts\DailyPaymentDetails\FY-2012\SEP 2013
X:\CommonShare\Claims_Report\Claim Intimation Register\SEP 2013
X:\CommonShare\Claims_Report\Claim_Mis_New\SEP 2013
Z:\Mumbai\CommonShare\Daily_Report\Cash_collection_BRS\SEP 2013
X:\CommonShare\Claims_Report\F&A Claim Paid & OS\SEP 2013
policy loading issue
1.take reference no.
2.check in CNFGTR_POLICY_LD_DTLS table.
3.check LD_CALC_AMT field in above table.
4. if two record found then delete one record having LD_CALC_AMT value = 0.
5. Commit.
C:\WINDOWS\system32\inetsrv
del_execute.bat
del_pdf_execute.bat
execute.bat
merge_execute.bat
Location of JSPs:
./resources/jsp/reinsurance
Location of XML:
./WEB-INF/reinsurance
Location of JAVA and CLASSes:
./WEB-INF/classes/geni/reinsurance
swapneel 9819615585
Mahesh D Mahadik
Human Resources - WR
CMC Limited
C-18, Bandra Kurla Complex
Bandra (E), Mumbai - 400051
Mobile: +91 9967919798
Direct Line: +91 22 67811779
Website: www.cmcltd.com
http://tata.mymeetingroom.com
user id: 5077321
pass: u220t0
http://docs.oracle.com/cd/E23104_01/download_readme_cr2/download_readme_cr2.htm
In this URL please select
Task 3: Select an Oracle Forms and Reports Software Download Site then
download the installer for RHEL 5 linux 64-bit version.
Note: file name may be like ofm_pfrd_linux_11.1.1.2.0_32_disk1_1of1.zip in
http://edelivery.oracle.com/
http://www.oracle.com/technetwork/developer-tools/forms/downloads/index.html
////////////////////////////////////////
CLAIM_MOTO_SCHEDULER
if u not got record then go for genisyss
Select record for claim number.
Create insert statement
update insert key from 1 to 0
upate update no from 1 to 0
execute the insert statement.
JOB_SCHEDULE_DTLS to check batchjob
////////////////////////////////////////////////////
Patch url
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=964676135662004&id=1618213.1&_afrWindowMode=0&_adf.ctrl-state=bjnr004kr_4#BABBCHHD
30 0 * * * root find /tmp -type f -empty -delete
####################################################################################################################################################################################################################]
lmk:
shrinkdatafile:
--------------
set linesize 1000 pagesize 0 feedback off trimspool on
with
hwm as (
-- get highest block id from each datafiles ( from x$ktfbue as we don't need all joins from dba_extents )
select /*+ materialize */ ktfbuesegtsn ts#,ktfbuefno relative_fno,max(ktfbuebno+ktfbueblks-1) hwm_blocks
from sys.x$ktfbue group by ktfbuefno,ktfbuesegtsn
),
hwmts as (
-- join ts# with tablespace_name
select name tablespace_name,relative_fno,hwm_blocks
from hwm join v$tablespace using(ts#)
),
hwmdf as (
-- join with datafiles, put 5M minimum for datafiles with no extents
select file_name,nvl(hwm_blocks*(bytes/blocks),5*1024*1024) hwm_bytes,bytes,autoextensible,maxbytes
from hwmts right join dba_data_files using(tablespace_name,relative_fno)
)
select
case when autoextensible='YES' and maxbytes>=bytes
then -- we generate resize statements only if autoextensible can grow back to current size
'/* reclaim '||to_char(ceil((bytes-hwm_bytes)/1024/1024),999999)
||'M from '||to_char(ceil(bytes/1024/1024),999999)||'M */ '
||'alter database datafile '''||file_name||''' resize '||ceil(hwm_bytes/1024/1024)||'M;'
else -- generate only a comment when autoextensible is off
'/* reclaim '||to_char(ceil((bytes-hwm_bytes)/1024/1024),999999)
||'M from '||to_char(ceil(bytes/1024/1024),999999)
||'M after setting autoextensible maxsize higher than current size for file '
|| file_name||' */'
end SQL
from hwmdf
where
bytes-hwm_bytes>1024*1024 -- resize only if at least 1MB can be reclaimed
order by bytes-hwm_bytes desc
/
burleson shir:
------------
select 'alter database '||a.name||' datafile '''||b.file_name||'''' ||
' resize '||(bytes_total-bytes_free)
from v$database a
,dba_data_files b
,(Select tablespace_name,sum(bytes) bytes_full
From dba_extents
Group by tablespace_name) c
,(Select tablespace_name,sum(bytes) bytes_total
From dba_data_files
Group by tablespace_name) d
,(Select a.tablespace_name,a.file_id,b.bytes bytes_free
From (select tablespace_name,file_id
,max(block_id) max_data_block_id
from dba_extents
group by tablespace_name,file_id) a
,dba_free_space b
where a.tablespace_name = b.tablespace_name
and a.file_id = b.file_id
and b.block_id > a.max_data_block_id) e
Where b.tablespace_name = c.tablespace_name
And b.tablespace_name = d.tablespace_name;
##################################################################################################################################################################################################
mostoftensql:
-------------
SELECT
sql_text,
executions
FROM
(
SELECT
sql_text,
executions,
rank() over ( order by executions DESC) exec_rank
FROM
v$sql
)
WHERE
exec_rank >10;
/
################################
mostiosql:
----------
SELECT
disk_reads,
sql_text
FROM
(
SELECT
sql_text,
disk_reads,
dense_rank() over ( order by disk_reads DESC) disk_reads_rank
FROM
v$sql
)
WHERE
disk_reads <=10;
##################################################
mostlogcalsql:
-------------
SELECT
buffer_gets,
sql_text
FROM
(
SELECT
sql_text,
buffer_gets,
dense_rank() over (order by buffer_gets DESC) buffer_gets_rank
FROM
v$sql
)
WHERE
buffer_gets <=10;
#########################################################################################
Find the SQL for the expensive query
Here the expensive means either physical io or logical io large than 10000, the number could be differ depends on the environment.
Get the hash code first
select hash_value,executions, buffer_gets,disk_reads, parse_calls
from v$SQLAREA
where buffer_gets > 10000 or disk_reads > 10000
orderby buffer_gets + 100 * disk_reads desc
Get the SQL
select address,hash_value,piece,sql_text
from V$sqltext
where hash_value = '487379649'
orderby piece;
Find the query plan
selectoperation,options, object_name, cost
from v$sql_plan
where address = '58861A18'and hash_value='487379649'
Find the query plan for the current active user session
Find the active session
select username,terminal,program,sql_hash_value,sql_address,type
from v$session
where type notlike'BACKGROUND'
select operation,options, object_name, cost
from v$sql_plan
where address = '5F9F10F8'and hash_value='3509024188'
#################################################################################################
@unnamedg:
---------
Check for the files needs to be recovered.
SQL> select * from v$recover_file where error like ‘%FILE%’;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
—— ——- ——- ——————– ———- ——————–
33 ONLINE ONLINE FILE MISSING 0
SQL>
Identify on primary of data file 33(Primary Database)
SQL> select file#,name from v$datafile where file#=33;
FILE# NAME
—— ———————————————————————-
33 M:\UNDO\UNDOTBS02.DBF
SQL>
Identify dummy file name created in (Standby)
SQL> select file#,name from v$datafile where file#=33;
FILE# NAME
—— ———————————————————————-
33 E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00033
SQL>
Crosscheck that no MRP is running and STANDBY_FILE_MANAGEMENT can be enabled once after creating file on standby
SQL> alter database create datafile ‘E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00033’ as ‘M:\UNDO\UNDOTBS02.DBF;
Database altered.
SQL>
If you are managing File system ASM with OMF, you are not allowed to create data file, because it will file system names and format maintained by ASM. If you try to create datafile as above with ASM File, You will pass with below error.
SQL> alter database create datafile ‘ E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE \UNNAMED00033’ as ‘+DATA3\UNDO\UNDOTBS02.DBF
*
ERROR at line 1:
ORA-01276: Cannot add file
+DATA3\UNDO\UNDOTBS02. File has an Oracle Managed Files file name.
Then Run above command as shown below
SQL> alter database create datafile ‘E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00033’ as new;
Database altered.
SQL>
Enable STANDBY_FILE_MANAGEMENT to AUTO & Start MRP.
SQL> show parameter standby_file_management
NAME TYPE VALUE
———————————— ———– ————————-
standby_file_management string MANUAL
SQL> alter system set standby_file_management=AUTO scope=both;
system altered.
SQL> show parameter standby_file_management
NAME TYPE VALUE
———————————— ———– ————————–
standby_file_management string AUTO
SQL> alter database recover managed standby database disconnect from session;
Database altered.
#################################################################################################################################
@manualsync:
---------
increamental sync
================
1. [Standby] Stop the managed standby apply process:
SQL> alter database recover managed standby database cancel;
Database altered.
2. [Standby] Shutdown the standby database
3. [Primary] On the primary, take an incremental backup from the SCN number where the standby has been stuck:
run
{
allocate channel c1 type disk format '/u01/rman_backup/inctl_%U.bkp';
backup incremental from scn 67 database;
}
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=139 devtype=DISK
Starting backup at 18-DEC-09
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/oradata/DEL1/datafile/o1_mf_system_5bhbh59c_.dbf
… …
piece handle=/u01/oraback/06l16u1q_1_1.rmb tag=TAG20091218T083619 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:06
Finished backup at 18-DEC-09
released channel: c1
4. [Primary] On the primary, create a new standby controlfile:
SQL> alter database create standby controlfile as '/u01/rman_backup/inctl_%U.ctl';
Database altered.
5. [Primary] Copy these files to standby host:
oracle@oradba1 /u01/oraback# scp *.rmb *.ctl oracle@oradba2:/u01/oraback
oracle@oradba2's password:
06l16u1q_1_1.rmb 100% 43MB 10.7MB/s 00:04
DEL1_standby.ctl 100% 43MB 10.7MB/s 00:04
6. [Standby] Bring up the instance in nomount mode:
SQL> startup nomount
7. [Standby] Check the location of the controlfile:
SQL> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/oradata/standby_cntfile.ctl
8. [Standby] Replace the controlfile with the one you just created in primary.
9. $ cp /u01/oraback/DEL1_standby.ctl /u01/oradata/standby_cntfile.ctl
10.[Standby] Mount the standby database:
SQL> alter database mount standby database;
11.[Standby] RMAN does not know about these files yet; so you must let it know – by a process called cataloging. Catalog these files:
$ rman target=/
Recovery Manager: Release 10.2.0.4.0 - Production on Fri Dec 18 06:44:25 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: DEL1 (DBID=846390698, not open)
RMAN> catalog start with '/u01/oraback';
using target database control file instead of recovery catalog
searching for all files that match the pattern /u01/oraback
List of Files Unknown to the Database
=====================================
File Name: /u01/oraback/DEL1_standby.ctl
File Name: /u01/oraback/06l16u1q_1_1.rmb
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/oraback/DEL1_standby.ctl
File Name: /u01/oraback/06l16u1q_1_1.rmb
12.Recover these files:
RMAN> recover database;
######################################################################################################################3
@gridconf:
---------
groupadd -g 1000 oinstall
groupadd -g 1020 asmadmin
groupadd -g 1021 asmdba
groupadd -g 1031 dba
groupadd -g 1022 asmoper
groupadd -g 1023 oper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,dba,asmoper grid
useradd -u 1101 -g oinstall -G dba,asmdba,oper oracle
passwd oracle
passwd grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oraInventory
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/oracle
chown -R grid:oinstall /u01/app/11.2.0/grid
chown -R grid:oinstall /u01/app/grid
chown -R oracle:oinstall /u01/app/oracle
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
chmod -R 775 /u01/app/grid
fdisk /dev/sdb
echo "- - -" > /sys/class/scsi_host/host0/scan
/etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
/etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
/etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
chown grid:asmadmin /dev/sdb1
chmod 660 /dev/sdb1
chown grid:asmadmin /dev/sdc1
chmod 660 /dev/sdc1
chown grid:asmadmin /dev/sdd1
chmod 660 /dev/sdd1
#################################################################################
/sbin/ifconfig
netstat -l
#################################################################################
librarycacheinfo:
-----------------
SELECT NAMESPACE, GETS, PINS, GETHITRATIO FROM V$LIBRARYCACHE;
SELECT S.NAME, V.VALUE FROM V$STATNAME S, V$MYSTAT V WHERE S.STATISTIC# = V.STATISTIC# AND S.NAME LIKE 'parse%';
########################################################################################
@whentorebuild:
--------------
If the index has height greater than four, rebuild the index
The deleted leaf rows should be less than 20%.
SELECT name, height, lf_rows, del_lf_rows, (del_lf_rows/lf_rows)*100 as ratio FROM INDEX_STATS;
ANALYZE INDEX <IDX_GAM_FID> VALIDATE STRUCTURE;
ALTER INDEX <> REBULD REBUILD ONLINE;
###################################################################################################
sqltuningadvisor:
-----------------
CONNECT / AS SYSDBA
GRANT ADVISOR TO SH;
1.CONNECT sh@TESTDB/sh
2.Define an SQL Tuning Task for a single query:
DECLARE
l_task VARCHAR2(30);
l_sql CLOB;
BEGIN
l_sql := 'SELECT AMOUNT_SOLD FROM sh.SALES S ' ||
'WHERE S.CUST_ID IN ( '||
'SELECT C.CUST_ID FROM sh.CUSTOMERS C ' ||
'WHERE C.CUST_CREDIT_LIMIT IN (:l1, :l2, :l3))';
l_task := DBMS_SQLTUNE.CREATE_TUNING_TASK(
sql_text => l_sql,
bind_list => sql_binds(anydata.ConvertNumber(10000),
anydata.ConvertNumber(11000),
anydata.ConvertNumber(15000)),
user_name => 'SH',
scope => 'COMPREHENSIVE',
time_limit => 120,
task_name => 'test_tuning_task',
description => 'Specific SQL tuning');
END;
/
3. Execute the SQL Tuning Task just defined:
BEGIN
DBMS_SQLTUNE.EXECUTE_TUNING_TASK(task_name => 'test_tuning_task');
END;
/
4. View the results of the tuning process:
SET LINESIZE 120
SET LONG 1000
SET LONGCHUNKSIZE 1000
SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK('test_tuning_task')
FROM DUAL;
5. Drop the SQL Tuning Task and revoke grants from user SH:
EXEC DBMS_SQLTUNE.DROP_TUNING_TASK('test_tuning_task');
CONNECT / AS SYSDBA
REVOKE ADVISOR FROM SH;
################################################################################################################################3
@cachetable:
----------
ALTER TABLE SH.CUSTOMERS STORAGE (BUFFER_POOL KEEP);
@objinbuffer:
------------
COL OBJECT_NAME FOR A30
COL OBJECT_TYPE FOR A20
SELECT OBJECT_NAME, OBJECT_TYPE, COUNT(*) AS "buffers"
FROM SYS.X$BH XBH, SYS.DBA_OBJECTS OBJ
WHERE XBH.OBJ = OBJ.OBJECT_ID
AND OWNER = 'SH'
GROUP BY OBJECT_TYPE, OBJECT_NAME
ORDER BY OBJECT_TYPE, OBJECT_NAME;
v$db_object_cache:
select owner,name,type,sharable_mem from v$db_object_cache where kept='YES';
#############################################################################################################################
bufferbusyavoid:
---------------
User Action
Look at v$waitstat (or the buffer busy drill down page) and determine the block type with the highest waits.
Block Type and Action:
Undo Header - Use Automatic Undo Management (AUM) or add more RBS segments)
Undo Block - Use AUM (or increase RBS sizes)
Data Block - First determine if it is an I/O problem. The Buffer Busy Waits drill-down page should provide this information. Otherwise, sample from v$session_wait
SELECT p3, count(*) FROM v$session_wait WHERE event='buffer busy wait' group by p3;
If p3 is less than 200 then it is an I/O problem. Either improve I/O performance or change application. Applications running concurrent batch jobs that do full table scans on the same large tables run into this problem.
Free List - Use ASSM (or freelists groups)
http://www.oracledba.in/Articles/display_article.aspx?article_id=53
http://www.dba-oracle.com/art_builder_bbw.htm
#################################################################
indpartition:
-------------
select index_name from dba_indexes where table_name='MTC_MSG_TXT_CBS';
select INDEX_OWNER,INDEX_NAME,PARTITION_NAME,STATUS,TABLESPACE_NAME from dba_ind_partitions where INDEX_NAME='MTC_MSG_TXT_CBS_IDX';
sys@RTGSSFMS2> select INDEX_OWNER,INDEX_NAME,PARTITION_NAME,STATUS,TABLESPACE_NAME from dba_ind_partitions where INDEX_NAME='MTC_MSG_TXT_CBS_IDX';
INDEX_OWNER INDEX_NAME PARTITION_NAME STATUS TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------ -------- ------------------------------
SFMSBR MTC_MSG_TXT_CBS_IDX P1 USABLE SFMS_BR_NDX
SFMSBR MTC_MSG_TXT_CBS_IDX P2 USABLE SFMS_BR_NDX
SFMSBR MTC_MSG_TXT_CBS_IDX P3 USABLE SFMS_BR_NDX
alter index SFMSBR.MTC_MSG_TXT_CBS_IDX rebuild partition p1 online;
alter index SFMSBR.MTC_MSG_TXT_CBS_IDX rebuild partition p2 online;
alter index SFMSBR.MTC_MSG_TXT_CBS_IDX rebuild partition p3 online;
ALTER INDEX indexName MONITORING USAGE;
V$OBJECT_USAGE
#################################################################################################################
@pointintimerecovery:
--------------
RMAN> recover tablespace "TEST" until SCN 4515327 auxiliary destination '+DATA';
select timestamp_to_scn(sysdate) from dual;
#########################################################################
@optredo:
-------------
The default size of the redo log buffer is calculated as follows:
MAX(0.5M, (128K * number of cpus))
#####################################################################################################################
ourskil:
select sql_id,hash_value,plan_hash_value from v$sql where sql_text='select * from scott.dept where deptno=40';
#################################################################################################################
@oskill:
$ kill -9 `ps -ef | grep LOCAL=YES | grep -v grep | awk '{print $2}'`
##################################################################################################################3
shrink:
set linesize 1000 pagesize 0 feedback off trimspool on
with
hwm as (
-- get highest block id from each datafiles ( from x$ktfbue as we don't need all joins from dba_extents )
select /*+ materialize */ ktfbuesegtsn ts#,ktfbuefno relative_fno,max(ktfbuebno+ktfbueblks-1) hwm_blocks
from sys.x$ktfbue group by ktfbuefno,ktfbuesegtsn
),
hwmts as (
-- join ts# with tablespace_name
select name tablespace_name,relative_fno,hwm_blocks
from hwm join v$tablespace using(ts#)
),
hwmdf as (
-- join with datafiles, put 5M minimum for datafiles with no extents
select file_name,nvl(hwm_blocks*(bytes/blocks),5*1024*1024) hwm_bytes,bytes,autoextensible,maxbytes
from hwmts right join dba_data_files using(tablespace_name,relative_fno)
)
select
case when autoextensible='YES' and maxbytes>=bytes
then -- we generate resize statements only if autoextensible can grow back to current size
'/* reclaim '||to_char(ceil((bytes-hwm_bytes)/1024/1024),999999)
||'M from '||to_char(ceil(bytes/1024/1024),999999)||'M */ '
||'alter database datafile '''||file_name||''' resize '||ceil(hwm_bytes/1024/1024)||'M;'
else -- generate only a comment when autoextensible is off
'/* reclaim '||to_char(ceil((bytes-hwm_bytes)/1024/1024),999999)
||'M from '||to_char(ceil(bytes/1024/1024),999999)
||'M after setting autoextensible maxsize higher than current size for file '
|| file_name||' */'
end SQL
from hwmdf
where
bytes-hwm_bytes>1024*1024 -- resize only if at least 1MB can be reclaimed
order by bytes-hwm_bytes desc
/
###############################################
cloneraj:
--------
1 Take backup of source database
2. Copy backup pieces to target host machine.
3. Create pfile from spfile (source machine)
create pfile='<path/init<service>.ora' from spfile;
4. Copy pfile to target machine ($ORACLE_HOME/dbs/)
5. Remove all entries related to instance 2
6. Change cluster_database=false
*.cluster_database=false
7. Specify the contorl file path in pfile
*.control_files=
'+REDO01/<DBNAME>/CONTROLFILE/ctrl01.dbf',
'+REDO02/<DBNAME>/CONTROLFILE/ctrl02.dbf'
8. Change DB_NAME to duplicater DB name and db_create_file_dest='+DATADG'
8. Change instane_number =1
<DBNAME>.instance_number=1
9. Add entry for remote_listener in pfile
*.remote_listener='ptrandr-scan.mcsl.in:1526'
MPUTDB.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=10.88.11.21)(PORT=1526))'
10. Create password file for target database.
orapwd file=/oracle/product/11.2.0/db/dbs/orapw<DBNAME> password=<password> entries=10
11. Create adump dir in target server
mkdir -p /oracle/product/admin/<DBNAME>/adump
12. Setup the environment variables and startup nomount
ORACLE_SID=<DB_NAME>; export ORACLE_SID
sqlplus / as sysdba
STARTUP NOMOUNT;
exit
13.Connect RMAN with Auxiliary database
rman AUXILIARY /
RMAN>DUPLICATE DATABASE TO MPSWSDB
BACKUP LOCATION '/DBtemp/070914/MPPWSDB_20140907/';
for standby :-
DUPLICATE TARGET DATABASE
FOR STANDBY BACKUP LOCATION '/DBtemp/MPPBSDB/' ;
DUPLICATE TARGET DATABASE FOR STANDBY BACKUP LOCATION '/DBtemp/MPPBSDB/'
DB_FILE_NAME_CONVERT='+DATA','+DATADG';
14. Once duplication complete, you would get error in alert log that unable to create spfile.
15. Stop database and restart with pfile.
RMAN> shutdown database
16.Startup the database from pfile.
17. Create spfile from pfile.
CREATE SPFILE='+DATA/<DBNAME>/spfile<DBNAME>.ora' from pfile;
18. Edit pfile with spfile entry.
SPFILE='+DATA/<DBNAME>/spfile<DBNAME>.ora'
19. Unregister and Register DB
srvctl add database -d <DBNAME> -o /oracle/product/11.2.0/db -c RACONENODE -i <INSTANCE_NAME> -e mcslin-mum-air-dr-ptrandb1.mcsl.in
20. Start DB with srvctl
srvctl start database -d <DBNAME>
######################################################################3
@dytbs:
-----------
select 'create tablespace ' || df.tablespace_name || chr(10)
|| ' datafile ''' || df.file_name || ''' size ' || df.bytes
|| decode(autoextensible,'N',null, chr(10) || ' autoextend on maxsize '
|| maxbytes)
|| chr(10)
|| 'default storage ( initial ' || initial_extent
|| decode (next_extent, null, null, ' next ' || next_extent )
|| ' minextents ' || min_extents
|| ' maxextents ' || decode(max_extents,'2147483645','unlimited',max_extents)
|| ') ;'
from dba_data_files df, dba_tablespaces t
where df.tablespace_name=t.tablespace_name
/
######################################################################################
@order:
--------
bash-4.2$ cat order.sql
set serveroutput on size 50000
set echo off feed off veri off
accept SID prompt 'Enter Oracle SID: '
DECLARE
v_sid number;
s sys.v_$session%ROWTYPE;
p sys.v_$process%ROWTYPE;
BEGIN
begin
select sid into v_sid
from sys.v_$session s
where sid = &&SID;
exception
when no_data_found then
dbms_output.put_line('Unable to find SID &&SID!!!');
return;
when others then
dbms_output.put_line(sqlerrm||'naaaaaaaaaaaaaaaaaaaaa');
return;
end;
select * into s from sys.v_$session where sid = v_sid;
select * into p from sys.v_$process where addr = s.paddr;
dbms_output.put_line('=====================================================================');
dbms_output.put_line('SID/Serial : '|| s.sid||','||s.serial#);
dbms_output.put_line('Foreground : '|| 'PID: '||s.process||' - '||s.program);
dbms_output.put_line('Shadow : '|| 'PID: '||p.spid||' - '||p.program);
dbms_output.put_line('Terminal : '|| s.terminal || '/ ' || p.terminal);
dbms_output.put_line('OS User : '|| s.osuser||' on '||s.machine);
dbms_output.put_line('Ora User : '|| s.username);
dbms_output.put_line('Status Flags: '|| s.status||' '||s.server||' '||s.type);
dbms_output.put_line('Tran Active : '|| nvl(s.taddr, 'NONE'));
dbms_output.put_line('Login Time : '|| to_char(s.logon_time, 'Dy HH24:MI:SS'));
dbms_output.put_line('Last Call : '|| to_char(sysdate-(s.last_call_et/60/60/24), 'Dy HH24:MI:SS') || ' - ' || to_char(s.last_call_et/60, '9999999999.0') || ' min');
dbms_output.put_line('Lock/ Latch : '|| nvl(s.lockwait, 'NONE')||'/ '||nvl(p.latchwait, 'NONE'));
dbms_output.put_line('Latch Spin : '|| nvl(p.latchspin, 'NONE'));
dbms_output.put_line('Current SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.sql_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Previous SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.prev_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Session Waits:');
for c1 in ( select * from sys.v_$session_wait where sid = s.sid) loop
dbms_output.put_line(chr(9)||c1.state||': '||c1.event);
end loop;
dbms_output.put_line('Connect Info:');
for c1 in ( select * from sys.v_$session_connect_info where sid = s.sid) loop
dbms_output.put_line(chr(9)||': '||c1.network_service_banner);
end loop;
dbms_output.put_line('Locks:');
for c1 in ( select
decode(l.type,
-- Long locks
'TM', 'DML/DATA ENQ', 'TX', 'TRANSAC ENQ',
'UL', 'PLS USR LOCK',
-- Short locks
'BL', 'BUF HASH TBL', 'CF', 'CONTROL FILE',
'CI', 'CROSS INST F', 'DF', 'DATA FILE ',
'CU', 'CURSOR BIND ',
'DL', 'DIRECT LOAD ', 'DM', 'MOUNT/STRTUP',
'DR', 'RECO LOCK ', 'DX', 'DISTRIB TRAN',
'FS', 'FILE SET ', 'IN', 'INSTANCE NUM',
'FI', 'SGA OPN FILE',
'IR', 'INSTCE RECVR', 'IS', 'GET STATE ',
'IV', 'LIBCACHE INV', 'KK', 'LOG SW KICK ',
'LS', 'LOG SWITCH ',
'MM', 'MOUNT DEF ', 'MR', 'MEDIA RECVRY',
'PF', 'PWFILE ENQ ', 'PR', 'PROCESS STRT',
'RT', 'REDO THREAD ', 'SC', 'SCN ENQ ',
'RW', 'ROW WAIT ',
'SM', 'SMON LOCK ', 'SN', 'SEQNO INSTCE',
'SQ', 'SEQNO ENQ ', 'ST', 'SPACE TRANSC',
'SV', 'SEQNO VALUE ', 'TA', 'GENERIC ENQ ',
'TD', 'DLL ENQ ', 'TE', 'EXTEND SEG ',
'TS', 'TEMP SEGMENT', 'TT', 'TEMP TABLE ',
'UN', 'USER NAME ', 'WL', 'WRITE REDO ',
'TYPE='||l.type) type,
decode(l.lmode, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
4, 'S', 5, 'RSX', 6, 'X',
to_char(l.lmode) ) lmode,
decode(l.request, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
4, 'S', 5, 'RSX', 6, 'X',
to_char(l.request) ) lrequest,
decode(l.type, 'MR', o.object_name,
'TD', o.object_name,
'TM', o.object_name,
'RW', 'FILE#='||substr(l.id1,1,3)||
' BLOCK#='||substr(l.id1,4,5)||' ROW='||l.id2,
'TX', 'RS+SLOT#'||l.id1||' WRP#'||l.id2,
'WL', 'REDO LOG FILE#='||l.id1,
'RT', 'THREAD='||l.id1,
'TS', decode(l.id2, 0, 'ENQUEUE', 'NEW BLOCK ALLOCATION'),
'ID1='||l.id1||' ID2='||l.id2) objname
from sys.v_$lock l, dba_objects o
where sid = s.sid
and l.id1 = o.object_id(+) ) loop
dbms_output.put_line(chr(9)||c1.type||' H: '||c1.lmode||' R: '||c1.lrequest||' - '||c1.objname);
end loop;
dbms_output.put_line('=====================================================================');
END;
/
undef SID
===============================================
@movedatafile:
RMAN> ;
RMAN> SQL 'ALTER TABLESPACE soe OFFLINE';
Switch to the new datafile copy(s) and recover the tablespace.
RMAN> SWITCH DATAFILE 8 TO COPY;
RMAN> RECOVER TABLESPACE soe;
RMAN> SQL 'ALTER TABLESPACE soe ONLINE';
===================================================================================
@cloneothersid:
run{
backup database format '/u01/rmanbkp/rman_full_%d_%s_%p';
backup archivelog all format '/u01/rmanbkp/rman_full_arc_%d_%s_%p';
}
======ready pfile==========
do changes accoring ====> rman auxiliary /
run {
SET NEWNAME FOR DATABASE TO '/u01/app/oracle/oradata/orcl/%b';
SET NEWNAME FOR TEMPFILE 1 TO '/u01/app/oracle/oradata/orcl/temp01.dbf' ;
DUPLICATE DATABASE 'RMG' DBID 1604518329 TO ORCL BACKUP LOCATION '/u01/rmanbkp/'
LOGFILE
GROUP 1 ('/u01/app/oracle/oradata/orcl/redo01a.log',
'/u01/app/oracle/oradata/orcl/redo01b.log') SIZE 50M REUSE,
GROUP 2 ('/u01/app/oracle/oradata/orcl/redo02a.log',
'/u01/app/oracle/oradata/orcl/redo02b.log') SIZE 50M REUSE,
GROUP 3 ('/u01/app/oracle/oradata/orcl/redo03a.log',
'/u01/app/oracle/oradata/orcl/redo03b.log') SIZE 50M REUSE;
}
===============================================================================================
The following variables are introduced for SET NEWNAME from 11gR2 :-
%b The file name remains same as the original. For example, if a datafile is named D:\oracle\oradata\matrix\test.dbf, then %b results in test.dbf.
%f Specifies the absolute file number of the datafile for which the new name is generated.
%I Specifies the DBID.
%N Specifies the tablespace name.
%U Specifies the following format: data-D-%d_id-%I_TS-%N_FNO-%f.
===============================================================================================
@allfiles
=========
select name from v$tempfile
union
select member from v$logfile
union
select name from v$datafile
union
select name from v$controlfile;
======================================
@licence: http://www.jobacle.nl/?p=583
select 'set newname for datafile '||file#||' to '''||replace(name,'/u01/app/oracle/oradata/orcl/','/data10/oradata/DEVDBNEW/')||''';' from v$datafile;
====================================
@dbfilecreation
col name for a50
select d.creation_time,d.name,t.name from v$datafile d,v$tablespace t where d.ts#=t.ts# order by 1;
================================
@pass prod & Uat -->oracle-->$4oraTB@storage
===============================
@asm
set wrap off
set lines 155 pages 9999
col "Group Name" for a6 Head "Group|Name"
col "Disk Name" for a10
col "State" for a10
col "Type" for a10 Head "Diskgroup|Redundancy"
col "Total GB" for 9,990 Head "Total|GB"
col "Free GB" for 9,990 Head "Free|GB"
col "Imbalance" for 99.9 Head "Percent|Imbalance"
col "Variance" for 99.9 Head "Percent|Disk Size|Variance"
col "MinFree" for 99.9 Head "Minimum|Percent|Free"
col "MaxFree" for 99.9 Head "Maximum|Percent|Free"
col "DiskCnt" for 9999 Head "Disk|Count"
prompt
prompt ASM Disk Groups
prompt ===============
SELECT g.group_number "Group"
, g.name "Group Name"
, g.state "State"
, g.type "Type"
, g.total_mb/1024 "Total GB"
, g.free_mb/1024 "Free GB"
, 100*(max((d.total_mb-d.free_mb)/d.total_mb)-min((d.total_mb-d.free_mb)/d.total_mb))/max((d.total_mb-d.free_mb)/d.total_mb) "Imbalance"
, 100*(max(d.total_mb)-min(d.total_mb))/max(d.total_mb) "Variance"
, 100*(min(d.free_mb/d.total_mb)) "MinFree"
, 100*(max(d.free_mb/d.total_mb)) "MaxFree"
, count(*) "DiskCnt"
FROM v$asm_disk d, v$asm_diskgroup g
WHERE d.group_number = g.group_number and
d.group_number <> 0 and
d.state = 'NORMAL' and
d.mount_status = 'CACHED'
GROUP BY g.group_number, g.name, g.state, g.type, g.total_mb, g.free_mb
ORDER BY 1;
prompt ASM Disks In Use
prompt ================
col "Group" for 999
col "Disk" for 999
col "Header" for a9
col "Mode" for a8
col "State" for a8
col "Created" for a10 Head "Added To|Diskgroup"
--col "Redundancy" for a10
--col "Failure Group" for a10 Head "Failure|Group"
col "Path" for a19
--col "ReadTime" for 999999990 Head "Read Time|seconds"
--col "WriteTime" for 999999990 Head "Write Time|seconds"
--col "BytesRead" for 999990.00 Head "GigaBytes|Read"
--col "BytesWrite" for 999990.00 Head "GigaBytes|Written"
col "SecsPerRead" for 9.000 Head "Seconds|PerRead"
col "SecsPerWrite" for 9.000 Head "Seconds|PerWrite"
select group_number "Group"
, disk_number "Disk"
, header_status "Header"
, mode_status "Mode"
, state "State"
, create_date "Created"
--, redundancy "Redundancy"
, total_mb/1024 "Total GB"
, free_mb/1024 "Free GB"
, name "Disk Name"
--, failgroup "Failure Group"
, path "Path"
--, read_time "ReadTime"
--, write_time "WriteTime"
--, bytes_read/1073741824 "BytesRead"
--, bytes_written/1073741824 "BytesWrite"
, read_time/reads "SecsPerRead"
, write_time/writes "SecsPerWrite"
from v$asm_disk_stat
where header_status not in ('FORMER','CANDIDATE')
order by group_number
, disk_number
/
Prompt File Types in Diskgroups
Prompt ========================
col "File Type" for a16
col "Block Size" for a5 Head "Block|Size"
col "Gb" for 9990.00
col "Files" for 99990
break on "Group Name" skip 1 nodup
select g.name "Group Name"
, f.TYPE "File Type"
, f.BLOCK_SIZE/1024||'k' "Block Size"
, f.STRIPED
, count(*) "Files"
, round(sum(f.BYTES)/(1024*1024*1024),2) "Gb"
from v$asm_file f,v$asm_diskgroup g
where f.group_number=g.group_number
group by g.name,f.TYPE,f.BLOCK_SIZE,f.STRIPED
order by 1,2;
clear break
prompt Instances currently accessing these diskgroups
prompt ==============================================
col "Instance" form a8
select c.group_number "Group"
, g.name "Group Name"
, c.instance_name "Instance"
from v$asm_client c
, v$asm_diskgroup g
where g.group_number=c.group_number
/
prompt Free ASM disks and their paths
prompt ==============================
col "Disk Size" form a9
select header_status "Header"
, mode_status "Mode"
, path "Path"
, lpad(round(os_mb/1024),7)||'Gb' "Disk Size"
from v$asm_disk
where header_status in ('FORMER','CANDIDATE')
order by path
/
prompt Current ASM disk operations
prompt ===========================
select *
from v$asm_operation
/
This is how some of the changes look
Added To Total Free Seconds Seconds
Group Disk Header Mode State Diskgroup GB GB Disk Name Path PerRead PerWrite
----- ---- --------- -------- -------- ---------- ------ ------ ---------- ------------------- ------- --------
1 0 MEMBER ONLINE NORMAL 20-FEB-09 89 88 FRA_0000 /dev/oracle/disk388 .004 .002
1 1 MEMBER ONLINE NORMAL 31-MAY-10 89 88 FRA_0001 /dev/oracle/disk260 .002 .002
1 2 MEMBER ONLINE NORMAL 31-MAY-10 89 88 FRA_0002 /dev/oracle/disk260 .007 .002
2 15 MEMBER ONLINE NORMAL 04-MAR-10 89 29 DATA_0015 /dev/oracle/disk203 .012 .023
2 16 MEMBER ONLINE NORMAL 04-MAR-10 89 29 DATA_0016 /dev/oracle/disk203 .012 .021
2 17 MEMBER ONLINE NORMAL 04-MAR-10 89 29 DATA_0017 /dev/oracle/disk203 .007 .026
2 27 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0027 /dev/oracle/disk260 .011 .023
2 28 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0028 /dev/oracle/disk259 .009 .020
2 38 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0038 /dev/oracle/disk190 .012 .025
2 39 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0039 /dev/oracle/disk189 .014 .015
2 40 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0040 /dev/oracle/disk260 .011 .024
2 41 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0041 /dev/oracle/disk260 .009 .022
2 42 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0042 /dev/oracle/disk260 .011 .018
2 43 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0043 /dev/oracle/disk260 .003 .026
2 44 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0044 /dev/oracle/disk260 .008 .019
2 45 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0045 /dev/oracle/disk193 .008 .018
2 46 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0046 /dev/oracle/disk192 .007 .024
2 47 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0047 /dev/oracle/disk191 .005 .022
2 48 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0048 /dev/oracle/disk190 .008 .021
2 49 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0049 /dev/oracle/disk189 .008 .026
2 50 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0050 /dev/oracle/disk261 .009 .030
56 rows selected.
File Types in Diskgroups
========================
Group Block
Name File Type Size STRIPE Files Gb
------ ---------------- ----- ------ ------ --------
DATA CONTROLFILE 16k FINE 1 0.01
DATAFILE 16k COARSE 404 2532.58
ONLINELOG 1k FINE 3 6.00
PARAMETERFILE 1k COARSE 1 0.00
TEMPFILE 16k COARSE 13 440.59
FRA AUTOBACKUP 16k COARSE 2 0.02
CONTROLFILE 16k FINE 1 0.01
ONLINELOG 1k FINE 3 6.00
@diskindiskgroup
SELECT SUBSTR(d.name,1,16) AS asmdisk, d.mount_status, d.state,dg.name AS diskgroup FROM V$ASM_DISKGROUP dg, V$ASM_DISK d WHERE dg.group_number = d.group_number;
@pathstatus
col PATH for a40
select PATH, HEADER_STATUS, MODE_STATUS, STATE from v$asm_disk;
/
@mountstate
select inst_id,path,mount_status,header_status from gv$asm_disk where path='/dev/rhdisk17';
=====
@digasm
/etc/init.d/oracleasm listdisks
out:DSK1
/etc/init.d/oracleasm querydisk -d dsk1
out:Disk "DSK1" is a valid ASM disk on device [8, 17]
ls -l /dev |grep 8|grep 17
out:brw-r----- 1 root disk 8, 17 Aug 10 13:05 sdb1
==========================================
@renamedatafileasm
RMAN> COPY DATAFILE '+DATA/sfms/datafile/users.290.930691959' to '+DATA/sfms/datafile/users.dbf';
RMAN> switch datafile '+DATA/sfms/datafile/users.290.930691959' to copy;
RMAN> recover datafile 5;
SQL> alter database datafile 5 online;
======================================
@isdynamicparameter
select name,isses_modifiable,issys_modifiable,isinstance_modifiable from v$parameter where name like '&memory_max_target'
==============================
@cpuinfo
nproc
/proc/cupinfo
/proc/meminfo
======================
@tophelp
l âTo display or to hide load average line
t âTo display or to hide task/cpu line
1 âTo display or hide all other CPUâs
m âto display or to hide RAM and SWAP details
s âTo change the time interval for updating top results(value is in secâs)
R âTo sort by PID number
u â Press u then username to get only that user process details
P âTo sort by CPU utilization
M âTo sort by RAM utilization
c âTo display or hide command full path
r âTo renice a process, press r then the PID no then the renice value to renice a process.
k âTo kill a process, press k then PID number then enter to kill a process
w âTo save the modified configuration permanently.
q âTo quit the top command.
h âfor getting help on top command
=======================================================
@shrink
set verify off
column file_name format a50 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings format 999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report
column value new_val blksize
select value from v$parameter where name = 'db_block_size';
/
select file_name,
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest,
ceil( blocks*&&blksize/1024/1024) currsize,
ceil( blocks*&&blksize/1024/1024) -
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savings
from dba_data_files a,
( select file_id, max(block_id+blocks-1) hwm
from dba_extents
group by file_id ) b
where a.file_id = b.file_id(+) order by savings desc
/
=================================================
@activeuserlist:
select username,account_status,default_tablespace from dba_users where username not in('XDB',
'TSMSYS',
'TRACESVR',
'SYSTEM',
'SYS',
'SCOTT',
'ADAMS',
'JONES',
'CLARK',
'BLAKE',
'PERFSTAT',
'OUTLN',
'ORDSYS',
'ORDPLUGINS',
'ORACLE_OCM',
'MDSYS',
'LBACSYS',
'HR',
'OE',
'SH',
'EXFSYS',
'DSSYS',
'DMSYS',
'DIP',
'DEMO',
'DBSNMP',
'CTXSYS',
'CSMIG',
'AWR_STAGE',
'AURORA$ORB$UNAUTHENTICATED',
'ANONYMOUS') and account_status='OPEN';
==============================================
@multiblockreadcount
The formula for calculating DB_FILE_MULTIBLOCK_READ_COUNT is:
db_file_multiblock_read_count = min(max I/O size/db_block_size , db_cache_size/(sessions * db_block_size))
Note: Max I/O size is platform-dependent and equal to 1MB for most platforms
========================================================================================================================
@large table
col owner format a15
col segment_name format a30
col segment_type format a15
col gb format 999,999,999
select owner
, segment_name
, segment_type
, gb
from (
select owner
, segment_name
, segment_type
, bytes / 1024 / 1024 / 1024 gb
from dba_segments
where segment_type = 'TABLE'
order by bytes desc
)
where rownum < 10;
/
===========================================================================================================
@setdate in linux
date -s "05JAN2017 11:38:00"
=====================================================================
@sysdbausers
select * from v$pwfile_users
=====================================================================
@multiplearchivedest
log_archive_duplex_dest='path'
======================
@centos
https://wiki.centos.org/HowTos/Oracle12onCentos7
==================================================
@workshop
http://dbaworkshop.blogspot.in/p/recovery-scenarios_5.html
=====================
@image
rman> list copy of database;
==========================
@checkpoint&scn
select sequence#,first_change#,next_change#,first_time from v$archived_log order by first_time;
========================================================
@lastscn
select sequence#,first_change#,next_change#,first_time,status from v$log where status='CURRENT';
==============================
@resetlogs
http://www.dba-oracle.com/t_rman_71_recover_previous_incarnation.htm
=============================
@restore not done; all files read only, offline, or already restored
sol:restore tablespace example force;
===============================
@incarnation
RMAN> list incarnation of database;
SQL> select incarnation#, resetlogs_change# from v$database_incarnation;
*****************
RMAN> shutdown immediate
RMAN> startup mount
RMAN> reset database to incarnation 2;
database reset to incarnation 2
===================================
RMAN> list archivelog all
===================================
@recreate controlfile creation
CREATE CONTROLFILE REUSE DATABASE "EWSTEST" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo1.log' SIZE 30M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo2.log' SIZE 30M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo3.log' SIZE 30M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/system.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/sysaux.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/undo.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/example01.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/example02.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/bil03.dbf'
CHARACTER SET US7ASCII
;
=====================================
@changedbname
CREATE CONTROLFILE REUSE SET DATABASE "EWSTEST" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo1.log' SIZE 30M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo2.log' SIZE 30M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo3.log' SIZE 30M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/system.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/sysaux.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/undo.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/example01.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/example02.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/bil03.dbf'
CHARACTER SET US7ASCII
;
==============================
@rmgrep
ls | grep chrome | xargs rm
==============================
@rowcount in table
select 'select count(*) from '||table_name||';' from dba_tables where owner = '&OWNER';
============or==================
DECLARE
val NUMBER;
BEGIN
FOR I IN (SELECT TABLE_NAME FROM USER_TABLES) LOOP
EXECUTE IMMEDIATE 'SELECT count(*) FROM ' || i.table_name INTO val;
DBMS_OUTPUT.PUT_LINE(i.table_name || ' ==> ' || val );
END LOOP;
END;
/
===============or======================
set pages 999;
col count format 999,999,999;
spool countlist.txt
select
table_name,
to_number(
extractvalue(
xmltype(
dbms_xmlgen.getxml('select count(*) c from '||table_name))
,'/ROWSET/ROW/C')) count
from
user_tables
order by
table_name;
==============================================================================
@setscn
SQL> shutdown immediate
SQL>startup mount
RMAN> run
{
set until scn=547891;
restore database;
recover database;
}
RMAN> alter database open resetlogs;
=========================
@minold
find . -mmin 3 #exactly 3 minutes old
find . -mmin +3 #more than 3 minutes old
find . -mmin -3 #less than 3 minutes old.
find . -mmin -360 #less than 6 hours old
=============================================
@sessionprivs
select * from session_privs;
=============================================
@restrictsysdba
SQLNET.AUTHENTICATION_SERVICES=(NONE)
============================================
@lastddl
SELECT LAST_DDL_TIME, TIMESTAMP
FROM USER_OBJECTS
WHERE OBJECT_TYPE = 'PROCEDURE'
AND OBJECT_NAME = 'MY_PROC';
=====================================
@wildel
ls -ltr o1_mf_1_2[5-7]*
rm -rf o1_mf_1_2[5-7]*
======================================
@maxtran SELECT ini_trans, max_trans from dba_tables WHERE table_name = 'TEST' ;
==================================================================================
@degreegather
BEGIN
SYS.DBMS_STATS.GATHER_TABLE_STATS (
OwnName => 'MK2'
,TabName => 'MIG_CASENAME'
,Degree => 4
,Cascade => TRUE
,No_Invalidate => FALSE);
END;
=========================================================
@arup
select sid, state, event
from v$session
where username = '&ARUP';
SID STATE EVENT
————— ————————————————— ————————————————————————————
2832 WAITED KNOWN TIME SQL*Net message from client
3346 WAITING enq: TX - row lock contention
----------------------------------------------------------------
col "Description" format a50
select sid,
decode(state, 'WAITING','Waiting',
'Working') state,
decode(state,
'WAITING',
'So far '||seconds_in_wait,
'Last waited '||
wait_time/100)||
' secs for '||event
"Description"
from v$session
where username = '&ARUP';
Output:
SID STATE Description
————— —————————— ———————————————————————————————————————————————————————
2832 Working Last waited 2029 secs for SQL*Net message from client
3346 Waiting So far 743 secs for enq: TX - row lock contention
4208 Waiting So far 5498 secs for SQL*Net message from client
----------------------------------------------------
select
blocking_session B_SID,
blocking_instance B_Inst
from v$session
where sid = &3346;
B_SID B_INST
—————— ———————
2832 1
----------------------------------------------------------
select row_wait_obj#,
row_wait_file#,
row_wait_block#,
row_wait_row#
from v$session
where sid = &3346;
ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW#
————————————— —————————————— ———————————————— ——————————————
241876 1024 2307623 0
-----------------------------------------------------------------------
select owner, object_type, object_name, data_object_id
from dba_objects
where object_id = &241876;
OWNER OBJECT_TYPE OBJECT_NAME DATA_OBJECT_ID
————— ———————————— ———————————— ——————————————
ARUP TABLE T1 241877
------------------------------------------------------------
select SID, osuser, machine, terminal, service_name,
logon_time, last_call_et
from v$session
where username = '&ARUP';
-------------------------------------------------------------
col username format a5
col program format a10
col state format a10
col last_call_et head 'Called|secs ago' format 999999
col seconds_in_wait head 'Waiting|for secs' format 999999
col event format a50
select sid, username, program,
decode(state, 'WAITING', 'Waiting',
'Working') state,
last_call_et, seconds_in_wait, event
from v$session
where machine = '&appsvr1'
-------------------------------------------------
select event
from v$session
where sid = &3011;
---------------------------------
@releaase
cat /etc/redhat-release
------------------------------------
@expirepassword
create user manoj identified by manoj1 password expire;
====================================================================
@nonasmtoasm
SQL> select name from v$database;
NAME
---------
YYAPRD
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------
/u04/oradata/YYAPRD/system01.dbf
/u04/oradata/YYAPRD/sysaux01.dbf
/u04/oradata/YYAPRD/undotbs01.dbf
/u04/oradata/YYAPRD/users01.dbf
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------
/u04/oradata/YYAPRD/temp01.dbf
SQL> col member form a50
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------
/u02/oradata/YYAPRD/redo01a.log
/u03/oradata/YYAPRD/redo01b.log
/u02/oradata/YYAPRD/redo02a.log
/u03/oradata/YYAPRD/redo02b.log
/u02/oradata/YYAPRD/redo03a.log
/u03/oradata/YYAPRD/redo03b.log
6 rows selected.
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
.3/dbs/spfileYYAPRD.ora
SQL> show parameter control_file
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/oradata/YYAPRD/control01.
ctl, /u02/oradata/YYAPRD/contr
ol02.ctl, /u03/oradata/YYAPRD/
control03.ctl
SQL> alter system set control_files='+DATA','+DATA1' scope=spfile;
System altered.
SQL> alter system set db_create_file_dest='+DATA' scope=spfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL>
SQL> startup nomount
ORACLE instance started.
Total System Global Area 2042241024 bytes
Fixed Size 1345968 bytes
Variable Size 838862416 bytes
Database Buffers 1191182336 bytes
Redo Buffers 10850304 bytes
[oracle@NODE1 11.2.0.3]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Apr 8 23:24:36 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: YYAPRD (not mounted)
RMAN> restore controlfile from '/u01/oradata/YYAPRD/control01.ctl';
Starting restore at 08-APR-13
using channel ORA_DISK_1
channel ORA_DISK_1: copied control file copy
output file name=+DATA/yyaprd/controlfile/current.256.812244559
output file name=+DATA1/yyaprd/controlfile/current.256.812244561
Finished restore at 08-APR-13
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> backup as copy database format '+DATA';
Starting backup at 08-APR-13
allocated channel: ORA_DISK_1
------
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DATA/yyaprd/datafile/system.257.812244625"
datafile 2 switched to datafile copy "+DATA/yyaprd/datafile/sysaux.259.812244827"
datafile 3 switched to datafile copy "+DATA/yyaprd/datafile/undotbs.260.812244881"
datafile 4 switched to datafile copy "+DATA/yyaprd/datafile/users.258.812244721"
RMAN> alter database open;
database opened
RMAN> exit
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------
+DATA/yyaprd/datafile/system.257.812244625
+DATA/yyaprd/datafile/sysaux.259.812244827
SQL> alter tablespace temp add tempfile size 500M;
Tablespace altered.
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------
/u04/oradata/YYAPRD/temp01.dbf
+DATA/yyaprd/tempfile/temp.263.812245559
SQL> alter database tempfile '/u04/oradata/YYAPRD/temp01.dbf' drop including datafiles;
Database altered.
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------
+DATA/yyaprd/tempfile/temp.263.812245559
SQL> alter database add logfile group 4 ('+DATA','+DATA1') size 10M;
Database altered.
SQL> alter database add logfile group 5 ('+DATA','+DATA1') size 10M;
Database altered.
SQL> alter database add logfile group 6 ('+DATA','+DATA1') size 10M;
Database altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ----------- ------------ -----------
1 1 115 10485760 512 2 NO INACTIVE 244292 08-APR-2013 268271 08-APR-2013
2 1 116 10485760 512 2 NO INACTIVE 268271 08-APR-2013 271180 08-APR-2013
3 1 117 10485760 512 2 NO CURRENT 271180 08-APR-2013 2.8147E+14
4 1 0 10485760 512 2 YES UNUSED 0 0
5 1 0 10485760 512 2 YES UNUSED 0 0
6 1 0 10485760 512 2 YES UNUSED 0 0
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ----------- ------------ -----------
3 1 117 10485760 512 2 NO INACTIVE 271180 08-APR-2013 274462 08-APR-2013
4 1 118 10485760 512 2 NO INACTIVE 274462 08-APR-2013 274465 08-APR-2013
5 1 119 10485760 512 2 NO CURRENT 274465 08-APR-2013 2.8147E+14
6 1 0 10485760 512 2 YES UNUSED 0 0
SQL> alter database drop logfile group 3;
Database altered.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------
+DATA/yyaprd/onlinelog/group_4.264.812246035
+DATA1/yyaprd/onlinelog/group_4.257.812246037
+DATA/yyaprd/onlinelog/group_5.265.812246095
+DATA1/yyaprd/onlinelog/group_5.258.812246097
======================================================================
@asmtononasm
==================================================================================
@BIT
getconf LONG_BIT
==================================
@GUI
yum install xorg-x11-apps.x86_64
=====================================
@deinstall
./runInstaller -deinstall -home /u01/app/oracle/product/12.1.0/dbhome_1/
---------------------
$ORACLE_HOME/oui/bin/runInstaller
================================================================================
@newlycreated
SELECT created,object_name
FROM dba_objects
WHERE object_name like '%EWU_USE%'
AND owner = 'EWSADMIN'
AND object_type = 'TABLE' order by 1;
====================================================
@perfstatdel
Deleting certain SNAP IDs
SQL> @?/rdbms/admin/sppurge.sql
Delete all snapshots
SQL> @?/rdbms/admin/sptrunc.sql
Delete the perfstat schema
SQL> @?/rdbms/admin/spdrop.sql
Delete a timerange
SQL> exec statspack.purge (i_begin_date=>to_date('01-JAN-2012', 'DD-MON-YYYY'),i_end_date =>to_date('02-JAN-2012', 'DD-MON-YYYY'),i_extended_purge=>TRUE);
=================================or===========================================
select SNAP_ID,to_char(SNAP_TIME,'dd-mon-yyyy hh24:mi') from stats$snapshot;
delete from stats$snapshot where SNAP_TIME < sysdate - (1/(24*60)) ;
=============================================================================================================================================================================================================
@resetsamepassword:
select password from sys.user$ where name='&QWERTY';
PASSWORD
-----------------------------
87FE2DD49B2882B2
alter user QWERTY identified by values '87FE2DD49B2882B2';
=======================================================================
@windowsprofile:
set PATH=%ORACLE_HOME%\perl\bin;%PATH%
path=%path%;E:\app\Administrator\product\11.2.0\dbhome_1\OPatch
===============================================
@list of directories
ls -ltr | grep "^d"
=====================================================
@7of7zipfile
1-Db
2-Db
3-Grid
4-Client
5-Oracle Gateways
6-Oracle Examples
7-Deinstall
================================================================================
@indexsstatus
select OWNER,INDEX_NAME,owner,status,table_name from dba_indexes where owner like %PMD%';
SELECT index_name,status,Blevel,LEAF_BLOCKS,DISTINCT_KEYS,NUM_ROWS,CLUSTERING_FACTOR FROM DBA_INDEXES WHERE index_name = 'ORGANIZED_IDX';
===================================================================================================================================
@tabstats
EXEC DBMS_STATS.gather_table_stats('PMD', 'VW_DAG_0',cascade => true,estimate_percent => dbms_stats.auto_sample_size);
============================================================================================
@redomultiplexing
alter database add logfile member '/u03/app/oracle/oradata/orcl/redo/redo01_b.log' to group 1;
ALTER DATABASE ADD LOGFILE group 7 ('/u02/oradata/P38/redo07a.log', '/u03/oradata/P38/redo07b.log') size 100m;
http://www.oracledistilled.com/oracle-database/administration/multiplexing-the-redo-log-files/ --multiplexing
alter database add logfile member '/u03/app/oracle/oradata/orcl/redo/redo01_b.log' to group 1;
https://muneer2908.wordpress.com/2011/01/27/how-to-change-the-redo-log-file-size-in-oracle-database/ --increase size
======================================
@nls
SELECT * FROM NLS_DATABASE_PARAMETERS;
select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
========================================
@cachefusion:
@sess_stats.sql
SELECT sn.name,
st.value
FROM v$statname sn
JOIN v$sesstat st
ON sn.STATISTIC#=st.STATISTIC#
WHERE sn.name IN ('session logical reads','physical reads','gc cr block received','gc current block received')
AND st.sid=SYS_CONTEXT('USERENV','SID')
ORDER BY sn.STATISTIC#;
-------------------------------------------------------
@tracemysession
declare
v_sid number;
v_serial number;
begin
select sid,serial# into v_sid,v_serial from v$session
where sid=SYS_CONTEXT('USERENV','SID');
dbms_monitor.session_trace_enable(v_sid,v_serial,TRUE,TRUE);
end;
-----------------------------
@mytracefile
select
pm.value ||'/diag/rdbms/'||d.name||'/'||i.instance_name||
'/trace/'||i.instance_name||'_ora_'||pr.spid||'.trc' as trace_file
from
(select
p.spid
from
v$session s
join
v$process p
on s.paddr=p.addr
where
s.sid=SYS_CONTEXT('USERENV','SID')) pr
cross join
(select
value
from v$parameter
where name='diagnostic_dest') pm
cross join
(select instance_name
from v$instance) i
cross join
(select
lower(name) as name
from v$database) d;
-----------------------------------------------------------------------
@mysid
select SYS_CONTEXT('USERENV','SID') from dual;
select SYS_CONTEXT('USERENV','CURRENT_USER') from dual;
@traceenable
exec DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(sid,serial#,true);
------------------------------------------------------------------
@optsession
@opttransaction
session= (1.1 * PROCESSES) + 5
transaction= (1.1 * SESSIONS)
---------------------------------------------------------------------------
@service :A service is a logical grouping of sessions performing similar kind of work.
$srvctl add service -s test -d hrms -r hrms1 -a hrms2 -P basic r=prefer
#to see status of specific service
$srvctl status service -s test -d hrms
#to delete service
$srvctl remove service -s test -d hrms
--------------
@modify service
srvctl modify service -d RTGS -s myser -n -i RTGS1,RTGS2
srvctl add service -d testing -s testsrv -r testing2,testing1
-----------------------------------------
select service_name,inst_id,count(*)
from gv$session
group by service_name,inst_id
order by service_name,inst_id;
----------------
select name from v$services
-----------
@findvip
olsnodes -i
--------
@clientsysdba
sqlplus sys/SYS123@OCAS as sysdba
-------------------------------------------
@adrci
purge -age 43200 (older then one month)
adrci>show alert -tail -f
adrci>show home
adrci>set homepath diag/rdbms/orclbi/orclbi2
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@pt
select sid,event,p1,p2,p3 from v$session_wait where event='db file sequential read';
select owner,segment_name,segment_type from dba_extents where file_id= 21 and 969567 between block_id and block_id + blocks -1;
-----------------------------------------------------------------------------------
@blkid
----------------------------------------------------------------------------------
@sysauxpurge
set linesize 120
set pagesize 100
COLUMN "Item" FORMAT A25
COLUMN "Space Used (GB)" FORMAT 999.99
COLUMN "Schema" FORMAT A25
COLUMN "Move Procedure" FORMAT A40
SELECT occupant_name "Item",
space_usage_kbytes/1048576 "Space Used (GB)",
schema_name "Schema",
move_procedure "Move Procedure"
FROM v$sysaux_occupants
ORDER BY 1
/
--How long old stats are kept
1
select dbms_stats.get_stats_history_retention from dual;
--Set retention of old stats to 10 days
1
exec dbms_stats.alter_stats_history_retention(10);
--Purge stats older than 10 days (best to do this in stages if there is a lot of data (sysdate-30,sydate-25 etc)
1
exec DBMS_STATS.PURGE_STATS(SYSDATE-10);
--Show available stats that have not been purged
1
select dbms_stats.get_stats_history_availability from dual;
--Show how big the tables are and rebuild after stats have been purged
https://jhdba.wordpress.com/2009/05/19/purging-statistics-from-the-sysaux-tablespace/
--------------------------------------------------------------
@html
set markup html on
set pagesize 30
spool processes_sessions.html
select
p.username "V$PROCESS - OS USERNAME",
p.terminal,
p.program,
s.username "V$SESSION - USERNAME",
s.command,
s.status,
to_char(s.LOGON_TIME,'DD-MON-YY HH24:MI:SS') "LOGON TIME",
s.LAST_CALL_ET/60 "LAST_CALL TIME",
s.server,
s.process,
s.machine,
s.port,
s.terminal,
s.program,
s.sid,
s.serial#,
p.spid
FROM v$session s,v$process p
WHERE p.addr=s.paddr
order by p.background desc;
spool off
exit;
---------------------------------------------------------------------------------------------------------
@audit(schema)
https://oracle-base.com/articles/10g/auditing-10gr2
SHOW PARAMETER AUDIT
AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }
ALTER SYSTEM SET audit_trail=db SCOPE=SPFILE; bounce db
CONNECT sys/password AS SYSDBA
--pri
AUDIT ALL BY SCOTT BY ACCESS;
AUDIT SELECT TABLE, UPDATE TABLE, INSERT TABLE, DELETE TABLE BY SCOTT BY ACCESS;
AUDIT EXECUTE PROCEDURE BY SCOTT BY ACCESS;
---dictionary tab info
SELECT view_name FROM dba_views WHERE view_name LIKE 'DBA%AUDIT%' ORDER BY view_name;
---check audit
COLUMN username FORMAT A10
COLUMN owner FORMAT A10
COLUMN obj_name FORMAT A10
COLUMN extended_timestamp FORMAT A35
SELECT username,
extended_timestamp,
owner,
obj_name,
action_name
FROM dba_audit_trail
WHERE owner = 'AUDIT_TEST'
ORDER BY timestamp;
----------------------------
@audithousekeeping
https://oracle-base.com/articles/11g/auditing-enhancements-11gr2 --
--------------------------------------------------------------------------------------------------------------
@mastertableissue
SET lines 150
COL owner_name FORMAT a10
COL job_name FORMAT a20
COL operation FORMAT a10
SELECT owner_name, job_name, operation
FROM dba_datapump_jobs where state='NOT RUNNING' and attached_sessions=0;
set head off
SELECT 'drop table ' || owner_name || '.' || job_name || ';'
FROM dba_datapump_jobs WHERE state='NOT RUNNING' and attached_sessions=0;
--------------------------------------------------------------------------------------------------------------
@HOW TO GENERATE ARCHIVE LOG FROM ASM TO LOCAL DISK
SQL> CREATE or replace DIRECTORY archdir AS '+ARCH/mscdxb/arch/';SQL> Directory created.SQL> CREATE or replace DIRECTORY tempdir AS '/u01/starch/';Directory created.
spool archmove.sql
set linesize 250
set pagesize 250
select 'EXECUTE DBMS_FILE_TRANSFER.COPY_FILE(''ARCHDIR'','''||
SUBSTR(NAME,INSTR(NAME,'/',-1) + 1) ||''',''TEMPDIR'','''||
SUBSTR(NAME,INSTR(NAME,'/',-1) + 1)||''');'
FROM V$ARCHIVED_LOG where name is not null;
spool off;
exit;
----------------------------------------------------------------------------------------------------------------
@aixinstallation:
kernal:
# lsattr -E -l sys0 -a maxuproc
maxuproc 128 Maximum number of PROCESSES allowed per user True
# smit chgsys ( Change / Show Characteristics of Operating System)
#chdev -l sys0 -a maxuproc=1000
# getconf -a
AIO_LISTIO_MAX: 4096
AIO_MAX: 4096
AIO_PRIO_DELTA_MAX: 0
ARG_MAX: 24576
# bootinfo -K (64 or 32)
# /usr/bin/getconf HARDWARE_BITMODE --(To determine if the system architecture)
# /usr/sbin/lsps -a (To determine swap)
# /usr/sbin/lsattr -E -l sys0 -a realmem (To determine the RAM size)
----------------------------------------------------------------------------
ERROR at line 1:
ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: at "SYS.DBMS_STATS", line 24281
ORA-06512: at "SYS.DBMS_STATS", line 24332
ORA-06512: at line 1
------------------------ sol-------------------
exec dbms_stats.unlock_table_stats('EWSADMIN', 'EWN_COMP_MODEL_SCORE');
-------------------------------------------------------------------------------
@dbfutilization
SET PAUSE ON
SET PAUSE 'Press Return to Continue'
SET PAGESIZE 60
SET LINESIZE 300
COLUMN "Tablespace Name" FORMAT A20
COLUMN "File Name" FORMAT A80
SELECT Substr(df.tablespace_name,1,20) "Tablespace Name",
Substr(df.file_name,1,80) "File Name",
Round(df.bytes/1024/1024,0) "Size (M)",
decode(e.used_bytes,NULL,0,Round(e.used_bytes/1024/1024,0)) "Used (M)",
decode(f.free_bytes,NULL,0,Round(f.free_bytes/1024/1024,0)) "Free (M)",
decode(e.used_bytes,NULL,0,Round((e.used_bytes/df.bytes)*100,0)) "% Used"
FROM DBA_DATA_FILES DF,
(SELECT file_id,
sum(bytes) used_bytes
FROM dba_extents
GROUP by file_id) E,
(SELECT Max(bytes) free_bytes,
file_id
FROM dba_free_space
GROUP BY file_id) f
WHERE e.file_id (+) = df.file_id
AND df.file_id = f.file_id (+)
ORDER BY df.tablespace_name,
df.file_name
/
-------------------------------------------------------------------------------------------------------------
@allocaterestore:
run {
allocate channel ch1 device type 'sbt';
allocate channel ch2 device type 'sbt';
allocate channel ch3 device type 'sbt';
send 'NB_ORA_POLICY=DB_rman_full,NB_ORA_SERV=master-bk';
restore database;
release channel ch1;
release channel ch2;
release channel ch3;
}
----------------------asm to nonasm-----------
run
{
set newname for datafile 1 to '/data/emrep/oradata/EMREP/datafile/system.283.903890003';
set newname for datafile 2 to '/data/emrep/oradata/EMREP/datafile/sysaux.278.903889977';
set newname for datafile 3 to '/data/emrep/oradata/EMREP/datafile/undotbs1.282.903890003';
set newname for datafile 4 to '/data/emrep/oradata/EMREP/datafile/users.285.903890027';
set newname for datafile 5 to '/data/emrep/oradata/EMREP/datafile/mgmt_ecm_depot_ts.281.903890003';
set newname for datafile 6 to '/data/emrep/oradata/EMREP/datafile/mgmt_tablespace.284.903890027';
set newname for datafile 7 to '/data/emrep/oradata/EMREP/datafile/mgmt_ad4j_ts.280.903889977';
set newname for datafile 8 to '/data/emrep/oradata/EMREP/datafile/rman_catalog.279.903889977';
set newname for datafile 9 to '/data/emrep/oradata/EMREP/datafile/mgmt_tablespace.499.916503681';
SET NEWNAME FOR TEMPFILE 1 TO '/data/emrep/oradata/EMREP/datafile/temp01.dbf';
set until scn 658140403;
DUPLICATE TARGET DATABASE TO EMREP
NOFILENAMECHECK
DB_FILE_NAME_CONVERT '+DATA','/data/emrep/oradata/EMREP/datafile'
LOGFILE
GROUP 1 ('/data/emrep/onlinelog/EM_GRIDP03/redo01a.log','/data/emrep/onlinelog/EM_GRIDP03/redo01b.log') SIZE 600M REUSE,
GROUP 2 ('/data/emrep/onlinelog/EM_GRIDP03/redo02a.log','/data/emrep/onlinelog/EM_GRIDP03/redo02b.log') SIZE 600M REUSE
SPFILE
SET LOG_FILE_NAME_CONVERT '+FRA/','/data/emrep/onlinelog', '+DATA','/data/emrep/onlinelog'
SET AUDIT_FILE_DEST '/app/oracle/admin/EMREP/adump'
SET CONTROL_FILES '/data/emrep/oradata/EMREP/controlfile/control01.ctl'
SET DB_RECOVERY_FILE_DEST '/data/emrep/FRA'
SET DB_CREATE_FILE_DEST '/data/emrep/oradata/EMREP/datafile/'
SET DIAGNOSTIC_DEST '/app/oracle/admin';
}
-----------------------------------------------------------------
@bandwidth
Let us assume the redo rate is a 500 KB/sec.
Required bandwidth = ((Redo rate bytes per sec. / 0.75) * 8) / 1,000,000 = bandwidth in Mbps Required bandwidth = ((512000/0.75) * 8) /1,000,000 Required bandwidth = 5.46 Mbps
Also you can find the Minimum and Maximum Bandwidth limit using the below query,
SELECT DT,SUM(RB*8/3600000000*1.3) TOTAL_Mbps_REQ_FOR_A_DAY,MIN(RB*8/3600000000*1.3) MIN_Mbps_REQ_FOR_AN_HOUR,MAX(RB*8/3600000000*1.3) MAX_Mbps_REQ_FOR_AN_HOUR ,AVG(RB*8/3600000000*1.3) AVG_Mbps_REQ_FOR_AN_HOURFROM(SELECT TRUNC (COMPLETION_TIME) DT,TO_CHAR (COMPLETION_TIME,'HH24') HH,SUM(BLOCKS*BLOCK_SIZE) RBFROMV$ARCHIVED_LOGWHERE COMPLETION_TIME > SYSDATE-5AND DEST_ID=1GROUP BY TRUNC(COMPLETION_TIME),TO_CHAR (COMPLETION_TIME, 'HH24'))GROUP BY DT;
Reference:
How To Calculate The Required Network Bandwidth Transfer Of Redo In Data Guard Environments (Doc ID 736755.1)
As an Alternative you can also get the 'Redo rate bytes per sec.' from V$SYSMETRIC_HISTORY, eg.
SQL> select *
from v$sysmetric_history where metric_name = 'Redo Generated Per Sec';
------------------------------------------------------------------------------------
@indexonwhichcolumn
SELECT * FROM dba_ind_columns t where t.table_owner='EWSADMIN'
------------------------------------------------------------------------------------
@flashback
SELECT FLASHBACK_ON FROM V$DATABASE;
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320; -- 3 days default is 1440
ALTER DATABASE FLASHBACK ON;
-----------------------------------------------------------------------------
@$ORACLE_HOME/rdbms/admin/sqltrpt.sql
--------------------------------
@compilepackage ALTER PACKAGE UTL_FILE COMPILE BODY;
--------------------------------
@changehome
https://pierreforstmanndotcom.wordpress.com/2014/09/30/how-to-move-or-rename-oracle-home/
---------------------------------------------
@telnetexit
ctl+]
telnet > quit
*********************************************************************************************************************
@spusteps:http://ermanarslan.blogspot.in/2016/11/rdbms-applying-db-psu-and-ojvm-psu-to.html
*Shutdown listener and Databases running from target ORACLE HOME
*Add opatch to the path ($PATH env variable)
export PATH=$PATH:$ORACLE_HOME/OPatch
--export PATH=$ORACLE_HOME/OPatch:$PATH
opatch lsinventory -detail
opatch lsinventory
opatch version
/home/oracle/oracle_11204/psu/24006111
*PREREQ & CONFLICT CHECK
[oracle@coinactdbtst 24006111]$ opatch prereq CheckConflictAmongPatchesWithDetail -phBaseDir /home/oracle/25879656
*WE APPLY PSU using Opatch apply
export PATH=$PATH:$ORACLE_HOME/OPatch
csd /home/oracle/oracle_11204/psu/24006111
opatch apply
*********rollback*********
opatch rollback -id 15941858
***********@rpatch***************
export CRS_ORA_HOME=/opt/oracrs/oragrid/11.2.0.4
export ORACLE_HOME=/opt/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/Opatch
cd /orastage/PSU/PSU_PATCH_OCT_2016
NPRD:oracle@ausyd23db05cn01:>ls -trl
total 798464
-rw-r--r-- 1 oracle oinstall 105489166 Nov 15 16:42 p24006111_112040_Linux-x86-64-RDBMS.zip
-rw-r--r-- 1 oracle oinstall 712035213 Nov 15 16:51 p24436338_112040_Linux-x86-64-GI.zip
drwxrwxr-x 3 oracle oinstall 3896 Nov 17 18:09 RDBMS_PSU/
drwxrwxr-x 3 oracle oinstall 3896 Nov 17 18:09 GI_PSU/
unzip p24006111_112040_Linux-x86-64-RDBMS.zip -d RDBMS_PSU
unzip p24436338_112040_Linux-x86-64-GI.zip -d GI_PSU
-- Stop agents on all nodes
cd /opt/oracle/product/agent/core/12.1.0.5.0/bin/
./emctl status agent
./emctl stop agent
-- unix Team to stop crs service, only node one
$CRS_ORA_HOME/bin/crsctl stop crs
export CRS_ORA_HOME=/opt/oracrs/oragrid/11.2.0.4
export ORACLE_HOME=/opt/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/Opatch
/opt/oracrs/oragrid/11.2.0.4/bin/crsctl stop crs
-- crosscheck above command
$lsof |grep /opt/oracle/product/1120
-----------------------------------------------
cd $CRS_ORA_HOME
>> from node1 and all other nodes
cd /opt/oracrs/oragrid/11.2.0.4
tar -cvpf /ora_conv/ora_node1_bak_11.2.0.4/gi_bkp_n1.tar ./
cd $ORACLE_HOME
>> from node1 and all other nodes
cd /opt/oracle/product/11.2.0.4
tar -cvpf /ora_conv/ora_node1_bak_11.2.0.4/db_bkp_n1.tar ./
$** As Oracle user **
cd /opt/oracle/oraInventory
>> from node1 and all other nodes
cd /opt/oracle/oraInventory
tar -cvpf /ora_conv/ora_node1_bak_11.2.0.4/inv_bkp_n1.tar ./
-- crontab backup and comment all jobs on both nodes..
<<flag-1>>
/ora_conv/ora_node1_bak_11.2.0.4
cd /opt/oracrs/oragrid/11.2.0.4
tar -cvpf /ora_conv/oradata/node1_bak/gi_bkp_n1.tar ./
cd /opt/oracle/product/11.2.0.4
tar -cvpf /ora_conv/oradata/node1_bak/db_bkp_n1.tar ./
cd /opt/oracle/oraInventory
tar -cvpf /ora_conv/oradata/node1_bak/inv_bkp_n1.tar ./
-- unix Team to start crs service.
$CRS_ORA_HOME/bin/crsctl start crs
/opt/oracrs/oragrid/11.2.0.4/bin/crsctl start crs
export CRS_ORA_HOME=/opt/oracrs/oragrid/11.2.0.4
export ORACLE_HOME=/opt/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/Opatch
/opt/oracrs/oragrid/11.2.0.4/bin/crsctl start crs
-- Make OCM Configuration (make response file)
cd $CRS_ORA_HOME/OPatch/ocm/bin/
./emocmrsp
-- Validation of Oracle Inventory / If the below command succeeds, we are good /
$CRS_ORA_HOME/OPatch/opatch lsinventory -detail -oh $CRS_ORA_HOME
$ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME
-- ** As Root user ** / might not required in rare case /
$ORACLE_HOME/crs/install/rootcrs.pl -unlock
$ORACLE_HOME/crs/install/roothas.pl -unlock
opatch lsinventory | grep 25476126
**************** GRID and DATABASE Home Patching ****************
25476126
--- Apply auto patch on GRID and RDBMS in one go
$CRS_ORA_HOME/OPatch/opatch auto /orastage/PSU/PSU_PATCH_APR_2017/GI_PSU/25476126 -ocmrf $CRS_ORA_HOME/OPatch/ocm/bin/ocm.rsp
/opt/oracrs/oragrid/11.2.0.4
export CRS_ORA_HOME=/opt/oracrs/oragrid/11.2.0.4
export ORACLE_HOME=/opt/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/Opatch
/opt/oracrs/oragrid/11.2.0.4/OPatch/opatch auto /orastage/PSU/PSU_PATCH_APR_2017/GI_PSU/25476126 -ocmrf /opt/oracrs/oragrid/11.2.0.4/OPatch/ocm/bin/ocm.rsp
{after sucess of this directly jump to > * DATABASE Patching }
-- Apply patch on GRID (make below comand in a file, and ask unix team to execute)
$CRS_ORA_HOME/OPatch/opatch auto <patch_location>/GI_PSU -oh $CRS_ORA_HOME -ocmrf $CRS_ORA_HOME/OPatch/ocm/bin/ocm.rsp
**************** DATABASE Patching ****************
This need to be done, on all database either of the nodes.
vi db_patch_apply.sql
set lines 132 pages 300
set serveroutput on
set sqlbl on
exec dbms_output.put_line('***PSU Status before PATCH ***');
select name from v$database;
col ACTION_TIME for a30
col COMMENTS for a30
col BUNDLE_SERIES for a10
select ACTION_TIME, comments, version, bundle_series
from sys.registry$history
where bundle_series = 'PSU'
order by action_time desc
;
@?/rdbms/admin/catbundle.sql psu apply
@?/rdbms/admin/utlrp.sql
exec dbms_output.put_line('***PSU Status after PATCH ***');
set lines 132 pages 300
col ACTION_TIME for a30
col COMMENTS for a30
col BUNDLE_SERIES for a10
select ACTION_TIME, comments, version, bundle_series
from sys.registry$history
where bundle_series = 'PSU'
order by action_time desc
;
exit
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
==========================
export ORACLE_SID=DSPCAN101
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLPSYD201
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD121
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDCAN021
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDCAN051
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=DSDCAN021
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDCAN031
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD111
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=DSDCAN031
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD131
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=CTLGDB1
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDCAN041
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD091
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=DSDCAN051
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=DSDCAN041
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD081
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
***********************************************************************************************************************************
set lines 200
set pages 200
set time on
col ACTION_TIME for a35
col ACTION for a12
col NAMESPACE for a12
col VERSION for a12
col COMMENTS for a30
col BUNDLE_SERIES for a10
select * from registry$history;
-------------------------------------------------------------------------------
@afterupgraderemove
1.export old home
export ORACLE_HOME=$OLD_GI_HOME
2.$OLD_GI_HOME/oui/bin/runInstaller -detachHome -silent ORACLE_HOME=$OLD_GI_HOME
--/home/oracle/app/oracle/product/11.2.0/dbhome/oui/bin/runInstaller -detachHome -silent ORACLE_HOME=$ORACLE_HOME
## confirm $OLD_HOME is removed from central inventory:
$OLD_GI_HOME/OPatch/opatch lsinventory -all
## remove files in OLD_HOME manually:
/bin/rm -rf $OLD_GI_HOME
unset ORACLE_HOME
-------------------------------------------------------------------------------
@objnameindatafile
How can we check in which datafile my object resides?
select a.segment_name,a.file_id,b.file_name Datafile_name from dba_extents a,dba_data_files b where a.file_id=b.file_id and a.segment_name='YOUR OBJECT NAME';
How can we check what objects are there in a datafile?
select a.segment_name,a.file_id,b.file_name Datafile_name from dba_extents a,dba_data_files b where a.file_id=b.file_id and b.file_name=<your datafile name with path>;
--------------------------------------------------------------------------------------
@getpassword
select
'alter user "'||username||'" identified by values '''||extract(xmltype(dbms_metadata.get_xml('USER',username)),'//USER_T/PASSWORD/text()').getStringVal()||''';' old_password
from
dba_users
where
username = '&WATADMIN';
----------------------------------------------------------------------------------------------------
@prelim
sqlplus -prelim / as sysdba
oradebug setmypid
oradebug unlimit;
oradebug dump systemstate 266
...wait for 2 mins
oradebug dump systemstate 266
oradebug tracefile_name <=== To check the dump file location
exit
-------------------------------------------------------------------------------------------------------------------------------
@oradim
oradim -new -sid ORCL -syspwd mgrorcl -startmode auto -pfile C:\app\mgrvinod\product\11.2.0\dbhome_1\dbs\init_orcl.ora;
-------------------------
@CSSD won’t start automatically
[oracle@Linux4 ~]$ crsctl stat res ora.cssd -p
[oracle@Linux4 ~]$ crsctl modify resource "ora.cssd" -attr "AUTO_START=always"
[oracle@Linux4 ~]$ crsctl modify resource "ora.asm" -attr "AUTO_START=always"
@end--------------------------
*************************************************
https://dbdwell.wordpress.com/category/rac/
***************************************************
http://select-star-from.blogspot.in/2013/07/oracle-dba-interview-questions-answers_24.html
***************************************************
http://oracle4ryou.blogspot.in/2013/11/oracle-11g-rac-interview-question-and.html
***************************************************
http://www.freeoraclehelp.com/2011/12/scan-setup-for-oracle-11g-release211gr2.html
***************************************************
http://ranjeetwipro.blogspot.in/2011/03/rolling-patch-opatch-support-for-rac.html
***************************************************
https://anargodjaev.wordpress.com/2015/03/10/ra-01503-ora-01189-when-trying-to-recreate-controlfile/
***************************************************
http://dbarohit.blogspot.in/2012/12/why-oracle-recommends-voting-disks-in_25.html
***************************************************
https://oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux
***************************************************
http://expertoracle.com/2014/04/01/data-guard-broker-basics/
***************************************************
http://oracleinstance.blogspot.in/2012/01/create-single-instance-standby-database.html
***************************************************
http://www.oracleracexpert.com/2014/01/optimal-redo-logfile-size-in-oracle.html
***************************************************
https://martincarstenbach.wordpress.com/2010/04/30/applying-psu-11-2-0-1-1-to-grid-infrastructure-rdbms-2/
***************************************************
https://nehakohlidba.wordpress.com/2015/01/18/database-upgrade-11-2-0-1-to-11-2-0-4-on-sap-using-mopatch-on-windows/
***************************************************
https://sadanandhudge.wordpress.com/2015/11/11/database-upgrade-from-11-2-0-1-to-11-2-0-4-on-linux-64bit/
***************************************************
http://www.dba-oracle.com/t_goldengate_upgrade_to_oracle12c.htm
***************************************************
http://dbaoracletips.blogspot.in/2014/02/owb-component-not-upgraded-to-11204.html
***************************************************
https://oracle-base.com/articles/11g/data-guard-setup-using-broker-11gr2
***************************************************
https://sachinichake.wordpress.com/2013/05/10/frequently-asked-questions/
***************************************************
http://expertoracle.com/2014/03/05/rman-recovery-scenarios-related-to-database/
***************************************************
http://www.dbas-oracle.com/2013/05/10-steps-to-analyze-awr-report-in-oracle.html
***************************************************
http://dbaquest.blogspot.in/2014/02/rac-11gr2-clusterware-startup-sequence.html
***************************************************
http://karandba.blogspot.in/2014/09/12c-sql-plan-management-spm.html
***************************************************
https://mewithoracle.wordpress.com/2012/05/02/recovering-through-an-added-datafile/
***************************************************
https://orainternals.wordpress.com/tag/ohasd-startup/
****************************************************
http://www.oraclebuffer.com/goldengate/understanding-oracle-goldengate-architecture/
****************************************************
https://dbastar.wordpress.com/2015/10/29/applying-psu-oct-2015-patch-11-2-0-4-8-to-a-two-node-rac/
****************************************************
https://docs.oracle.com/cd/B16240_01/doc/em.102/e15294/rac.htm
****************************************************
http://anotherdatabaseblog.blogspot.in/2011/10/crerating-ocm-response-file-for-gi-home.html
****************************************************
https://dbdwell.wordpress.com/category/rac/
***************************************************
https://aprakash.wordpress.com/2012/01/19/moving-aud-table-to-another-tablespace-in-11gr2/
****************************************************
https://hoopercharles.wordpress.com/2009/12/01/sql-plan_hash_value-changes-for-the-same-sql-statement/
****************************************************
https://web.stanford.edu/dept/itss/docs/oracle/10gR2/backup.102/b14191/rcmtspit001.htm
****************************************************
https://stackoverflow.com/questions/16011976/hash-value-for-sql-statement
****************************************************
https://oracle-dba-help.blogspot.in/2017/04/oracle-asm-interview-questions.html?m=1
****************************************************
http://oracle-dba-help.blogspot.in/search/label/Frequently%20Asked
****************************************************
https://blogshavail.wordpress.com/2012/03/03/remove-previous-gicrsasm-home-after-upgrade/
****************************************************
https://community.oracle.com/docs/DOC-1012784
****************************************************
http://enterprise-manager.blogspot.in/2011/04/favourite-questions-and-answers-from-em.html
****************************************************
http://blog.oracle48.nl/oracle-database-undo-space-explained/
****************************************************
http://vetriveldba.blogspot.in/2017/03/how-to-calculate-network-bandwidth-for.html
*****************************************************
http://searchoracle.techtarget.com/answer/26-performance-tuning-questions-and-solutions-1-10
*****************************************************
http://dba-expert.blogspot.in/2012/02/cross-platform-migration-using-rman.html
******************************************************
https://oracleracdba1.wordpress.com/2014/07/14/how-to-clone-oracle-binaries/
******************************************************
https://oracleracdba1.wordpress.com/category/oracle-rac/asm/
******************************************************
http://www.dba-oracle.com/t_data_pump_disable_archive_logging.htm
******************************************************
http://subudba.blogspot.in/search/label/Performance%20Tunning
***********************************************************
http://oukc.oracle.com/static09/opn/core09/oracle9i_database/89067/062410_89067/062410_89067_demo.html
***********************************************************
http://www.oracle-scripts.net/
***********************************************************
https://samadhandba.wordpress.com/2011/03/07/reducing-datafile-size-to-recover-free-space-%E2%80%93-oracle-database-10g/
***********************************************************
https://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_1019.htm#REFRN30170
***********************************************************
https://alexzeng.wordpress.com/2012/09/25/valuate-oracle-awr-automatic-workload-repository/
***********************************************************
https://www.tutorialspoint.com/unix/unix-regular-expressions.htm
***********************************************************
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=542863524161349&parent=DOCUMENT&sourceId=1366610.1&id=112248.1&_afrWindowMode=0&_adf.ctrl-state=jnzbip2ie_4 -- resetlogs
***********************************************************
http://dillidba.blogspot.in/2016/06/upgrade-oracle-11g-r2-11204-database-to.html --upgrade
***********************************************************
http://oracledbabhuvan.blogspot.in/2011/05/recreating-oracle-inventory-in-10g11g.html --recreate oracleinventory
***********************************************************
http://dnccfg.blogspot.in/ --Add node into RAC
***********************************************************
********************************************************************************
./runInstaller -ignorePrereq -J"-Doracle.install.db.validate.supportedOSCheck=false" -ignorePrereq "-ignoreInternalDriverError"
***********************************************************************************************************************************
PMON failed to acquire latch, see PMON dump sol:kill smon and start the instance or sqlplus -prelim / as sysdba shut abort then start
ORA-07445: Message 7445 not found; No message file for product=RDBMS, facility=ORA;
*********************************************************************************************
ORA-29701: unable to connect to Cluster Synchronization Service RESOLVABLE GAP
**************************************************************
Failed to open service <OracleOraDb11g_home2TNSListenerLISTENER1
*********************************************************
RMAN> sql 'alter database open resetlogs';
sql statement: alter database open resetlogs
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 09/07/2017 13:41:14
RMAN-11003: failure during parse/execution of SQL statement: alter database open resetlogs
ORA-00349: failure obtaining block size for '+REDO/etlprod/redo01.lo
sol: ALTER DATABASE RENAME FILE '+REDO/etlprod/redo03.log' to '/home/oracle/app/oracle/oradata/ETLPROD/redo03.log';
***********************************************************************************************************************************
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00392: log 1 of thread 1 is being cleared, operation not allowed
ORA-00312: online log 1 thread 1: ------sol: alter database clear logfile group 1;
'/home/oracle/app/oracle/oradata/ETLPROD/redo01.log'
ORA-00312: online log 1 thread 1:
'/home/oracle/app/oracle/oradata/ETLPROD/redo01a.log'
***********************************************************************************************************************************
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== check the file permission
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/05/2016 10:37:31
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
***********************************************************************************************************************************
ORA-12547: TNS:lost contact ---https://oracledbamasters.wordpress.com/2014/02/25/ora-12547-tns-lost-contact/ -- check the permission on birnaries
***********************************************************************************************************************************
ERROR at line 1:
ORA-00376: file 4 cannot be read at this time --tablespace or datafile might be offline --make it as online
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/DB01/users01.dbf'
***********************************************************************************************************************************
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ---
setup.exe -ignorePrereq -ignorePrereq -J"-Doracle.install.db.validate.supportedOSCheck=false --windows
chmod +R 777 CVU_11.2.0.4.0_oracle in /tmp/ -- Linux
ora-2048 9i client trying to connect -- 11g database
***********************************************************************************************************************************
@casesensitive
sec_case_sensitive_logon=true default passwork case sensitive
***********************************************************************************************************************************
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set windows db sever --> linux client export
erver uses AL32UTF8 character set (possible charset conversion)
***********************************************************************************************************************************
ORA-19502: write error on file "/backup/RMAN_BKP/25Apr17230001/smsdb_rmanbkp_u48s2kcu5_s38024_p1_t20170426", block number 1418113 (block size=8192)
ORA-27061: waiting for async I/Os failed
Linux-x86_64 Error: 5: Input/output error reason:Filesystem error
***********************************************************************************************************************************
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=429723768106311&id=1630653.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=7jctwvisz_114#SYMPTOM
postupg:
The Database has been upgraded from 11.2.0.2 to 11.2.0.4. Upgrade completed successfully but the OWB component is not upgraded and showing version 11.2.0.4
Solution:
Login as sysdba and execute below scripts
execute the script $ORACLE_HOME\owb\UnifiedRepos\clean_owbsys.sql
execute the script $ORACLE_HOME\owb\UnifiedRepos\cat_owb.sql
***********************************************************************************************************************************
SQL> alter database open;
alter database open
*
ERROR at line 1: --> create textcontrolfile
ORA-01190: control file or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '+DATA/t1/datafile/system_01.dbf'
***********************************************************************************************************************************
ERROR at line 1:
ORA-38784: Cannot create restore point 'SNAPSHOT_STANDBY_REQUIRED_11/13/2009
11:18:18'.
ORA-38786: Flash recovery area is not enabled.
To enable the Flash Recovery area
QL> alter system set db_recovery_file_dest_size = 2G;
System altered.
SQL> alter system set db_recovery_file_dest='/u01/Stage11g/flash_recovery_area/STANDBY11g';
System altered.
***********************************************************************************************************************************
RMAN-06094: datafile 1 must be restored
SQL> startup nomount
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device
Additional information: -1895825408
Additional information: 1
sol:increaase kernel.shmall = 4194304
sysctl -p
http://padmavyuha.blogspot.in/2010/12/configuring-shmmax-and-shmall-for.html
***********************************************************************************************************************************
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORA-15097: cannot SHUTDOWN ASM instance with connected client (process 5476) --> shut down the database instance first
http://dbasoumya.blogspot.in/2015/02/alert-mail-script-for-checking-oracle.html
https://communities.bmc.com/docs/DOC-9942 --shell
http://tutorial-sql-databases.blogspot.in/2014/09/manual-upgrades-to-oracle-database-12c.html --Manual upgradation
http://allthingsoracle.com/upgrading-a-database-using-recovery-manager-rman-duplicate-command-in-oracle-12c/ -- Manual upgradation
http://sandeepnandhadba.blogspot.in/2014/12/oracle-golden-gate-12-bidirectional.html
http://orcltechnology.blogspot.in/2016/03/upgrading-oracle-database-11204-to-12101.html --upgradation
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory --> cd $ORACLE_HOME/bin/ -->relink
inhttp://localhost:5500/em
OC4J Configuration issue. /opt/oracle/prod -->#127.0.0.2 myhost.domain.local myhost
http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/241652.htm#o --emctl
*ORA-01078: failure in processing system parameters -->
*ORA-29701: unable to connect to Cluster Synchronization Service --> ./crsctl start resource ora.cssd (or) https://dbamind.wordpress.com/2014/01/29/ora-29701-unable-to-connect-to-cluster-synchronization-service/
http://myoracleproduct.blogspot.in/2013/11/oracle-goldengate-replication-oracle-to.html --goldengate
Listerner purge --https://samadhandba.wordpress.com/2011/03/07/emptyremove-oracle-listener-log-files/
http://allappsdba.blogspot.in/2012/04/scripts-related-to-temp-tablespace.html --temp
12c--http://db12c.blogspot.in/2013/10/clone-pluggable-database-to-remote.html
12c--https://yasinyazici.wordpress.com/2014/11/19/clone-pluggable-database-to-another-container-database-over-the-network/
http://www.pro-oracle.com/2014/10/oracle-database-resolving-library-cache.html
https://orainternals.wordpress.com/2009/06/02/library-cache-lock-and-library-cache-pin-waits/
https://dbacatalog.wordpress.com/2014/10/20/ora-04021-timeout-occurred-while-waiting-to-lock-object/
ORA-00059: maximum number of DB_FILES exceeded ---> alter system set db_files=150 scope=spfile;
https://sachinichake.wordpress.com/2013/05/08/step-by-step-golden-gate-configuration/
ORA-12162: TNS:net service name is incorrectly specified --> export ORACLE SID
ORA-04021: timeout occured while to lock object
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor -->reason for this is that the database instance has not been started
ORA-12541: TNS:no listener -->start the listener
ORA-12154: TNS: could not resolve the connect identifier specified --> reson user entered the wrong connect identifier
ORA-01555: snapshot too old: rollback segment number --> ALTER system SET undo_retention=10800;
*ORA-01194: file 1 needs more recovery to be consistent --->
*ORA-01110: data file 1: ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\DBTEST\SYSTEM01.DBF’ -->recover database using backup controlfile until cancel; -->ALTER SYSTEM SET "_allow_resetlogs_corruption"= TRUE SCOPE = SPFILE; & ALTER SYSTEM SET undo_management=MANUAL SCOPE = SPFILE; & alter database datafile 7 offline drop;
https://blogs.oracle.com/optimizer/entry/explain_adaptive_cursor_sharing_behavior_with_cursor_sharing_similar_and_force
ORA-03135: connection lost contact
ORA-01178: file 6 created before last CREATE CONTROLFILE, cannot recreate
ORA-01190: control file or data file 1 is from before the last RESETLOGS
ORA-01152: file 1 was not restored from a sufficiently old backup -->recover database using backup controlfile until cancel or recover database until cancel using backup controlfile;
-->aply-->alter database open resetlogs;
ORA-01034: ORACLE not available
sampletns:
---------
@tnsfile
RDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.32.128)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = rdb)
)
)
###############################
samplelistener:
--------------
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = rdb)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
)
)
RDB =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = sample.com)(PORT = 1521))
)
)
##############################
11gpfile:
---------
cpr.__db_cache_size=197132288
cpr.__java_pool_size=4194304
cpr.__large_pool_size=4194304
cpr.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
cpr.__pga_aggregate_target=251658240
cpr.__sga_target=369098752
cpr.__shared_io_pool_size=0
cpr.__shared_pool_size=155189248
cpr.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/cpr/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/cpr/control01.ctl','/u01/app/oracle/fast_recovery_area/cpr/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='cpr'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4196401152
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=cprXDB)'
*.memory_target=620756992
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
##########################################
sfms.__db_cache_size=1224736768
sfms.__java_pool_size=16777216
sfms.__large_pool_size=16777216
sfms.__oracle_base='E:\app\administrator'#ORACLE_BASE set from environment
sfms.__pga_aggregate_target=587202560
sfms.__sga_target=1627389952
sfms.__shared_io_pool_size=0
sfms.__shared_pool_size=335544320
sfms.__streams_pool_size=16777216
*.audit_file_dest='E:\app\Administrator\admin\SFMS\adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='E:\app\Administrator\oradata\SFMS\control01.ctl','E:\app\Administrator\oradata\SFMS\control02.ctl','E:\app\Administrator\oradata\SFMS\control03.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='SFMS'
*.db_recovery_file_dest='E:\app\Administrator\flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.db_unique_name='SFMS_KHAR'
*.diagnostic_dest='E:\app\Administrator'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=sfmsXDB)'
*.fal_client='SFMS_KHAR'
*.fal_server='SFMS_BEL'
*.log_archive_config='DG_CONFIG=(SFMS_BEL,SFMS_KHAR,SFMS_NAG,SFMS_KHR)'
*.log_archive_dest_1='LOCATION=G:\archives\sfms VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=SFMS_KHAR'
*.log_archive_dest_2='SERVICE=SFMS_BEL LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_BEL'
*.log_archive_dest_3='SERVICE=SFMS_NAG LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_NAG'
*.log_archive_dest_4='SERVICE=SFMS_KHR LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_KHR'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_dest_state_3='DEFER'
*.log_archive_dest_state_4='DEFER'
*.log_archive_format='%s_%r.%t'
*.memory_target=2204106752
###############################################################
10gpfile:
---------
*.audit_file_dest='/u01/app/oracle/product/10.2.0/db_1/admin/rdb/adump'
*.background_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/rdb/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/control01.ctl','/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/control02.ctl'
*.core_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/rdb/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='rdb'
*.db_recovery_file_dest='/u01/app/oracle/product/10.2.0/db_1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/product/10.2.0/db_1/admin/rdb/udump'
#######################################################
@logfilesize:
-----------
SET LINESIZE 200
COLUMN member FORMAT A50
COLUMN first_change# FORMAT 99999999999999999999
COLUMN next_change# FORMAT 99999999999999999999
col GROUP# for 9
col THREAD# for 9
SELECT l.thread#,
lf.group#,
lf.member,
TRUNC(l.bytes/1024/1024) AS size_mb,
l.status,
l.archived,
lf.type,
lf.is_recovery_dest_file AS rdf,
l.sequence#,
l.first_change#,
l.next_change#
FROM v$logfile lf
JOIN v$log l ON l.group# = lf.group#
ORDER BY l.thread#,lf.group#, lf.member;
##############################################################################
crdb.sql:
--------
create database rdb
datafile '/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/system.dbf' size 400M
sysaux datafile '/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/sysaux.dbf' size 400M
undo tablespace undotbs1 datafile '/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/undo.dbf' size 400M
default temporary tablespace temp tempfile '/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/temp.dbf' size 300M
logfile group 1('/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/redo1.log') size 30M,
group 2('/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/redo2.log') size 30M,
group 3('/u01/app/oracle/product/10.2.0/db_1/oradata/rdb/redo3.log') size 30M;
########################################################
expimp:
-------
1.TRANFER THE DATA FROM ORACLE TO ORACLE
DATABASE LEVEL ENTIRE TO ANTHOER DATABASE
SCHEMA
TABLE
ROW
X SCHEMA WANT TO DUPLICATE IN THE SAME SCHEMA SO CREATE Y EXP X AND IMPORT
$ exp file=full_devdb_sysdate.dump log=full_devdb_sysdate_log.log full=y
exp file=scott_prd_sysdate.dmp log=scott_prd_sysdate.log owner='SCOTT'
exp file=emp_prd_sysdate.dmp log=emp_prd_sysdate.log tables='SCOTT.EMP' statistics=none
exp file=emp_dept10_sysdate.dmp log=emp_dept10_sysdate.log tables='scott.emp' query=\"where deptno=10 \" statistics=none
desired loc file=/u02/emp_prod
buffer to speed up export porcess
it should be 10*avg row level
prafile: list of commanads
new file 1.parfile
userid='/ as sysdba'
file=proddb.dmp
log=prodb.log
full=y
direct=y
buffer=5000
indexes=n
exp parfile=1.parfile
consistent no better to make s ?
=========
reading updation is take placess it will take the data from undo tablespaces
=================================================================IMPORT======================================================================
Take the export and transfer it to another server
scp kanna.dmp oracle@192.168.1.120:/u02
schema
create new user with same name
imp file=kanna.dmp log=imp_kanna.log fromuser='kanna' touser 'kanna2'
table
imp file=kanna.dmp log=kanna.log fromuser='scott' touser='kanna' opt(tables='scott.emp' or tables='emp')
rows
imp file=emp.dmp log=emp_kanna.log fromuser='scott' touser='kanna' tables='emp'
options
======
show=y
imp file=emp_row.dmp log=1.log show=y fromuser='scott' touser='kanna'
if table is already exists
ignore=y
imp file=emp_row.dmp log=2.log fromuser='scott', touser='kanna' ignore=y
oracle skip and continue further
commit=y
=====
AFTER IMPORTING COMMIT WILL ISSUED 30 DATAPUMP
need to understand the error:
ORA-01102: cannot mount database in EXCLUSIVE mode
***********************************export multiple table and imp multiple tables************************
exp file=f1.dmp log=f1.log tables='SYS.T1','SYS.T2'
imp file=f1.dmp log=f1.log fromuser='SYS' touser='PUSR'
datapump:
---------
col owner for a20
col directory_path for a60
set lines 150
set pages 999
select * from dba_directories;
@objcount:
------------
select owner,object_type , count(*) from dba_objects where status='INVALID' group by object_type,owner;
select distinct object_type,count(*),status from dba_objects where owner='<>' group by object_type,status;
sql> !mkdir /u02/dpdir
sql> create directory dpdir as /u02/dpdir
$expdp directory=dpdir dumpfile=1.dmp logfile=1.log full=y
sysdba
SQL>grant read,wirte on directory dpdir to kanna
tablspace leve posible
select * from dba_datapump_jobs;
expdp help=y
attach:
expdp directory=dpdir dumpfile=1.dmp logfile=1.log full=y
expdp attach=sys_export_full_01
/ as sysdab
contl+c
export> exit
expdp attach='jobname'
export>status
compression:
======
content data and metadata
======
estimate: calate and perform exp
========
estimate only only calculate
============
exclude: shema having 100 tables u dont want to exp so u can use even view etc
=====
parlel: 10 process will take care of u r exp
======
version:
=======
9i exp imp on 10g lower to higher
normal exp imp not possible the above
exp 11g imp into 10g
addfile:
======
we can add anthoer dumpfile
continue
=======
kill_job
========
expdp: u can pauase the job continue later
networklink:
------------
- Create user on SOURCE db to use for network link in TARGET database.
CREATE USER ARTISDBA IDENTIFIED BY "Password123$";
GRANT DBA TO ARTISDBA;
- Create Database link on target
CREATE DATABASE LINK SERVICE_NAME CONNECT TO ARTISDBA IDENTIFIED BY "Password123$" USING 'SERVICE_NAME';
- Copy TNSNAMES entry for source database to target's tnsnames.ora file.
- Create directory in TARGET to use for your logfiles.
CREATE DIRECTORY dumpdir AS '/orabkup/expdp';
GRANT READ,WRITE ON DIRECTORY dumpdir to PUBLIC;
- Run import job on TARGET. You parallelize the job to make it faster.
impdp parfile=impdp.par
PARFILE contents:
DIRECTORY=dumpdir
NETWORK_LINK=SERVICE_NAME
SCHEMAS='TEST'
PARALLEL=4
LOGFILE=impdp_from_service_name.log
TABLE_EXISTS_ACTION = {SKIP | APPEND | TRUNCATE | REPLACE}
As the name implies, table_exists_action is used in impdp when the table already exists in the database where the import is being executed.
table_exists_action=skip: This says to ignore the data in the import file and leave the existing table untouched. This is the default and it is not a valid argument if you set content=data_only.
table_exists_action=append: This says to append the export data onto the existing table, leaving the existing rows and adding the new rows from the dmp file. Of course, the number and types of the data columns must match to use the append option. Just like the append hint, Oracle will not re-user any space on the freelists and the high-water mark for the table will be raised to accommodate the incoming rows.
table_exists_action=truncate: This says to truncate the existing table rows, leaving the table definition and replacing the rows from the expdp dmp file being imported. To use this option you must not have any referential integrity (constraints) on the target table. You use the table_exists_action=truncate when the existing table columns match the import table columns. The truncate option cannot be used over a db link or with a cluster table.
table_exists_action=replace: This says to delete the whole table and replace both the table definition and rows from the import dmp file. To use this option you must not have any referential integrity (constraints) on the target table. You use the table_exists_action=replace when the existing table columns do not match the import table columns.
expdp directory=EXP_IMP_DIR dumpfile=expdp_BR_%u.dmp logfile=expdp_BR.log tables=SFMSBR.MTB_MSG_TXT_BR filesize=2G parallel=4
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL.log filesize=2G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL_1.log filesize=10G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL_1.log filesize=10G FULL=Y
http://artisdba.blogspot.in/2011/04/data-pump-impdp-via-network-link.html
expmultipledir:
---------------
CREATE OR REPLACE DIRECTORY TEST_DIR1 AS '/software_dump/11gR204/dbbackup/mpesa_platform_bkp/test1';
CREATE OR REPLACE DIRECTORY TEST_DIR2 AS '/software_dump/11gR204/dbbackup/mpesa_platform_bkp/test2';
expdp SCHEMAS=MPESA_PLATFORM DUMPFILE=TEST_DIR1:MPESA_PLATFORM_1%u.dmp,TEST_DIR2:MPESA_PLATFORM_2%u.dmp FILESIZE=100M LOGFILE=TEST_DIR1:expdp_log JOB_NAME=expdp_Mpesa parallel=2
http://www.linkedin.com/groups/Multiple-EXPDP-Directories-77941.S.5849421326418194436
@expcheck
----------
select sid, serial#, sofar, totalwork,(sofar/totalwork) * 100 done,
dp.owner_name, dp.state, dp.job_mode
from gv$session_longops sl, gv$datapump_job dp
where sl.opname = dp.job_name and sofar != totalwork;
##################################################################################
@catalog:
--------
RECOVERY CATALOG
Is is a separte database in which u r going maintain rman backup information this info will store in control file. backup info of multiple db will store
and if u lost control file of target db it will help to recover db
Backup information of multiple database will store
back color is target white is recovery catlog db
1.create tablespace rmantbs datafile '/u01/ora10g/rcatdb/rmantbs01.dbf' size 100m
2.create user rman_rc identified by rman_rc default tablespace rmantbs temporary tablespace temp;
3.Grant connect,resource,recovery_catalog_owner to rman_rc
4.$ rman catalog rman_rc/rman_rc
5.create catalog; =====>once u issue tables view will be created we can see those after connecting to rman_rc user. back up info store in these tables
6.conn rman_rc/rman_rc
===========
to target database block color
cd oracle_home/network/admin/tnsname.ora
service_name =listername(rcatdb)
tnsping rcatdb 10:mis
configure the tns names.ora
rman target /catlog rman_rc/rman_rc@rcatdb
RMAN>register database (this info will store in rcatdb)
waytotakebkp:
------------
rman target /catlog rman_rc/rman_rc@rcatdb
RMAN> backup database plus archive;
========From catdb side to we can connect to target db===========
rman target sys/oracle@ROD catalog pusr/pusr@OD
RMAN>BACKUP DATABASE PLUS ARCHIVELOG;
#########################################################################################
RMAN CLOING:
COLOING IS PROCESS OR REPLICATING EXISTS DATABASE IN ANOTHER SERVERS
dp or exp imp smaller database if u r db is 10 tb or 20 tb in case we need to go rman cloning
refreshing vs cloning
some set of scheman or tables copying entire db it is cloning
NOTE:The server os vesion the databse version should be same
aix 64 aix 64
10g 10g
1 db white(prod)
2.test black (test)
test block (prod) 8
==================
#install 11 g
white:
=====
1.create pfile from spfile
$ scp initprod.ora oracle@192.1.23.34: /u01/oacle_home/dbs/inittestdb.ora black: change the name in in pfile in testdb
add 2 perameters
1.db_file_name_convert
2.log_file_name_convert
log_archive_dest crated directry also
create nessary directories
on the production server where redo,data exsits /u01/oradata/prod
/u01/oradata/test
orapwd file=orapwprodb password=sys123 force=y
$scp orapwprodb oracl@192.1.23.34: /u01/oacle_home/dbs/orapwtestdb
both side configure lister and tnsnames
creating lister and tns
invoke vnc create listner
tns : testdb
tns :prodb
vnc invoke
$ps -ef | grep tns
if listner not up and running start listner
lsnctl stop listner
vi listner
sid =proddb
tnsping prodb tnsping prodb
tnsping tesdb tnsping testdb
shut immediate
startup mount
rman target /
RMAN> backup database plus archivelog;
store backup peices in some location create same direcories same location 40
TAKE FULL RMAN BACKUP
Pieces handled /u01/jdld/ mkdir -p /u01/jdld/
scp *.bkp oracle@192.168.120 test side invoke rman
export oracle_sid=testdb
sqlplus / as sysdba
SQL>STARTUP NOMOUNT
rman target sys/sys@123@test auxiliary sys/sys123@testdb
RMAN>duplicate target database to testdb nofilenamecheck
V$BACKUP_SET
RC_BACKUP_SET
#############################################################################################################
CREATE TABLESPACE:
=================
create tablespace mytbs
datafile '/u02/ora10g/prod/mytbs01.dbf' size 50m
autoextend on maxsize 200m
extent management local / dictionary
segment space management auto / manual
inittrans 1 maxtrans 255
pctfree 20 pctused 40
initial 1m next 5m
pctincrease / uniform / autoallocate
minextents 1 maxextents 500
logging / nologging
blocksize 8k; - this is optional
CHECK TABLESPACE INFO:
=====================
select allocation_type,extent_management,contents from dba_tablespaces where tablespace_name='MYDATA';
@freedata:
---------
col file_name for a50
select file_name,sum(bytes)/1024/1024 "ACTU",autoextensible,sum(maxbytes)/1024/1024 "MAX" from dba_data_files where tablespace_name='&tbs' group by file_name,autoextensible order by 1;
DATABASE SIZE:
=============
1 - The size of the Oracle database files can be computed several ways:
-- get database size from v$datafile:
select round((sum(bytes)/1048576/1024),2) from v$datafile;
-- get Oracle database size from dba_data_files:
select
"Reserved_Space(MB)", "Reserved_Space(MB)" - "Free_Space(MB)" "Used_Space(MB)","Free_Space(MB)"
from(
select
(select sum(bytes/(1014*1024)) from dba_data_files) "Reserved_Space(MB)",
(select sum(bytes/(1024*1024)) from dba_free_space) "Free_Space(MB)"
from dual
);
TABLE_SIZE:
===========
2 - The size of the sum of table extents
select
segment_name table_name,
sum(bytes)/(1024*1024) table_size_meg
from
user_extents
where
segment_type='TABLE'
and
segment_name = 'MYTAB'
=====================
select sum(bytes/1024/1024/1024) from dba_data_files;
ENABLE/DISABLE AUTOEXTEND:
=========================
alter database datafile ‘/u02/prod/mytbs01.dbf’ autoextend on maxsize 100m;
alter database datafile ‘/u02/prod/mytbs01.dbf’ autoextend off;
RESIZE DATAFILE:
===============
alter database datafile ‘/u02/prod/mytbs01.dbf’ resize 20m;
ADD DATAFILE:
============
alter tablespace mytbs add datafile ‘/u02/prod/mytbs02.dbf’ size 10m;
RENAME TABLESPACE:
=================
alter tablespace mytbs rename to mydata;
========
FREE
COLUMN pct_free FORMAT 999.99 HEADING "% Free"
COLUMN name FORMAT A16 HEADING "Tablespace Name"
COLUMN mbytes FORMAT 99,999,999 HEADING "Total MBytes"
COLUMN used FORMAT 99,999,999 HEADING "Used Mbytes"
COLUMN free FORMAT 99,999,999 HEADING "Free Mbytes"
BREAK ON REPORT
COMPUTE SUM OF mbytes ON REPORT
COMPUTE SUM OF free ON REPORT
COMPUTE SUM OF used ON REPORT
SELECT fs.tablespace_name name, df.totalspace mbytes, (df.totalspace - fs.freespace) used,
fs.freespace free, 100 * (fs.freespace / df.totalspace) pct_free
FROM (SELECT tablespace_name, ROUND(SUM(bytes) / 1048576) TotalSpace FROM dba_data_files GROUP BY tablespace_name ) df,
(SELECT tablespace_name, ROUND(SUM(bytes) / 1048576) FreeSpace FROM dba_free_space GROUP BY tablespace_name ) fs
WHERE df.tablespace_name = fs.tablespace_name(+);
==========
.201
SQL> select file_name,sum(bytes)/1024/1024/1024,sum(maxbytes)/1024/1024/1024 from dba_data_files group by tablespace_name,file_name having tablespace_name='NEFT_ARCH_NDX';
========================
chktbs:
-------
col "NAME" format a30
set lines 140
set pages 1000
select a.tablespace_name "NAME",(b.totalspace - a.freespace)"USED SPACE",
a.freespace "FREE SPACE",b.totalspace "TOTAL SPACE",round(100 * (a.freespace / b.totalspace)) "% FREE"
from
(select tablespace_name,sum(bytes)/1024/1024 TotalSpace
from dba_data_files
group by tablespace_name) b,
(select tablespace_name,sum(bytes)/1024/1024 FreeSpace
from dba_free_space
group by tablespace_name) a
where b.tablespace_name = a.tablespace_name(+)
and b.tablespace_name like upper('%&tablespace_name%')
order by 5
/
=================
@alltbs
SELECT /* + RULE */ df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;
========================
@temptbs
select FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE from dba_temp_files where TABLESPACE_NAME='TEMP';
=============freetbs====================
@privs
=========
SEE PERMANENT DEFAUT TABLESPACE:
===============================
select default_tablespace,temporary_tablespace from dba_users where username=’SCOTT’;
# To check default permanent tablespace and temporary tablespace
================================================================
select property_name,property_value from database_properties where property_name like ‘DEFAULT%’;
# To change default permanent tablespace
========================================
alter database default tablespace mydata;
# To change default temporary tablespace
========================================
alter database default temporary tablespace mytemp;
# To check system privileges for a user:
========================================
select privilege from dba_sys_privs where grantee='&SCOTT';
# To check object level privileges
==================================
select owner,table_name,privilege from dba_tab_privs where grantee='&SCOTT';
# To check roles assigned to a user
===================================
select granted_role from dba_role_privs where grantee='&SCOTT';
# To check permissions assigned to role
=======================================
select privilege from role_sys_privs where role='&MYROLE';
select owner,table_name,privilege from role_tab_privs where role=’MYROLE’;
select granted_role from role_role_privs where role='MYROLE';
RMAN BACKUP:
===========
23:00
cold and hot ==>file level
export ====>table level
rman ===>block level
adv ===> speed,size reduced
contact bit map in datafile header
parallelsim: 10 process datafile scan across
duplexing archive: if want to maintain two location if one corrupted oracle take care
detection : if data file curupted
validating : validation will give rman
controlfile autobackup on :
along with database back if u want to take control file backup
autoback up: will go in to tap or disk
DISK PARLLELISM: at a time 3 data file will scan
components of rman:
1. RMAN executable file ===> rman prompt
2.target : abc is my database if want to take backup of abc it will become target database
3. auxillary database: colnned copy of target
4. recovery catalog :repository of it will store the backup of database
5. media manger layer:
configuration parameters:
========================
show all; (; mandatory)
1. retention pocily:
redundency: how many back to there def 1
recovery window: how many days
RMAN> CONFIGURE RETENTION POLIICY TO RECOVERY WINDOW OF 90days
RMAN> configure channel device type disk format '/u01/rman_bkp/%T_%D_%U';
redundency 3
2. configure backup optimization defalut off:
file level bkp 10 gb back of yesterday. today datafile not changed (not use realtime)
300 5 par
sbt_tape
flash recovery area: it is a area when recovery req file will be there
backup piece: it is a file phy
backup set: group of backup pieces logical
how to increse the size of flash recovery:
SQL> show parameter db_recovery_file_dest_size
name type value
db_recovery_file_dest_size big interger 2G
SQL> alter system set db_recovery_file_dest_size=10G scope=both;
@archdestination
----------------
mkdir /u02/archives
SQL> alter system set log_archive_dest_1='location=/u02/archives' scope=both;
alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST';
------------------------------------------------------------------------------------
RMAN> BACKUP FORMAT='/U02/FULL_PRODB_%T.BKP' DATABASE PLUS ARCHIVELOG T IS THE REFERENCE NUMBER IT STORES THE TIMESTAMP WHAT TIME BACKUP TAKEN
10g compressed backup:
size of the backup peice reduced
RMAN>backup as compressed backupset database plus archivelog
14 to 2 gb
RMAN> list backup
the info stored in control files from control file this info will get
bskey typeofbackup size disk howmuchtimetaken(elapased) completedtime
due to some space issue u delted os level
rm yesterday directory
even u tho u deleted but rman dont' know if u list backup it will give u deleted backup all so
RMAN>Crosscheck backup ======verification of cmparing to 2 os level and db level
it make as expired
RMAN> delete expired backup;
it will ask promt
RMAN>delete noprompt expired backup;
RMAN>CROSSCHECK ARCHIVELOG ALL;
RMAN> DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
RMAN> REPORT OBSOLETE;
RMAN> DELETE NOPROMPT OBSOLETE;
delete expired archivelog all;
RMAN> BACKUP AS COPY DATABASE; FILE LEVEL BACKUP SIMILER TO HOT AND COLDBACKUP
AFTER TAKING BACKUP
RMAN>RESTORE DATABSAE VALIDATE;
LAST BACKUP OF THE PEICES WILL BE VALIDATED
RMAN> VALIDATE BACKUPSET 23;
BEFORE BACKUP ONLY WE CAN CHECK THE DATABSE
==========
RMAN>BACKUP VALIDATE DATABASE ARCHIVELOG ALL; DONT TAKE BACKUP JUST VALIDATE
LIST BACKUP BY FILE; # shows backup sets, proxy copies, and image copies
LIST COPY; # shows only disk copies
******************************************************** RECOVERY *****************************************************************
******************************************************** *****************************************************************
remove datafile at os level
run block series of steps execution
RMAN> run
{
sql 'alter tablespace users offline';
restore tabelspace users;
recover tablespace users;
sql 'alter tablespace users online';
}
******************************************************** incremental *******************************************************
today 100 gb tomorw 110 next 120
today 1 hr taken
tomorrow more then one hour
level 0 full backup
rest of days incremental backup
sunday full backup
every day incremental backup
*****************************************
today 500
tomorr 510 i take only 10 of backup
1. diffential
2. cumilative
both have level 0 and 1
fist time level 0
backup incremetal levelo 0 database plus archivelog; differntial by default
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE PLUS ARCHIVELOG; FAST
T
RMAN> BACKUP CUMULATIVE INCRENTAL LEVEL 0 DATABSAE PLUS ARCHVIVELOG;
10G BLOCK CHAGE TRACING
IF BLOCK CHANGE IT PLACE IN A FILE WHEN U INITIATE RMAN TO GO TO THAT FILE
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/U02/TRACK.F';
CTWR BACKGROUND PROCESS
===========SHOW=================
SHOW CHANNEL
SHOW DEFAULT DEVICE TYPE
SHOW BACKUP OPTIMIZATION
============MONITERING RMAN======================
V$PROCESS Identifies currently active processes.
V$SESSION Identifies currently active sessions. Use this view to determine
which database server sessions correspond to which RMAN allocated channels.
V$SESSION_LONGOPS Provides progress reports on RMAN backup and restore jobs.
V$SESSION_WAIT Lists the events or resources for which sessions are waiting.
V$BACKUP_SYNC_IO Displays rows when the I/O is synchronous to the process (or thread on some platforms) performing the backup
v$DATABASE_BLOCK_CURRPUTION : will update the rman errors
=================CHANGE THE LOCATION========================
=================****************==================
You can view the current configuration values of all the RMAN parameters that you change from
their default values by using the V$RMAN_CONFIGURATION view
======================================================@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@===============================================================
@level1
==============
run
{
sql 'alter system switch logfile';
sql 'alter system switch logfile';
sql 'alter system switch logfile';
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
allocate channel c5 device type disk;
allocate channel c6 device type disk;
allocate channel c7 device type disk;
allocate channel c8 device type disk;
backup as compressed backupset incremental level 1 database format '/u01/rman_bkp/level1_%d_%T_%s_%p' TAG='level1D';
####backup format '/u01/rman_bkp/level1_arch_%d_%T_%s_%p' archivelog all delete input TAG='level1_arch_bkp';
backup format '/u01/rman_bkp/level1_arch_%d_%T_%s_%p' archivelog all TAG='level1_arch_bkp';
delete noprompt archivelog all completed before 'sysdate-6';
backup current controlfile format '/u01/rman_bkp/ctrl_%d_%s.ctl';
}
==================================
rman is a server manged backup
RMAN> backup tablespace system;
it will take backup of backup set control&spfile even control file auto backup off;
RMAN> backup tablespace sysaux;
it will take only one backup piece genarated. but if you make control file auto backup on then it takes control&spfile;
if the control file autobackup is on and if you change any strutural change to db it take backup automatically.
controfile autobackup off;
RMAN>backup database plus archivelog; it take cotrol&spfile bcz we included system tablespace;
crash database
shut abort;
remove file at physical localtions CRD
SQL>startup
error 205 error identifying control file check alert log
SQL>shutdown abort
RMAN> startup nomount;
RMAN> restore controlfile form '004LM'; ---YOU MUST KNOW THE PIECE NAME
RMAN> alter database mount;
rman> restore database;
RMAN>recover database;
RMAN>alter database open resetlogs;
configure control file autobackup on:
RMAN>backup database plus archivelog; --control&spfile takes
quit
SQL>shutdown abort;
delete RCD FILE
SQL> startup
error
HERE DBID REQ
RMAN> SET DBID 234546 ---FROM BACKUP U GET DBID APPENDS
RMAN>startup nomount;
Oracle instance started
RMAN> restore controlfile from autobackup;
RMAN> alter database mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open resetlogs;
RMANBACKUP SCRIPTS:
==============
BACKUP VALIDATE:
===============
connect target /
run
{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
BACKUP VALIDATE CHECK LOGICAL database;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
BACKUP ARCH:
===========
connect target /
run
{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
backup as compressed backupset
format '/ora_backup/%d_arc_t%t_s%s_p%p.bkp'
filesperset=8
(archivelog all delete input);
release channel ch1;
release channel ch2;
release channel ch3;
}
BACKUP FULL:
===========
connect target /
set snapshot controlfile name to '/oracle/bkp/controlfile_snapshot.ctl';
run
{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
allocate channel ch5 type disk;
backup as compressed backupset
format '/ora_backup/%d_dbf_t%t_s%s_p%p.bkp'
filesperset=4
database;
sql 'alter system archive log current';
release channel ch1;
release channel ch2;
allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup as compressed backupset
format '/ora_backup/%d_arc_t%t_s%s_p%p.bkp'
filesperset=4
(archivelog all delete input);
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
}
run
{
crosscheck backup;
delete noprompt obsolete;
}
BACKUP INCR_DIFF:
================
connect target /
set snapshot controlfile name to '/oracle/bkp/controlfile_snapshot.ctl';
run
{
crosscheck backup;
delete noprompt obsolete;
}
run
{ allocate channel ch1 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch2 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch3 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch4 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch5 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
allocate channel ch6 type disk format '/ora_backup/in_%d_dbf_t%t_s%s_p%p.bkp';
BACKUP as compressed backupset INCREMENTAL LEVEL 1 DATABASE include current controlfile filesperset=8;
sql 'alter system archive log current';
backup as compressed backupset
format '/ora_backup/%d_arc_t%t_s%s_p%p.bkp'
filesperset=6
(archivelog all delete input);
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;
}
@DATAGAURD:
==========
DATA GAURD CONFIGURATION :
====================================
1. check archive log is on
SELECT force_logging FROM v$database;
2. SQL>alter database force logging; {redo entries will genarated} if the user connected issued dml and nologging
3. SQL>select group#,members,sum(bytes/1024/1024) from v$log group by group#,members
4. SQL>alter database add standby logfile group 4 '/u01/oradata/prodb/redo04.log' size 50m;
SQL>alter database add standby logfile group 5 '/u01/oradata/prodb/redo05.log' size 50m;
SQL>alter database add standby logfile group 6 '/u01/oradata/prodb/redo06.log' size 50m;
5. SQL>select type from v$logfile;
6. SQL>show parameter db_unique_name ===========>should show the instance name {database name should same in both primary and stand by}
7. SQL>alter system set log_archive_config='DG_CONFIG=(proddb,standb)' scope=both;
8. SQL>alter system set log_archvive_dest_1='location=/u02/archive VALID_FOR(ALL_LOGFILES,ALL_ROLES) db_unique_name=prodb' scope=both
9. SQL>alter system set log_archive_dest_2='SERVICE=standb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=stndb' scope=both
10.show paramter log_archive_dest_state_1
11.show paramter log_archive_dest_state_2 should be enable both if not alter system set log_archive_dest_1 eable
12. alter system set fal_server='standb' scope=both
13. alter system set fal_client='prodb' scope=both
14.alter system set standby_file_management=auto scope=both
15.create pfile from spfile
16. scp /u01/dbs/initprodb.ora oracle@19.168.1.11:/u01/initstandb.ora ======>check pfile copied or not
17. open pfile
18 above audit not required
19. a dump and control file, flash recovery
dbname same
servicename, db_unique_name prodb
add db_file_name_convert='/u01/oradata/proddb','/u01/oradata/standb'
log_file_name_convert='/u01/oradata/proddb','/u01/oradata/standb'
db_unique_name='standb'
create nesseary direcoties
configure listner
====
configure tnsnames
export oracle_sid=standb
startup nomount
RMAN> duplicate target database for standby from active database nofilenamecheck;
select name,open_mode from v$database;
ps -ef|grep mrp
alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;
select max(sequence#) from v$log_history =========> sink where both r
select name,database_role from v$database evn instace name also\
show parameter log_archive_dest2
and
select name,database_role,protection_level from v$database
alter database recovery managed standby database cancel
alter database recover managed standby database using current logfile disconnect from session; ========>realy time apply
suppose primary side i recreated passwordfile sys123 with out inform created then not scp
select sequence#,archived,applied from v$archived_log achive=== logshipping applied===mrp
Q;how to check logship and logapply are runing
what to do if logshipping not applied (1.set alert log file both primary and secondery)
2.if alter log 1034 show error in alert log file then copy the possword file primary to stand by
3.if alter log show any error related to network then check listners are up and runing both sides and check the tnsping both side
if alter log shows heart beat fail error then check the value of db_unique_name paramer both primary and standby
what to do if log apply not done?
check mrp process is up and running or not
some time even mrp upandrunnig apply not work in both cases stop and start mrp
@drill
swithover:
+++++++++
select database_role,switchover_status from v$database
AT PDC SITE:
===========
1) alter database commit to swithover to physical standy with session shutdown
2) shut immediate;
3) startup mount;
AT ODC SITE:
============
1)alter database recover managed standby cancel;
2)alter database commit to switchover to primary
3)shut immediate;
4)startup
5)alter database recover managed standby database disconnect from session;
2:29
V$DATAGUARD_STATS
=================
displays how much redo data generated by the primary database is not yet available on the standby database,
showing how much redo data could be lost if the primary database were to crash at the time you queried this view.
You can query this view on any instance of a standby database in a Data Guard configuration. If you query this view on a primary database,
then the column values are cleared.
v$recovery_progress can be used to monitoring database recovery operations, and gives us access to information
like: Last Applied Redo, Active Apply Rate, Average Apply Rate, Apply Time per Log and a few more.
The item we are interested in is “Last Applied Redo” and the value of the “TIMESTAMP” column.
The value should be very close to or match the value of LAST_TIME column from v$standby_log view.
SQL> select START_TIME,TYPE, ITEM,UNITS,SOFAR,TIMESTAMP
2 from v$recovery_progress where ITEM='Last Applied Redo';
START_TIME TYPE ITEM UNITS TIMESTAMP
------------------- ---------------- ------------------- --------- -------------------
2013-04-17 22:46:26 Media Recovery Last Applied Redo SCN+Time 2013-04-18 20:26:16
v$Managed_standby
=================
V$MANAGED_STANDBY displays current status information for some Oracle Database processes related to physical standby databases in the Data Guard environment.
This view does not persist after an instance shutdown.
v$datagaurd_config
=================
Lists the unique database names defined with the DB_UNIQUE_NAME and LOG_ARCHIVE_CONFIG initialization parameters.
v$log_history
=============
V$LOG_HISTORY displays log history information from the control file.
v$archive_dest_status
=====================
V$ARCHIVE_DEST_STATUS displays runtime and configuration information for the archived redo log destinations.
The information in this view does not persist across an instance shutdown.
=======================convert snapshto database to physical standby============
alter database convert to physical standby;
alter database convert to snapshot standby
======================prerequests============================
1. Ensure Dbvisit Standby is no longer scheduled on the primary and standby servers.
2. Ensure there is enough space on the standby server to receive the primary redo logs, and any new archive logs created.
3. Ensure that the standby database is in archive log mode.
4. Ensure there is sufficient space on the primary server for complete backups of the redo logs. Required space will be double the current redo log space requirements.
5. The standby database must be up to date before starting the switchover process. Dbvisit Standby will check if this is the case and will not initiate the switchover if the standby database is not up to date.
6. Oracle database parameters db_file_name_convert and log_file_name_convert must be set to default values (null strings) in the primary database prior to switchover.
If either of the parameters are set to non null values in an Oracle database version 11 and higher that uses an spfile (not pfile), Dbvisit will automatically reset both parameters to default values during Graceful Switchover so no action is required.
In case a primary database has version is 10 or lower, or a database uses a pfile, Graceful Switchover will terminate, and instructions to reset both parameters and restart the primary database will be displayed.
4.ALLOCATE CHANEL C1 DEVICE TYPE DISK FORMAT '/U01/RMANBKP';
BACKUP INCREMENT FROM SCN 102;
5.ALTER DATABSAE CREATE STANDBY CONTROLFILE AS ='/PATH';
6.SCP BACKUP AND CONTROL TO STAND BY 1.SELECT CURRENT_SCN FROM V$DATABASE
2.ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
3.SHUT IMMEIDATE
7.REPLACE CURRENT CONTROLFILE WITH 'PATH';
8.STARTUP MOUNT
9.ALTER DATABASE MOUNT STANDBY DATABASE
10.CATALOG STARTWITH 'PATH'
11.RECOVER DATABASE;
12.ALTER DATABASE RECOVER MANAGED STANDBY DATABSAE DISCONNECT FROM SESSION
REGISTER REDOLOGS AT STANDBY:
============================
ALTER DATABASE REGISTER LOGFILE '/physical_standby1/thread1_dest/arcr_1_7.arc';
standby side:
============
dbname our primary
dbfilename convert pri to stand
falclient=stand
falserver=primay
controlfile change to stand
dst1 dst2 unique name change
========================================================@zip@=====================================
1.compress
compress abc ===>abc.z
uncompress abc.z
2. zip <filename.zip> actfile ===>abc.zip
unzip abc.zp
3.gzip abc ===>abc.gz
gunzip abc.gz
gzip `ls -ltr | grep -w "Feb" | awk '{print $NF}'`
4.tar -cvf abc.tar foldername ===>abc.tar
tar -czvf archive.tar.gz
tar -xvf abc.tar for 3&4 you can give the destination
===============================================STATISTICS====================================================
analyze table emp estimate statistics;
exec dbms_stats.gather_table_stats('SCOTT','EMP',’’,40);
INDEX
=====
analyze index pk_emp compute statistics;
exec dbms_stats.gather_index_stats(‘SCOTT’,’PK_EMP’);
SCHEMA
=====
exec dbms_stats.gather_schema_stats(‘SCOTT’);
FULLDB
=====
exec dbms_stats.gather_database_stats;
=============================================TUNING================================================
if palntable not available execute below script
@?/rdbms/admin/utlxplan.sql
explain plan set statement_id='abc'
for select *from tablename;
@?/rdbms/admin/utlxpls.sql
explain_plan==
AWR:
===
SQL>@?/rdbms/admin/awrrpt.sql
report type: html
no of days:2
begin snapid
end snapid
reportname: /home/oracle/abc_awrrpt.html
=========================================@ADMIN RAC=============================
srvctl
======
#to see configuration
$srvctl config database -d hrms
#to see status of all instances
$srvctl status database -d hrms -- start or stop
#to see status of specific instance
$srvctl status instance -i hrms -d hrms
#to see all services of database
$srvctl status service -d hrms -- start or stop
#to see status of asm
$srvctl status asm -n lnx01 -- start or stop
#to see status of nodeapps
$srvctl status nodeapps -n lnx01 --start or stop
#to stop listner
$srvctl stop listner -n linx01 --stat or stop
racservice
$srvctl add service -s test -d hrms -r hrms1 -a hrms2 -P basic r=prefer
#to see status of specific service
$srvctl status service -s test -d hrms
#to delete service
$srvctl remove service -s test -d hrms
#to disable enable instance
$srvctl disable instance -d hrms
#to register the database with cluster
$srvctl add database -d crm -o $ORACLE_HOME
#to register the instance with cluster
$srvctl add instance -i crm -d crm -n lnx01
#to ungister the entries
$srvctl remove database -d crm
#to know the configuration of scan listner
$srvctl config scan_listner
#to know the status of scan listner
$srvctl status scan_listner
---------------------------------------------
@racsessions
-----------
select
inst_id,
count(*)
from
gv$session
where
username is not null
group by
inst_id;
----------------------------------------------
crsctl:
======
#to see version of cluster
$crsctl query crs softwareversion
$crsctl query crs activeversion
#to stop cluster
#cd /etc/init.d
#./int.crs stop
or
cd $ORACLE_CRS_HOME/bin
#./crsctl stop cluster
in 11g ./crsctl stop cluster -all
#to know the location of votiong disk
$crsctl query crs votedisk
#to know the location of ocr file
$ocrcheck
#to know olr
$ocrcheck -local
#to disable cluster
$crsctl disable crs
#to know the master node
$ocrconfig -showbackup
#to know the status of all resources that register with cluster
$crs_stat -d
#to dump the content of ocr into a text file
#ocrdump
#to know the number of nodes participating in cluster
#olsnode
#to check the status of cluster
$crsctl check crs
11g $crsctl check crs -all
----------------------------------------
$ crsctl get css disktimeout
CRS -4678: Successful get disktimeout 200 for Cluster Synchronization Services
$ crsctl get css misscount
CRS-4678: Successful get misscount 30 for Cluster Synchronization Services
-------------------------------------------
BACKUP IN RAC:
=============
OCR
$ocrconfig -showbackup
defalut will be $ORA_CRS_HOME/cdata/lnx02/ocr001.ocr
/day.ocr
/week.ocr
ocrconfig -restore $ORA_CRS_HOME/cdata/lnx02/ocr001.ocr
#to take ocrbackup manuall
$ocrconfig -export /opt/ocr.bkp
#to restore ocrbackup manuall
$ocrconfig -import /opt/ocr.bkp
VOTING FILE
===========
#dd if =/dev/sdb5 of=/opt/vote.bkp
#to restore votefile
#dd if=/opt/vote.bkp of=/dev/sdb5
OLR
===
$ocrconfig -showbackup -local
#to take backup of olr
$ocrconfig -local -manualbakup
#to restore olr
$ocrconfig -local -restore <filepath>
===================================DBSIZE===================================
select
"Reserved_Space(MB)", "Reserved_Space(MB)" - "Free_Space(MB)" "Used_Space(MB)","Free_Space(MB)"
from(
select
(select sum(bytes/(1014*1024)) from dba_data_files) "Reserved_Space(MB)",
(select sum(bytes/(1024*1024)) from dba_free_space) "Free_Space(MB)"
from dual
);
==========================KILL===============
alter system kill session '815,4221';
PATH=$PATH:$HOME/bin
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_home
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
==========multipledumps==========
expdp directory=EXP_IMP_DIR dumpfile=expdp_BR_%u.dmp logfile=expdp_BR.log tables=SFMSBR.MTB_MSG_TXT_BR filesize=2G parallel=4
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL.log filesize=2G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_1%u.dmp logfile=expdp_FULL_1.log filesize=10G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL_1.log filesize=10G parallel=4 FULL=Y
expdp directory=EXP_IMP_DIR dumpfile=expdp_FULL_%u.dmp logfile=expdp_FULL_1.log filesize=10G FULL=Y
=====================
RMANR
set lines 100 pages 100
col STATUS format a9
col min format 999.99
select SESSION_KEY, INPUT_TYPE, STATUS,to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,to_char(END_TIME,'mm/dd/yy hh24:mi')
end_time, round(elapsed_seconds/60,2) mis,round(OUTPUT_BYTES/1024/1024,2) "SizeMB" from V$RMAN_BACKUP_JOB_DETAILS order by session_key;
============
PAD WINDOWS
run
{
shutdown immediate;
startup mount;
allocate channel c1 device type disk;
backup as compressed backupset database format 'G:\Rman_Cold_bkp\SFMS\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'G:\Rman_Cold_bkp\SFMS\ctl_%d_%D_%M_%Y_%s.bkp';
alter database open;
}
======
run
{
shutdown immediate;
startup mount;
allocate channel c1 device type disk;
backup as compressed backupset database format 'G:\Rman_Cold_bkp\NEFT\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'G:\Rman_Cold_bkp\NEFT\ctl_%d_%D_%M_%Y_%s.bkp';
alter database open;
}
run
{
allocate channel c1 device type disk;
backup as compressed backupset database format 'G:\Rman_Cold_bkp\SFMS\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'G:\Rman_Cold_bkp\SFMS\ctl_%d_%D_%M_%Y_%s.bkp';
}
run
{
allocate channel c1 device type disk;
backup as compressed backupset database format 'G:\Rman_Cold_bkp\NEFT\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'G:\Rman_Cold_bkp\NEFT\ctl_%d_%D_%M_%Y_%s.bkp';
}
=============RMANCHECK====================
set lines 100 pages 100
col STATUS format a9
col min format 999.99
select SESSION_KEY, INPUT_TYPE, STATUS,to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,to_char(END_TIME,'mm/dd/yy hh24:mi')
end_time, round(elapsed_seconds/60,2) mis,round(OUTPUT_BYTES/1024/1024,2) "SizeMB" from V$RMAN_BACKUP_JOB_DETAILS order by session_key;
===========================================================
set lines 100 pages 100
col STATUS format a9
col min format 999.99
select SESSION_KEY, INPUT_TYPE, STATUS,to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,to_char(END_TIME,'mm/dd/yy hh24:mi') end_time, round(elapsed_seconds/60,2) mis,round(OUTPUT_BYTES/1024/1024,2) "SizeMB" from V$RMAN_BACKUP_JOB_DETAILS order by session_key;
PDCS3V3:/app/scr #
PDCS3V3:/app/scr #
PDCS3V3:/app/scr #
PDCS3V3:/app/scr # cat long.sql
=========================
set lines 150
select SID, SERIAL#, opname, START_TIME,TOTALWORK, sofar, (sofar/totalwork) * 100 done,
TIME_REMAINING/60 "Re Minute"
from v$session_longops
where totalwork > sofar
AND opname NOT LIKE '%aggregate%';
==================$$$$$$$$$$$$$$$$$$=============
SELECT
opname,
target,
ROUND((sofar/totalwork),4)*100 Percentage_Complete,
start_time,
CEIL(time_remaining/60) Max_Time_Remaining_In_Min,
FLOOR(elapsed_seconds/60) Time_Spent_In_Min
FROM v$session_longops
WHERE sofar != totalwork;
================0000000000000000000 PAD BACKUP 00000000000000000000=================
@echo OFF
set host=%COMPUTERNAME%
set oracle_home=E:\app\Administrator\product\11.2.0\db_1
#set backupstr="SFMS_%host%_%pdate%_%ptime%"
#set backupstr=%backupstr:/=-%
set dirname=Y:\EXPORTBKP
set dirname1=Y:\RMANCOLDBKP
md %dirname1%\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%
set oracle_sid=sfms
expdp 'sys/sys@SFMS as sysdba' DIRECTORY=DATA_PUMP_DIRECTORY DUMPFILE=SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%.dmp LOGFILE=SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%.log full=y
rman target 'sys/sys as sysdba' cmdfile 'H:\RMAN_COLD_BKP_RP\rmancold_sfms' log=Y:\RMANCOLDBKP\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%_rmancold.log
echo User exeuting backup is: %DB_USERNAME% >> Y:\RMANCOLDBKP\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%_rmancold.log
move H:\Rman_Cold_bkp\SFMS\*.BKP Y:\RMANCOLDBKP\SFMS_%host%_%pdate%_%ptime%_%DB_USERNAME%\
move H:\Rman_Cold_bkp\dpdump\*.DMP Y:\EXPORTBKP\
move H:\Rman_Cold_bkp\dpdump\*.log Y:\EXPORTBKP\
=========^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^================================
@snapshot standby
Steps to convert physical standby to snapshot standby and then again revert it to physical standby
If below parameters are already set then no need for below changes or else set below parameters before start as it should be required for snapshot standby
alter system set db_recovery_file_dest_size=4GB;
alter system set db_recovery_file_dest='PATH;
alter database recover managed standby database cancel;
shutdown immediate;
startup mount;
alter database convert to snapshot standby;
shutdown immediate;
startup;
*/ ----Ash Application team to do their testing once they will finish with their testing follow below step for converting snapshot standby to physical standby ---*/
shutdown immediate;
startup mount;
alter database convert to physical standby;
Shutdown immediate;
startup mount;
alter database recover managed standby database disconnect from session;
catalog device type 'SBT_TAPE' backuppiece 'NEFTDB_03_01_2015_1765.bkp';
=======
RMAN ARCHIVE DELETIONS
delete archivelog until time = 'sysdate-12' backed up 1 times to disk ;
delete archivelog all backed up 1 times to device type SBT;
delete archivelog all completed before 'sysdate';
delete archivelog all backed up 2 times to DEVICE TYPE disk; completed before 'sysdate-1';
delete archivelog all backed up 1 times to DEVICE TYPE disk completed before 'sysdate';
delete archivelog until time 'sysdate' backed up 1 times to disk;
delete archivelog all backed up 2 times to sbt;
run
{
allocate channel t1 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo-MWF.opt)';
delete archivelog all backed up 2 times to device type sbt;
release channel t1;
}
run
{
allocate channel t1 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo-TTS.opt)';
catalog backuppiece 'SFMSDBRPT_04_04_2015_242.bkp';
release channel t1;
}
alter system set log_archive_dest_state_2=DEFER scope=both;
alter system set log_archive_dest_state_3=DEFER scope=both;
============================================
CONVERTING PHYSICAL STANDBY DATABASE TO SNAPSHOT STANDBY DATABASE
http://www.orafaq.com/node/2505
alter system set log_archive_config='DG_CONFIG=(SFMS_BEL,SFMS_KHAR,SFMS_NAG,SFMS_KHR)' scope=both;
alter system set log_archive_dest_4='SERVICE=SFMS_KHR LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_KHR' scope=both;
alter system set log_archive_dest_state_4=DEFER scope=both;
alter system set log_archive_dest_state_4=ENABLE scope=both;
alter database recover managed standby database cancel;
shut immediate;
startup nomount;
alter database mount standby database;
alter database convert to snapshot standby;
alter database open;
shut immediate;
startup nomount;
alter database mount;
alter database convert to physical standby;
shut immediate;
startup nomount;
alter database mount standby database;
NORMAL Standby : ALTER DATABASE RECOVER managed standby database disconnect from session;
REAL-TIME APPLY : ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
SELECT dest_id,max(SEQUENCE#) FROM V$ARCHIVED_LOG where applied='YES' group by dest_id;
select name,open_mode,controlfile_type,database_role from v$database;
SELECT PROCESS, STATUS,sequence# FROM V$MANAGED_STANDBY;
set lines 200
set pages 200
col DEST_NAME for a30
PROD : select dest_id,DEST_NAME,STATUS,DB_UNIQUE_NAME,RECOVERY_MODE,DATABASE_MODE,error from v$archive_dest_status;
PROD : SELECT dest_id,max(SEQUENCE#) FROM V$ARCHIVED_LOG where applied='YES' group by dest_id;
STANDBY : select * from v$dataguard_stats;
=====
DATAGAURD Stopping & Starting Process:
Stopping
1)SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;
Canceling recover operation.
2)ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
3)SELECT NAME, SEQUENCE#, ARCHIVED, APPLIED FROM V$ARCHIVED_LOG;
4)SHUTDOWN IMMEDIATE;
------
Starting
1)STARTUP NOMOUNT;
2)ALTER DATABASE MOUNT STANDBY DATABASE;
3)ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
ALTER DATABASE RECOVER managed standby database disconnect from session;
alter database recover managed standby database cancel;
SELECT dest_id,max(SEQUENCE#) FROM V$ARCHIVED_LOG where applied='YES' group by dest_id;
select DEST_ID,DATABASE_MODE,ERROR,DB_UNIQUE_NAME from v$archive_dest_status;
=================================================
@drerror
set lines 200
set pages 200
col DEST_NAME for a30
select dest_id,DEST_NAME,STATUS,DB_UNIQUE_NAME,RECOVERY_MODE,DATABASE_MODE,error from v$archive_dest_status;
=====================================================
@DRDrill Swicthover
@switchover:
+++++++++
set lines 200
set pages 200
col host_name for a20
select instance_name,host_name,name,open_mode,log_mode,database_role,switchover_status from v$database,v$instance;
AT PDC SITE: it will become standby
===========
1) alter database commit to switchover to physical standby with session shutdown;
2) shut immediate;
3) startup nomount;
4) alter database mount standby database;
5) alter database recover managed standby database disconnect from session;
AT ODC SITE: it will become primary
============
1)alter database recover managed standby database cancel;
2)alter database commit to switchover to primary;
3)shut immediate;
4)startup
swithBack:
++++++++++
AT ODC SITE: this is primary
============
1) alter database commit to switchover to physical standby with session shutdown;
2) shutdown immediate;
3) startup mount;
4) alter database recover managed standby database disconnect from session;
AT PDC SITE: this is standby
===========
1)alter database recover managed standby database cancel;
2)alter database commit to switchover to primary;
3)shutdown immediate;
4)startup;
NOte: onece it open we need to start recover at standby side
Rajwinder
On Primary:
SQL> Set lines 200 pages 50
SQL > select dest_id,STATUS,database_mode,recovery_mode, archived_seq#, error,gap_status from v$archive_dest_status;
SQL > select thread#, max(sequence#) "Last Primary Seq Generated"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
On Standby:
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied" , almax-lhmax "Sequence Difference"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd;
SQL> select PROCESS,STATUS,THREAD#,SEQUENCE#,BLOCK#,BLOCKS
from v$managed_standby
where process like '%MRP%';
@pending arch:
--------------
set linesize 1200
set pagesize 1200
select * from (select sequence#,archived,applied from v$archived_log order by sequence# desc) where rownum<=20 order by rownum desc;
=====================================================================
expdp directory=EXPDP_DIR dumpfile=NTT_NIL_TRN_TBL1.dmp logfile=NTT_NIL_TRN_TBL1.log TABLES=NEFT.NTT_NIL_TRN_TBL
date +%d%m%Y_%H%M%S
For ORA-03137 : TTC Protocol :: Bug 8625762
=====================================================================
To be executed on : 172.22.196.201 NEFT & SFMS Reporting DB Server on 03-Feb-2015
export ORACLE_SID=NEFT
expdp directory=EXPDP_FULL dumpfile=NEFT_FULL_03FEB2015_%U.dmp logfile=NEFT_FULL_03FEB2015.log FULL=Y COMPRESSION=ALL parallel=4 filesize=20G
export ORACLE_SID=SFMS
expdp directory=EXPDP_FULL dumpfile=SFMS_FULL_03FEB2015.dmp logfile=SFMS_FULL_03FEB2015.log FULL=Y COMPRESSION=ALL
$ cd /backup
$ mkdir TEST
SQL> create directory EXPDP_FULL1 as '/backup/TEST';
$ expdp directory=EXPDP_FULL1 dumpfile=SFMSBR_24Apr2015_%U.dmp logfile=SFMSBR_24Apr2015.log schemas=SFMSBR COMPRESSION=ALL parallel=4 filesize=15G
==========================================================================================
---- FULL DB BACKUP ----
vi ncat_lvl0_backup_CDBD_disk.cmd
CONFIGURE CONTROLFILE AUTOBACKUP ON;
run {
allocate channel 'D1' type DISK FORMAT '/b001/rman/CDBD/hot/lvl0_DB_%d_%c_%U_%D%M%Y.bak';
allocate channel 'D2' type DISK FORMAT '/b001/rman/CDBD/hot/lvl0_DB_%d_%c_%U_%D%M%Y.bak';
allocate channel 'D3' type DISK FORMAT '/b002/rman/CDBD/hot/lvl0_DB_%d_%c_%U_%D%M%Y.bak';
sql 'alter system archive log current';
set controlfile autobackup format for device type disk to '/b001/rman/CDBD/hot/cf_%F';
backup incremental level 0 as compressed backupset database plus archivelog skip inaccessible;
sql 'alter system archive log current';
copy current controlfile to '/b001/rman/CDBD/hot/CDBD_control_hot_%t.ctl';
release channel 'D1';
release channel 'D2';
release channel 'D3';
}
CONFIGURE CONTROLFILE AUTOBACKUP ON;
exit
---- ARCH Backup ----
vi ncat_arch_backup_CDBD_disk.cmd
configure controlfile autobackup off;
run {
allocate channel D1 device type disk;
sql 'alter system archive log current';
backup as compressed
backupset format '/b001/rman/CDBD/arch/CDBD_003_arch_ncat_DB_%d_%F_%p.bak'
archivelog all not backed up 1 times;
delete noprompt force archivelog all backed up 1 times to device type disk;
sql 'alter system archive log current';
allocate channel 'D2' type disk;
copy current controlfile to '/b001/rman/CDBD/control/CDBD_control_hot_%t.ctl';
release channel 'D2';
release channel 'D1';
}
configure controlfile autobackup on;
exit
======================
DELETE ARCHIVELOG UNTIL SEQUENCE = 75200;
delete archivelog until time = 'sysdate-1' backed up 1 times to sbt_tape ;
delete archivelog all backed up 1 times; before 'sysdate';
delete archivelog all not backed up 2 times to device type sbt_tape;
delete archivelog all completed before 'sysdate-1';
======================
Delete from TAPE, where backup OLDER then 17 Days (sysdate - 17)
bash-4.2$ cat /sd_oraBkp/DBA_Activity/DBA_Script/config/delete_RMANBKP_TAPE.sh
#---Export current date
dy=`date "+%d%m%y-%H%M"`
export dy
echo "Starting Backup HouseKeeping Activity" > /sd_oraBkp/DBA_Activity/rman_bkp/obsolete_log/rman_deletion_tape_$dy.log
echo "*************************:CHECKING THE OBSOLETE BACKUP AND DELETING THE OBSOLETE BACKUP:****************************"
#---RMAN full backup script
#---Connect Target Database and Create RMAN Log File
rman TARGET / << EOF>>/sd_oraBkp/DBA_Activity/rman_bkp/obsolete_log/rman_deletion_tape_$dy.log
allocate channel for maintenance device type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
list backup completed before 'sysdate-17';
delete noprompt backup completed before 'sysdate-17';
exit;
eof
bash-4.2$ cd /sd_oraBkp/DBA_Activity/rman_bkp/obsolete_log/
======================
delete archivelog all backed up 1 times to device type Sbt_Tape;
FULL_BKP_%d_set%s_piece%p_%T_%U for backupsets when duplexing is not used.
For duplexing backup it would be FULL_BKP_%d_set%s_piece%p_copy%c_%T_%U
•%d : name of database
•%s :backup set number. (Unique for controlfile lifetime)
•%p :piece number in backup set.
•%T : Specified date in format YYYYMMDD
•%U : Unique number consist of %u_%p_%c
•%c : copy number of backup piece.when duplexing of backup
If no format is specified, Oracle by default uses %U.For controlfile autobackup, I prefer to use default config which is %F.This tag has DBID in the filename which would be necessary in the case of recovery when RMAN catalog is not accessible.This tag can not be used for backup sets.
==========================================================================================
orakill
@logon
SELECT s.inst_id,
s.sid,
s.serial#,
p.pid,
p.spid,
s.username,
s.program,
s.osuser
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id;
-- WHERE s.type != 'BACKGROUND';
SELECT s.inst_id,
s.sid,
s.serial#,
p.pid,
p.spid,
s.username,
s.program
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
where p.spid = 11222;
-------------------------------------------------------------------------------------------------------------------------------------------
crontab setting
00 20 01 03 * /u01/app/oracle/global/bin/rman/scripts/backup_db_logwatcher.ksh cdbp2 levl0_cdbp2_2tape.cmd >/dev/null
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
434779241
BEGIN
DBMS_STATS.gather_table_stats('RSPROD_ARCH',
'REQUEST',
ESTIMATE_PERCENT => 0.1,
METHOD_OPT => 'FOR COLUMNS CLOSEDDATE SIZE 254');
END;
/
select count(*) from V$FAST_START_TRANSACTIONS;
file://C:\Program Files (x86)\lucky leap\bin\Pac9064.js
http://autocache.hp.com/
HP LAPTOP 15R014tx
=====================================
oradw @ sf03s03xxd07:cmfd1
[/home/ais/oradw]$
tokill=`ps -fea|grep mon_ts|awk '{ printf $2" "}'`; kill -9 $tokill;
========================================
landed in similar situation.
I executed command
nid target=sys/pnt4vm dbname=PNT4VM
before renaming/creating the tempfile and was struck with error.
NID-00111: Oracle error reported from target database while executing
begin dbms_backup_restore.nidprocessdf(:fno, :istemp, :skipped, :idchged, :nmchged)
; end;
ORA-01116: error in opening database file F:\ORACLE\ORADATA\PNT4\TEMP02.DBF
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.
ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 6164
ORA-06512: at line 1
WorkAround.
This is what I understood.
If I try reverting (nid target=sys/pnt4vm REVERT=Y) the revert process agains fails. But it reverts all the datafiles except file 01 i.e. SYSTEM.DBF. So as a workaround, I performed following steps.
1) Executed the command
nid target=sys/pnt4vm dbname=PNT4VM
This will fail.
2) Shut down the database.
3) Take Backup of Existing control file.
4) Generate trace for Control file.
5) Remove the existing control files.
6) Edit the parameter file with new DB_NAME
7) Start the Instance in Nomount Stage.
8) Create the control files with SET option. (New DB NAme)
9) Open database with Resetlogs.
10) Add the tempfiles to temp tablespace.
=============================================================
RDA
DFSprod_sys
OVSsys
==========================================================================
DATAGAURD Stopping & Starting Process:
Stopping
1)SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;
Canceling recover operation.
2)ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
3)SELECT NAME, SEQUENCE#, ARCHIVED, APPLIED FROM V$ARCHIVED_LOG;
4)SHUTDOWN IMMEDIATE;
------
Starting
1)STARTUP NOMOUNT;
2)ALTER DATABASE MOUNT STANDBY DATABASE;
3)ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
ALTER DATABASE RECOVER managed standby database disconnect from session;
alter database recover managed standby database cancel;
===================================================
=====================================================================
col name for a50
SELECT NAME, max(SEQUENCE#), ARCHIVED, APPLIED FROM V$ARCHIVED_LOG where applied='YES' and name not like '%sd_ora%'group by name, ARCHIVED, APPLIED;
SELECT max(SEQUENCE#) FROM V$ARCHIVED_LOG where applied='YES';
alter system set log_archive_config='DG_CONFIG=(SFMS_BEL,SFMS_KHAR,SFMS_NAG,SFMS_KHR)' scope=both;
alter system set log_archive_dest_4='SERVICE=SFMS_KHR LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=SFMS_KHR' scope=both;
alter system set log_archive_dest_state_4=DEFER scope=both;
alter system set log_archive_dest_state_4=ENABLE scope=both;
CREATE OR REPLACE PROCEDURE TRUNCATE_TABLE_PROC (oname IN varchar2,
tname IN varchar2 ) as
/**********************************
AUTHOR JP Vijaykumar
Oracle DBA
DATE 10-05-2006
**********************************/
begin
execute immediate 'truncate table '||oname||'.'||tname;
exception
when others then
raise_application_error(-20001,'Insufficient privileges');
end;
The above truncate table procedure is a simple procedure. Whoever is granted EXECUTE privileges on the procedure can truncate any table in the database.
===== WEUP Proc. ======================================================
1-- Truncating Procedure Will created by Oracle DBA
CREATE PROCEDURE IWAM_STG.TRUNC_DEL_TABLE (btch IN number) as
begin
delete from iwam_stg.load_status_as400 where batch_id = btch;
commit;
execute immediate 'truncate table IWAM_STG.unified_data_as400';
exception
when others then
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR (-20001, btch || ':$:' || SQLERRM, TRUE) ;
end IWAM_STG.TRUNC_DEL_TABLE;
/
2-- Privilege granted to XYZ_User by Oracle DBA on this Truncate proc
grant execute on IWAM_STG.TRUNC_DEL_TABLE to XYZ_User;
3-- Execute Backup & Truncate and deleting procedure in XYZ_User with BATCH_ID Parameter in brackets () to be deleted, from single script created by Us
A. vi rr.sh <== If running from Oracle DB Server, other / Oracle User
a. export ORACLE_HOME
b. export ORACLE_SID
c. expdp xyz_user/xyz_user directory=XYZ_EXPDP filename=Table2_$DT.dmp logname=Table2_$DT.log schemas=iwam_stg tables=(IWAM_STG.unified_data_as400,iwam_stg.load_status_as400)
d. gzip Table2_$DT.dmp
e. sqlplus xyz_user/xyz_user @trunc_del_Proc.sql
e.1. vi trunc_del_Proc.sql ==> execute IWAM_STG.TRUNC_DEL_TABLE(874);
OR OR OR
B. execute IWAM_STG.TRUNC_DEL_TABLE(874); <== If running from TOAD / SQL Developer / etc... & not from logging on to Oracle DB Server
=====================================
@listenerpurging
LSNRCTL> set Log_status off
LSNRCTL> status --check the path of listenerlog
LSNRCTL> exit
Test $> mv listener.log listener_old.log
Test $> touch listener.log
Test $> lsnrctl
LSNRCTL> set Log_Status on
LSNRCTL> exit
====================================
& set LOGGING_LISTENER=OFF in the listener.ora file to stop the listener logging.
=========================================================
00 00,01,02,03,04,05,06,07 27 12 * /u02/orashare/oracle/scripts/dbei/gen200/prd/bin/cronstub.ksh /u02/orashare/oracle/scripts/dbei/ora225/prd/bin/rman.ksh pfubsfll RMAN_Backup/runarchivebkup.rman -n > /u02/orashare/oracle/scripts/dbeiwork/rmanlogs/runarchivebkup_pfubsfll.lst 2>&1
-- All versions. TRACE
SQL> ALTER SESSION SET sql_trace=TRUE;
SQL> ALTER SESSION SET sql_trace=FALSE;
SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => TRUE);
SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => FALSE);
h
yh
SQL> ALTER SESSION SET EVENTS '10046 trace name context forever, level 8';
SQL> ALTER SESSION SET EVENTS '10046 trace name context off';
@traceuser
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>TRUE);
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>FALSE);
SQL> EXEC DBMS_SYSTEM.set_ev(si=>123, se=>1234, ev=>10046, le=>8, nm=>' ');
SQL> EXEC DBMS_SYSTEM.set_ev(si=>123, se=>1234, ev=>10046, le=>0, nm=>' ');
-- Available from SQL*Plus since 8i (commandline utility prior to this.
SQL> CONN sys/password AS SYSDBA; -- User must have SYSDBA.
SQL> ORADEBUG SETMYPID; -- Debug current session.
SQL> ORADEBUG SETOSPID 1234; -- Debug session with the specified OS process.
SQL> ORADEBUG SETORAPID 123456; -- Debug session with the specified Oracle process ID.
SQL> ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12;
SQL> ORADEBUG TRACEFILE_NAME; -- Display the current trace file.
SQL> ORADEBUG EVENT 10046 TRACE NAME CONTEXT OFF;
-- All versions, requires DBMS_SUPPORT package to be loaded.
SQL> EXEC DBMS_SUPPORT.start_trace(waits=>TRUE, binds=>FALSE);
SQL> EXEC DBMS_SUPPORT.stop_trace;
SQL> EXEC DBMS_SUPPORT.start_trace_in_sessivx'bon(sid=>123, serial=>1234, waits=>TRUE, binds=>FALSE);
SQL> EXEC DBMS_SUPPORT.stop_trace_in_session(sid=>123, serial=>1234);
tkprof dev1_ora_367660.trc translated.txt explain=test/test table=sys.plan_table sys=no waits=yes
ORADEBUG SETOSPID 11228;
ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12;
ORADEBUG TRACEFILE_NAME;
ORADEBUG EVENT 10046 TRACE NAME CONTEXT OFF;
=== Rename DB P44 to T44, by NID
nid target=/ DBNAME=T44
nid target=/ DBNAME=metad1
=============================
oradim -NEW -SID P36
===============================
ed large
set pagesize 100
set linesize 500
col sid format 99999
col username format a10 truncated
col status format a1 truncated
col logon format a19
col idle format a9
col program format a30 truncated
col running_since format a15
col event format a35
select
TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI'),a.inst_id,a.sid,a.event,a.username,a.status,a.sql_hash_value,
to_char(logon_time,'dd-mm-yy hh:mi:ss') "LOGON",
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "RUNNING_SINCE",
a.program
from
gv$session a
where
a.type='USER'
AND floor(last_call_et/3600)*60+floor(mod(last_call_et,3600)/60) > 10
AND a.STATUS = 'ACTIVE'
AND a.SID > 10
order by a.last_call_et
/
OWIP 426 Server
bash-3.2$ cat rr_rman.sh
echo "" > rr.sh
BCKUP_DIR=/b01/rman/PNEOLOG/arch
cd $BCKUP_DIR
echo "`pwd`"
LSL=`ls *.bak`
echo "LSL : $LSL"
cd $BCKUP_DIR >> rr.sh
for filename in $LSL
do
echo "Processing : $filename"
echo "gzip $filename "
echo "gzip $filename &" >> rr.sh
done
chmod 755 rr.sh
./rr.sh &
================
create or replace trigger LOGG_TRAIL
before alter on database
when (ora_dict_obj_type = 'USER'
and ora_dict_obj_name != user
and sys_context('USERENV','ISDBA') = 'FALSE' );
declare
by_user varchar2(30);
to_user varchar2(30);
vprofile varchar2(30);
begin
select to.PROFILE into vprofile
from DBA_USERS by, DBA_USERS to
where by.USERNAME = user
and to.USER_NAME = ora_dict_obj_name
and by.PROFILE = to.PROFILE;
insert into TRAIL_TEMP (USER_ALTERED, PASSWORD_MODIFIED_BY, PASSWORD_MODIFIED_DATE, PROFILE)
values (ora_dict_obj_name, user, sysdate, vprofile);
exception
when others then raise_application_error (-20001,'can''t alter user');
end;
/
select to.PROFILE
from DBA_USERS by, DBA_USERS to
where by.USERNAME = user
and to.USER_NAME = ora_dict_obj_name
and by.PROFILE = to.PROFILE;
find / -name "mailx" 2>/dev/null
echo "This is the body."| mailx -s "mailx Test1" ronak.darji@hp.com 2> ./rr.out
echo "This is the body."| /usr/bin/mailx -s "mailx Test1" ronak.darji@hp.com 2> ./rr.out
echo "This is the body."| /bin/mailx -s "mailx Test1" ronak.darji@hp.com 2> ./rr.out
/bin/mailx -r oracle@o-i.com -s "RMAN Backup SUCCESSFUL" ronak.darji@hp.com anup.biswas@hp.com < ./testMail.out
/bin/mail -s "RMAN FAILURE (${HN}:${ORACLE_SID}) " `cat /u001/app/oracle/dba/dba_fail.lst|grep -v "#"` -- -f rman@convatec.com < ${RMAN_LOG_FL}
/bin/mail -s "RMAN FAILURE : TEST rr" ronak.darji@hp.com anup.biswas@hp.com -- -f ronak.darji@hp.com < ./dead.letter
SQL> select name,state,total_mb,free_mb from gv$asm_diskgroup;
NAME STATE TOTAL_MB FREE_MB
------------------------------ ----------- ---------- ----------
DATA MOUNTED 379276 378867
FRA MOUNTED 28610 26008
DATA DISMOUNTED 0 0
FRA DISMOUNTED 0 0
SQL> drop diskgroup FRA including contents;
Diskgroup dropped.
SQL> select name,state,total_mb,free_mb from gv$asm_diskgroup;
NAME STATE TOTAL_MB FREE_MB
------------------------------ ----------- ---------- ----------
DATA MOUNTED 379276 378867
DATA DISMOUNTED 0 0
SQL> drop diskgroup DATA including contents;
Diskgroup dropped.
SQL> select name,state,total_mb,free_mb from gv$asm_diskgroup;
no rows selected
UMG - Donot Close CLOSE only RESOLVE
*************************************************************************************************************
echo "=================================================================" >> ./cp_rr.log
echo "===========S T A R T :- `date` ============" >> ./cp_rr.log
echo "Enter Date of the Files needs to be COPIED e.g Feb 11 or Feb 2"
read dg1
mkdir cp_rr
fn1=`ls -ltr | grep "$dg1" | sed "s/ /;/g" | sed "s/ /;/g" | sed "s/ /;/g" | sed "s/;;;/;/g" | sed "s/;;/;/g" | sed "s/;;/;/g" | cut -d';' -f9`
##echo "dg1"
ls -ltr | grep "$dg1"
ls -ltr | grep "$dg1" >> ./cp_rr.log
echo " "
echo " " >> ./cp_rr.log
echo "================================================================="
echo "===========S T A R T :- `date` ============"
for filename in $fn1
do
cp $filename cp_rr/
echo "File COPIED :- $filename"
echo "File COPIED :- $filename" >> ./cp_rr.log
done
echo "============= E N D :- `date` ============" >> ./cp_rr.log
echo "============= E N D :- `date` ============"
*************************************************************************************************************
Script Deletes only required dated Files only
oracle@ustlvoi424>/export/home/oracle>cat Del_rr.sh
echo "=================================================================" >> ./Del_rr.log
echo "===========S T A R T :- `date` ============" >> ./Del_rr.log
echo "Enter Date of the GZ Files needs to be deleted e.g Feb 11 or Feb 2"
read dg1
fn1=`ls -ltr *.gz | grep "$dg1" | sed "s/ /;/g" | sed "s/ /;/g" | sed "s/ /;/g" | sed "s/;;;/;/g" | sed "s/;;/;/g" | cut -d';' -f9`
##echo "dg1"
ls -ltr *.gz | grep "$dg1"
ls -ltr *.gz | grep "$dg1" >> ./Del_rr.log
echo " "
echo " " >> ./Del_rr.log
echo "================================================================="
echo "===========S T A R T :- `date` ============"
for filename in $fn1
do
rm $filename
echo "File Deleted :- $filename"
echo "File Deleted :- $filename" >> ./Del_rr.log
done
echo "============= E N D :- `date` ============" >> ./Del_rr.log
echo "============= E N D :- `date` ============"
*************************************************************************************************************
echo "=================================================================" >> ./GZIP_rr.log
echo "===========S T A R T :- `date` ============" >> ./GZIP_rr.log
echo "Enter Files Extension needs to be GZIPPED e.g dmp"
read dg1
fn1=`ls *.$dg1`
cnt=`ls *.$dg1 | wc -l`
echo "fn1 : $fn1 : $cnt"
for filename in $fn1
do
echo "Pending $dg1 Files to be GZIPPED : $cnt"
cnt=`expr $cnt - 1`
gzip $filename
echo "File GZIPPED :- $filename"
echo "File GZIPPED :- $filename" >> ./GZIP_rr.log
done
echo "============= E N D :- `date` ============" >> ./GZIP_rr.log
echo "============= E N D :- `date` ============"
*************************************************************************************************************
/u07/oraexport/pfcdb/GZIP_rr.sh > /u07/oraexport/pfcdb/GZIP_rr1.log 2> /u07/oraexport/pfcdb/GZIP_rr1.err &
CONVERTING from RAC to NON-RAC, Online Redo Log file dropping from THREAD 2 / NODE 2
SQL> select THREAD#, STATUS, ENABLED
2 from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED PRIVATE
SQL> select group# from v$log where THREAD#=2;
GROUP#
----------
4
5
6
SQL> alter database disable thread 2;
Database altered.
SQL> alter database clear unarchived logfile group 4; ( repeat for 4 to 6)
Database altered.
SQL> alter database drop logfile group 4; ( repeat for 4 to 6)
Database altered.
- Now you can remove the undo tablespaces of other instances.
SQL> show parameter undo;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL> select tablespace_name from dba_tablespaces where contents='UNDO';
TABLESPACE_NAME
------------------------------
UNDOTBS1
UNDOTBS2
SQL> drop tablespace UNDOTBS2 including contents and datafiles;
Tablespace dropped.
**************************************************************
cat db_mon.cfg | grep 15m | grep -v ^"#" | grep -v l$
select table_name,partition_name,SUBPARTITION_COUNT,HIGH_VALUE,TABLESPACE_NAME,last_analyzed from dba_tab_partitions where table_name='&SMA_FAC_DIG_SALES';
========ORACLE GRID & DB HOME PSU Patch
opatch lsinventory -detail
@cpupatch:
----------
unzip p21972320_112040_AIX64-5L.zip
cd 21972320
export PATH=$ORACLE_HOME/OPatch:$PATH
opatch lsinventory
opatch version
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
opatch napply -skip_subset -skip_duplicate
opatch lsinventory | grep applied
opatch version
sqlplus / as sysdba
@?/rdbms/admin/catbundle.sql cpu apply
@?/rdbms/admin/utlrp.sql
set lines 200
set pages 200
set time on
col ACTION_TIME for a35
col ACTION for a12
col NAMESPACE for a12
col VERSION for a12
col COMMENTS for a30
col BUNDLE_SERIES for a10
select * from registry$history;
$ opatch version
$ opatch lsinventory
###########################################################################3
#opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./13696242
opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./
.As root user execute:
# opatch auto <UNZIPPED_PATCH_LOCATION> -oh <ORACLE_HOME>
echo $PATH
export PATH=/u01/app/crs/11.2.0.3/grid/OPatch:$PATH
cd <PSU_Location>
opatch auto <PSU_Location> -oh /u01/app/crs/11.2.0.3/grid -local
Case 5: Patching a Software Only GI Home Installation
1.Apply the CRS patch using.
As the GI home owner execute:
$ <GI_HOME>/OPatch/opatch napply -oh <GI_HOME> -local <UNZIPPED_PATCH_LOCATION>/13696242
As the GI home owner execute:
$ <GI_HOME>/OPatch/opatch napply -oh <GI_HOME> -local <UNZIPPED_PATCH_LOCATION>/13923804
Case 6: Patching a Software Only Oracle RAC or Oracle RAC One Node Home Installation
1.Run the pre script for DB component of the patch.
As the database home owner execute:
$ <UNZIPPED_PATCH_LOCATION>/13696242/custom/server/13696242/custom/scripts/prepatch.sh -dbhome <ORACLE_HOME>
2.Apply the DB patch.
As the database home owner execute:
$ <ORACLE_HOME>/OPatch/opatch napply -oh <ORACLE_HOME> -local <UNZIPPED_PATCH_LOCATION>/13696242/custom/server/13696242
$ <ORACLE_HOME>/OPatch/opatch napply -oh <ORACLE_HOME> -local <UNZIPPED_PATCH_LOCATION>/13923804
3.Run the post script for DB component of the patch.
As the database home owner execute:
$ <UNZIPPED_PATCH_LOCATION>/13696242/custom/server/13696242/custom/scripts/postpatch.sh -dbhome <ORACLE_HOME>
=================================================================================================================================
@racpatching
All-Node Patch
--------------
. Shutdown all Oracle instances on all nodes
. Apply the patch to all nodes
. Bring all nodes up
Minimum downtime
----------------
. Shutdown the Oracle instance on node 1
. Apply the patch to the Oracle instance on node 1
. Shutdown the Oracle instance on node 2
. Apply the patch to the Oracle instance on node 2
. Shutdown the Oracle instance on node 3
. At this point, instances on nodes 1 and 2 can be brought up
. Apply the patch to the Oracle instance on node 3
. Startup the Oracle instance on node 3
Rolling patch (no downtime)
---------------------------
. Shutdown the Oracle instance on node 1
. Apply the patch to the Oracle instance on node 1
. Start the Oracle instance on node 1
. Shutdown the Oracle instance on node 2
. Apply the patch to the Oracle instance on node 2
. Start the Oracle instance on node 2
. Shutdown the Oracle instance on node 3
. Apply the patch to the Oracle instance on node 3
. Start the Oracle instance on node 3
==========================================================================================================================================
2.5.2 Loading Modified SQL Files into the Database
The following steps load modified SQL files into the database. For an Oracle RAC or Oracle RAC One Node environment, perform these steps on only one node.
1.For each database instance running on the Oracle home being patched, connect to the database using SQL*Plus. Connect as SYSDBA and run the catbundle.sql script as follows:
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @?/rdbms/admin/catbundle.sql psu apply
SQL> QUIT
The catbundle.sql execution is reflected in the dba_registry_history view by a row associated with bundle series PSU.
For information about the catbundle.sql script, see My Oracle Support Note 605795.1 Introduction to Oracle Database catbundle.sql.
2.Check the following log files in $ORACLE_BASE/cfgtoollogs/catbundle for any errors:
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log
where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS. If there are errors, refer to Section 3, "Known Issues".
2.5.3 Upgrade Oracle Recovery Manager Catalog
If you are using the Oracle Recovery Manager, the catalog needs to be upgraded. Enter the following command to upgrade it:
$ rman catalog username/password@alias
RMAN> UPGRADE CATALOG;
=====================================
Eliminating Migrated or Chained Rows in a Table
You can use the information in the CHAINED_ROWS table to reduce or eliminate migrated and chained rows in an existing table. Use the following procedure.
Use the ANALYZE statement to collect information about migrated and chained rows.
ANALYZE TABLE order_hist LIST CHAINED ROWS;
Query the output table:
SELECT *
FROM CHAINED_ROWS
WHERE TABLE_NAME = 'ORDER_HIST';
OWNER_NAME TABLE_NAME CLUST... HEAD_ROWID TIMESTAMP
---------- ---------- -----... ------------------ ---------
SCOTT ORDER_HIST ... AAAAluAAHAAAAA1AAA 04-MAR-96
SCOTT ORDER_HIST ... AAAAluAAHAAAAA1AAB 04-MAR-96
SCOTT ORDER_HIST ... AAAAluAAHAAAAA1AAC 04-MAR-96
The output lists all rows that are either migrated or chained.
If the output table shows that you have many migrated or chained rows, then you can eliminate migrated rows by continuing through the following steps:
Create an intermediate table with the same columns as the existing table to hold the migrated and chained rows:
CREATE TABLE int_order_hist
AS SELECT *
FROM order_hist
WHERE ROWID IN
(SELECT HEAD_ROWID
FROM CHAINED_ROWS
WHERE TABLE_NAME = 'ORDER_HIST');
Delete the migrated and chained rows from the existing table:
DELETE FROM order_hist
WHERE ROWID IN
(SELECT HEAD_ROWID
FROM CHAINED_ROWS
WHERE TABLE_NAME = 'ORDER_HIST');
Insert the rows of the intermediate table into the existing table:
INSERT INTO order_hist
SELECT *
FROM int_order_hist;
Drop the intermediate table:
DROP TABLE int_order_history;
Delete the information collected in step 1 from the output table:
DELETE FROM CHAINED_ROWS
WHERE TABLE_NAME = 'ORDER_HIST';
Use the ANALYZE statement again, and query the output table.
======================================
CREATE DISKGROUP TEST EXTERNAL REDUNDANCY DISK '/dev/oracleasm/disks/DG_TEST','/dev/oracleasm/disks/DG_TEST1','/dev/oracleasm/disks/DG_TEST2' ATTRIBUTE 'au_size'='4M',
'compatible.asm' = '11.2.0.3.0',
'compatible.rdbms' = '11.2.0.3.0',
'compatible.advm' = '11.2.0.3.0';
CREATE DISKGROUP DATADG EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_DATA2','ORCL:ARGQ_DATA3','ORCL:ARGQ_DATA4','ORCL:ARGQ_DATA5','ORCL:ARGQ_DATA6','ORCL:ARGQ_DATA7','ORCL:ARGQ_DATA8','ORCL:ARGQ_DATA9','ORCL:ARGQ_DATA10';
CREATE DISKGROUP UNDODG EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_UNDO1','ORCL:ARGQ_UNDO2','ORCL:ARGQ_UNDO3';
CREATE DISKGROUP TEMPDG EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_DATA1','ORCL:ARGQ_DATA2','ORCL:ARGQ_TEMP3';
CREATE DISKGROUP FRADG EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_FRA1','ORCL:ARGQ_FRA2','ORCL:ARGQ_FRA3','ORCL:ARGQ_FRA4','ORCL:ARGQ_FRA5','ORCL:ARGQ_FRA6';
CREATE DISKGROUP REDODG1 EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_REDO_1';
CREATE DISKGROUP REDODG2 EXTERNAL REDUNDANCY DISK 'ORCL:ARGQ_REDO_2';
select name,state,total_mb,free_mb,COMPATIBILITY,DATABASE_COMPATIBILITY from gv$asm_diskgroup;
alter diskgroup ARGQ_UNDO set attribute 'compatible.asm'='11.2';
alter diskgroup ARGQ_UNDO set attribute 'compatible.rdbms'='11.2';
==========================================
set lines 160
set pages 2002
set time on
column machine format a20
column event format a35
column program format a30
column schemaname for a10
column action format a50
column FC_cdt new_value file_time noprint
column FC_DB new_value file_DB noprint
select to_char(sysdate,'dd_mm_yyyy_hh24_mi_ss') FC_cdt from dual;
select instance_name FC_DB from gv$instance;
spool &file_DB._Session_Check_&file_time..txt
prompt ===== TOTAL SESSION ======
select count(*) from v$session;
prompt ===== SESSION Count as per EVENT ======
select event,count(*) from v$session group by event;
prompt ===== TOTAL SESSION DETAIL INFORMATION======
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,status from v$session
where logon_time not like sysdate
and schemaname not like 'SYS%'
order by logon_time;
spool off;
exit;
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,status from v$session
where sid = &SID order by logon_time desc;
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,status
from v$session
where event like '%gc%'
order by logon_time desc;
select snaps.begin_interval_time, snaps.instance_number,snaps.snap_id,hist.event_name , hist.wait_time_milli, hist.wait_count
from dba_hist_event_histogram hist, dba_hist_snapshot snaps
where snaps.snap_id = hist.snap_id and snaps.instance_number = hist.instance_number and
snaps.begin_interval_time > sysdate - 1/12 -- sysdate - 1/12 -> display AWR reports from the last 2 hours
AND hist.event_name like lower ('%log%')
order by 4,2,3;
-- order by snaps.snap_id , snaps.instance_number, wait_time_milli;
set lines 160
set pages 2002
set time on
column FC_cdt new_value file_time noprint
column FC_DB new_value file_DB noprint
select to_char(sysdate,'dd_mm_yyyy_hh24_mi_ss') FC_cdt from dual;
select instance_name FC_DB from gv$instance;
spool &file_DB._Session_Check_&file_time..txt
spool off;
exit;
===================================================
change archivelog all crosscheck;
crosscheck backup of database;
====******** DAILY QUERY *********=====
BLOCKING
=========
Recipie #1 - find blocking sessions with v$session
SELECT
s.blocking_session,
s.sid,
s.serial#,
s.seconds_in_wait
FROM
v$session s
WHERE
blocking_session IS NOT NULL;
Recipie #2 - find blocking sessions using v$lock
SELECT
l1.sid || ' is blocking ' || l2.sid blocking_sessions
FROM
v$lock l1, v$lock l2
WHERE
l1.block = 1 AND
l2.request > 0 AND
l1.id1 = l2.id1 AND
l1.id2 = l2.id2;
Recipie #3 - blocking sessions with all available information
The next query prints a few more information, it let's you quickly see who's blocking who. Run this query and you can immediately call the colleague who's locking your table
SELECT s1.username || '@' || s1.machine
|| ' ( SID=' || s1.sid || ' ) is blocking '
|| s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
FROM v$lock l1, v$session s1, v$lock l2, v$session s2
WHERE s1.sid=l1.sid AND s2.sid=l2.sid
AND l1.BLOCK=1 AND l2.request > 0
AND l1.id1 = l2.id1
AND l2.id2 = l2.id2 ;
==============================================================================================================
SILENT INSTALLATION
You can use the below command to run the silent mode and after installation finish, run root.sh with root privilege
cd /backup/11203/database/response
./runInstaller -silent -responseFile /u01/app/oracle/data/db/database/db_install_new.rsp
==============================================================================================================
@UPGRADATION to 11.2.0.3.8 PSU8
1. Install 11.2.0.3.0 Software -- 10404530
2. Database ( USUX52P5 ) upgrade to 11.2.0.3 on USHPEAVDBS016.
Pre-Upgrade TASKS From OLD HOME...DB
SQL> @$11g_ORACLE_HOME/rdbms/admin/utlu112i.sql
SQL> select * from registry$sys_inv_objs; -- Any invalid SYS/SYSTEM objects found before upgrading the database are stored in the table named registry$sys_inv_objs
SQL> PURGE dba_recyclebin
SQL> @utlrp.sql
SQL> Gather System Statistics
SQL> backup PFILE / SPFILE
Change Compatible parameter to 11.2.0.3
Upgrade TASK
SQL> STARTUP UPGRADE -- From New HOME
SQL> @?/rdbms/admin/catupgrd.sql
SQL> @utlu112s.sql -- the Post-Upgrade Status Tool, which provides a summary of the upgrade at the end of the spool log
SQL> @catuppst.sql
SQL> @utlrp.sql
SQL> SELECT count(*) FROM dba_invalid_objects;
SQL> SELECT distinct object_name FROM dba_invalid_objects;
•After the upgrade, run ORACLE_HOME/rdbms/admin/utluiobj.sql
3. Apply PSU 8 Patch on 11.2.0.3.0 -- 16902043
unzip p16902043_11203_<platform>.zip
cd 16902043
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
opatch apply
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle.sql psu apply
opatch lsinventory
===
POSSIBLE Errors
?ORA-00401: the value for parameter compatible is not supported by this release
The COMPATIBLE initialization parameter is set to a value less than 10.0.0.
?ORA-39701: database must be mounted EXCLUSIVE for UPGRADE or DOWNGRADE
The CLUSTER_DATABASE initialization parameter is set to TRUE instead of FALSE.
?ORA-39700: database must be opened with UPGRADE option
The STARTUP command was issued without the UPGRADE keyword.
?ORA-00336: log file size xxxx blocks is less than minimum 8192 blocks
A redo log file size is less than 4 MB:
===
1. Install 11.2.0.3.0 rdbms software
11.2.0.3 patch set is a full release. There is no need to install 11.2.0.1 software
See Note 1189783.1 Important Changes to Oracle Database Patch Sets Starting With 11.2.0.2
The software can be downloaded from My Oracle support: Patch:10404530
Please select your platform before downloading (Click on "Platform or Language" drop down menu)
if the platform name contains (32-bit) then it's 32-bit 11.2.0.3 client version
To install 11.2.0.3, you must download both p10404530_112030_<platform>_1of7.zip
and p10404530_112030_<platform>_2of7.zip
<platform> = your platform( ie for linux x86, download p10404530_112030_LINUX_1of7.zip and
p10404530_112030_LINUX_2of7.zip )
Note 1194734.1 : Where do I find that on My Oracle Support (MOS) [Video]
Note 549617.1 : How To Verify The Integrity Of A Patch/Software Download? [Video]
Note 169706.1 : Oracle Database Installation and Configuration Requirements Quick Reference (8.0.5 to 11.2)
The minimum version required to upgrade to 11.2.0.X.X is 9.2.0.8.0.
Note 551141.1 : Database Server Upgrade/Downgrade Compatibility Matrix
2. Upgrade the database to 11.2.0.3.0
Note 419550.1 : Different Upgrade Methods For Upgrading Your Database
Note 837570.1 : Complete Checklist for Manual Upgrades to 11gR2
Note 870814.1 : Complete checklist to upgrade the database to 11gR2 using DBUA
REFERENCE:
Availability and Known issues for 11.2.0.3 Note:1348336.1
11.2.0.3 Patch Set - List of Bug Fixes by Problem Type Note 1348303.1
Actions For DST Updates When Upgrading To Or Applying The 11.2.0.3 Patchset Note 1358166.1
==============================================================================================================
@postupg
SELECT comp_name component, version, status FROM dba_registry;
http://dbaoracletips.blogspot.in/2014/02/owb-component-not-upgraded-to-11204.html
The Database has been upgraded from 11.2.0.2 to 11.2.0.4. Upgrade completed successfully but the OWB component is not upgraded and showing version 11.2.0.4
Solution:
Login as sysdba and execute below scripts
execute the script $ORACLE_HOME\owb\UnifiedRepos\clean_owbsys.sql
execute the script $ORACLE_HOME\owb\UnifiedRepos\cat_owb.sql
==============================================================================================================
==== RMAN Arch Delete
rman target / nocatalog << EOF >> $RMAN_LOG
run
{
allocate channel dsk_inst1 device type disk;
allocate channel dsk_inst2 device type disk;
delete noprompt archivelog all completed before 'sysdate -2';
release channel dsk_inst1;
release channel dsk_inst2;
}
EOF
list archivelog until time 'sysdate - 1';
crosscheck archivelog until time 'sysdate - 1';
delete noprompt archivelog all completed before 'sysdate - 1';
delete noprompt archivelog all completed before 'sysdate - 2';
delete noprompt archivelog all completed before 'sysdate - 1/12';
delete noprompt archivelog from sequence 1111 to sequence 1122;
rman target / nocatalog << EOF >> $RMAN_LOG
run
{
allocate channel dsk_inst1 device type disk;
allocate channel dsk_inst2 device type disk;
--delete noprompt archivelog all completed before 'sysdate -2';
backup database;
release channel dsk_inst1;
release channel dsk_inst2;
}
EOF
RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 73320 UNTIL SEQUENCE 73500;
RMAN> DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 73500;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 267914;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 268265;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 1100;
DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 1370;
list backup of datafile 1,2,3,4 completed after 'trunc(sysdate) -3';
list backup summary completed after 'trunc(sysdate) -3';
==========================================================================================================
RMAN Restore on Time basis:
RMAN> run
{
Set until time "to_date('15/04/2014 00:30:00','dd/mm/yyyy hh24:mi:ss')";
Restore controlfile from ‘h:\rman\backup…..\control.ctl’;
}
RMAN> restore database until time "to_date('15/04/2014 00:30:00','dd/mm/yyyy hh24:mi:ss')";
RMAN> recover database until time "to_date('15/04/2014 00:30:00','dd/mm/yyyy hh24:mi:ss')";
SQL> alter database open resetlogs;
======
configure retention policy to recovery window of 7 days;
configure retention policy to redundancy 2;
==========================================================================================================
root@HBFCRPPRDDB1:/fc_precut_dump/scripts $cat fc_precut_rman.sh
#!/usr/bin/ksh
# Name : rman_bkp.sh
# Description :
# This script takes a RMAN Daily FULL Database and Archive files backup.
# Also takes controlfile and spfile autobackup.
# It removes the obsolete backup and 3 days old archive files.
cd /fc_precut_dump/backup/logs
#topas_nmon -f -t -s10 -c180
export ORACLE_HOME=/oracle11R2/app/11.2.2
export ORACLE_SID=FCPRECUT
export PATH=$ORACLE_HOME/bin:$PATH
tdate=`date '+%d-%m-%y'`
DBNAME=FCPRECUT
BKPLOC=/fc_precut_dump/backup/RMAN/CURRENT
LOGLOC=/fc_precut_dump/backup/logs/RMAN
RMAN_LOG=$LOGLOC/"$DBNAME"_rman_backup_$tdate.log
sqlplus " /as sysdba" <<EOF>/fc_precut_dump/backup/logs/database_status.lst
@/fc_precut_dump/scripts/sql/database_status.sql
EOF
a=`cat /fc_precut_dump/backup/logs/database_status.lst | grep -i STARTED | wc -l | awk '{print $1}'`
if [ $a -eq 1 ]
then
echo "fcpreeod database is in nomount mode...please connect dba support"
exit 1
else
echo " ......"
fi
dbavl=`ps -eaf|grep ora_pmon_FCPRECUT | grep -v grep | wc -l`
spchk=`df -gt /fc_precut_dump|awk '{print $5}'|tail -1|cut -f1|sed -e 's/%//'`
if [ $dbavl -eq 1 ] && [ $spchk -le 85 ]; then
echo "\n\n **************** RMAN Backup Startup time : `date` *****************" >> $RMAN_LOG
rman target / nocatalog << EOF >> $RMAN_LOG
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
allocate channel c6 type disk;
allocate channel c7 type disk;
allocate channel c8 type disk;
allocate channel c9 type disk;
allocate channel c10 type disk;
allocate channel c11 type disk;
allocate channel c12 type disk;
allocate channel c13 type disk;
allocate channel c14 type disk;
allocate channel c15 type disk;
allocate channel c16 type disk;
allocate channel c17 type disk;
allocate channel c18 type disk;
allocate channel c19 type disk;
allocate channel c20 type disk;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/fc_precut_dump/backup/RMAN/CURRENT/snapcf_FCRPT.f';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/fc_precut_dump/backup/RMAN/CURRENT/fcprdgl_ctl%F';
crosscheck backup;
backup as compressed backupset database TAG 'Daily_Full_DB_Backup_$tdate' FORMAT '$BKPLOC/DBFULL_FC_%U_%D_%M_%Y';
backup archivelog all not backed up 1 times TAG 'ARC_Backup_$tdate' FORMAT '$BKPLOC/ARCH_FC_%U_%D_%M_%Y';
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;
release channel c9;
release channel c10;
release channel c11;
release channel c12;
release channel c13;
release channel c14;
release channel c15;
release channel c16;
release channel c17;
release channel c18;
release channel c19;
release channel c20;
}
EOF
else
echo "Database is down ...or Enough free space not available for Backup"
exit 1
fi
cd /openview_archive/openview_EXPBKP
dt=`date +%d%m%Y_%H%M%S`
find . -name "*.trc" -mtime +20 -exec rm {} \;
00 23 27 * * /home/oracle/rr/EXPDP_openview.sh 2>> /home/oracle/rr/EXPDP_openview.err
Arun RBI - 9870054897
Sonu Gupta - Mail Initiated
cd $BKPLOC
find . -name -mtime +60 -exec rm {} \;
find . -mtime +20 -exec rm -rf {} \;
find . -name "*.log" -mtime +60 -exec rm {} \;
find . -mtime +1 -exec rm {} \;
find . -mtime +20 -exec ls -ltr {} \;
find . -mtime +10 -exec rm {} \;
find . -mtime +1 -exec ls -ltr {} \;
find . -mtime +0 -exec ls -ltr {} \;
find . -mtime +1 -exec gzip {} \;
find . -mtime +10 -exec rm {} \;
find . -mtime -2 -exec rm {} \;
find . -mtime -2 -exec ls -ltr {} \;
find . -mtime +2 -exec ls -ltr {} \;
Will ls Files whose Modified time is Older then 24 Hours
find . -mtime +1 -name "*.gz" -exec ls -ltr {} \;
Will ls Files whose Modified time is Older then 48 Hours
find . -mtime +2 -exec ls -ltr {} \;
echo "\n\n ******************RMAN Backup for $DBNAME has completed at : `date` **********************" >> $RMAN_LOG
cd /fc_precut_dump/backup/logs/RMAN
chmod 755 $RMAN_LOG
find . -mtime +5 -exec rm {} \;
exit
ZUS-EMTOOLS-MR-AR <ZUS-EMTOOLS-MR-AR@hp.com>
find ./metap3_ora*.trc.gz -mtime +15 -exec rm {} \;
find . -mtime +15 -exec ls -ltr {} \;
find . -mtime +15 -exec gzip {} \;
find . -mtime +30 -exec rm {} \;
find . -mtime +1 -exec rm {} \;
find . -mtime -1 -exec ls -ltr {} \;
find . -mtime +200 -exec rm {} \;
find ./metaemp1_ora_*.trc -mtime +3 -exec ls -ltr {} \;
find /b001/backup/exports/wuktst -mtime +1 -exec ls -ltr {} \;
find /b001/backup/exports/wukdev/ -mtime +1 -exec ls -ltr {} \;
======= SQL
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
124.30.56.17 - DELL 2850
10.240.32.201 - DELL 2850
exec sp_send_cdosysmail 'dba@hdfcinsurance.com','dba@hdfcinsurance.com','','test','test'
-2147023782.
qazwsxed04
======= Oracle
opatch lsinventory -- check what this command does.
select owner,object_name,object_type,created,status from dba_objects where object_NAME like '%KGSKWT%';
select OWNER,CONSTRAINT_NAME,R_CONSTRAINT_NAME,CONSTRAINT_TYPE,TABLE_NAME,STATUS,INVALID from dba_constraints where TABLE_NAME like '%AUDIT_TRAIL%';
select * from dba_cons_columns where CONSTRAINT_name like '%PRL_CANDIDATE_CASE_REGN_R88%';
select OWNER,CONSTRAINT_NAME,R_CONSTRAINT_NAME,CONSTRAINT_TYPE,TABLE_NAME,STATUS,INVALID from dba_constraints where TABLE_NAME like '%PRL_CANDIDATE_CASE_REGN%';
select owner,object_name,object_type,created,status from dba_objects where object_NAME like '%TTFGLD106954%';
alter table
Truncating & Deallocating space.
================================
SQL> TRUNCATE TABLE BIGTABLE REUSE STORAGE;
SQL> ALTER TABLE BIGTABLE DEALLOCATE UNUSED KEEP 1707M; (2Gb*5/6)
\\bkchome\Common\Others\Komal\sutapa\RPT-Setup
imp ams/ams file='' log='' tables=(AMS_NEFT_COMMDETAILS,AMS_NEFT_DETAILS,CC_MED_LETTER_PDF,AMS_COMM_CHQ_DIS_STATUS,AMS_ECS_COMMDETAILS,AMS_ECS_MANREJ_DETAILS,AMS_NEFT_MANREJ_DETAILS) feedback=10000 buffer=1234567890 ignore=y
('AMS_NEFT_COMMDETAILS','AMS_NEFT_DETAILS','CC_MED_LETTER_PDF','AMS_COMM_CHQ_DIS_STATUS','AMS_ECS_COMMDETAILS','AMS_ECS_MANREJ_DETAILS','AMS_NEFT_MANREJ_DETAILS')
=====================================================================================
vi rmanbackup.sh
export ORACLE_HOME=/oracle11R2/app/11.2.2
export ORACLE_SID=FCPRECUT
export PATH=$ORACLE_HOME/bin:$PATH
tdate=`date '+%d-%m-%y'`
DBNAME=FCPRECUT
RMAN_LOG=/home/oracle/$DBNAME_rmanbackup_$tdate.log
rman target / nocatalog << EOF >> $RMAN_LOG
run
{
allocate channel dsk_inst1 device type disk;
allocate channel dsk_inst2 device type disk;
--delete noprompt archivelog all completed before 'sysdate -2';
backup database;
release channel dsk_inst1;
release channel dsk_inst2;
}
EOF
delete archivelog all backedup before 'sysdate';
RAC Services Check
Oracle11g
==========
srvctl config database -d RAC
srvctl status database -d HDFCPROD
srvctl stop database -d RAC
srvctl start instance -d racdb -i racdb1, racdb3
srvctl stop instance -d racdb -i racdb1, racdb3
srvctl status
crsctl status resource -t
crsctl status server -f
SELECT * FROM v$active_instances;
SELECT svrname, dirname FROM v$dnfs_servers;
ORACLE10g
==========
C:\>crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
D:\oracle\product\10.2.0\crs\BIN>srvctl status nodeapps -n ccdb1
VIP is running on node: ccdb1
GSD is running on node: ccdb1
Listener is not running on node: ccdb1
ONS daemon is running on node: ccdb1
crs_stat -t
C:\Documents and Settings\setouqe>D:\oracle\product\10.2.0\crs\BIN\crs_stat.exe -t
Name Type Target State Host
------------------------------------------------------------
ora....T1.inst application ONLINE OFFLINE
ora....T2.inst application ONLINE ONLINE ccdb2
ora.HDFCUAT.db application ONLINE ONLINE ccdb2
ora....AT1.srv application ONLINE ONLINE ccdb2
ora....luat.cs application ONLINE ONLINE ccdb2
ora....SM1.asm application ONLINE ONLINE ccdb1
ora....B1.lsnr application ONLINE OFFLINE
ora.ccdb1.gsd application ONLINE OFFLINE
ora.ccdb1.ons application ONLINE ONLINE ccdb1
ora.ccdb1.vip application ONLINE ONLINE ccdb1
ora....SM2.asm application ONLINE ONLINE ccdb2
ora....B2.lsnr application ONLINE ONLINE ccdb2
ora.ccdb2.gsd application ONLINE ONLINE ccdb2
ora.ccdb2.ons application ONLINE ONLINE ccdb2
ora.ccdb2.vip application ONLINE ONLINE ccdb2
ora....prod.db application OFFLINE OFFLINE
ora....d1.inst application ONLINE OFFLINE
ora....d2.inst application ONLINE UNKNOWN ccdb2
ora....prod.cs application OFFLINE OFFLINE
ora....od1.srv application OFFLINE OFFLINE
ora....od2.srv application OFFLINE OFFLINE
=============================================================================
Supriyo - 9920057626
Daily TBSP Check:
=============
10.60.0.186 -- ODS - Auto Manu
10.60.0.141 -- PRLPROD
10.60.0.144 -- Not Required
10.60.1.91 -- MINT1 , PINNACLE1 -- OracleDBConsole Auto
10.60.1.93 -- MINT2 , PINNACLE2 -- OracleDBConsole Auto
124.30.56.2 -- HDFCPROD1
124.30.56.15 -- HDFCPROD2
10.60.0.201 -- HDFCDB , IDB , FNTIDBCS -- Manu
10.60.1.208 -- MDEALING -- Auto - Manu
10.60.0.230 -- HDFCAML , FNTIDBCS , AMLUAT -- Manu
10.60.0.127 --
10.60.0.195 -- SUNAR , SUNLA , ORACLE9 Agent -- Auto Manu
Daily Disk Space Check:
=======================
10.60.0.126 -- Standby Server
10.60.0.201
124.30.56.16 -- Standby Server
Daily ASM Check:
================
124.30.56.2 / 15
10.60.1.91 / 93
select * from v$sess_io where sid in (select sid from v$session where program like '%(J0%');
@schemasize:
select sum(bytes/1024/1024/1024) from dba_segments where owner = '&AMS';
select username,default_tablespace from dba_users where username = 'AMS';
EVENTS :
=========
cursor: pin S wait on X : A session waits on this event when requesting a mutex for sharable operations
related to pins (such as executing a cursor), but the mutex cannot be granted because
it is being held exclusively by another session (which is most likely parsing the cursor).
SELECT p2raw
,to_number(substr(to_char(rawtohex(p2raw)), 1, 8), 'XXXXXXXX') sid
FROM v$session
WHERE event = 'cursor: pin S wait on X';
P2RAW SID
---------------- ---
0000001F00000000 31
On 64 bit platforms 8 bytes are used, so the top 4 bytes are the holding session Id (if the mutex is held X), and the bottom 4 bytes are the ref count (if the mutex is held S).
On 32 bit platforms 4 bytes are used, so the top 2 bytes are the holding session Id (if the mutex is held X) and the bottom 2 bytes are the ref count (if the mutex is held S).
select p1, p2raw, count(*)
from v$session
where event = 'cursor: pin S wait on X’
and wait_time = 0
group by p1, p2raw;
col p1text for a15
col p2text for a15
col p3text for a15
select sid,serial#,program,event,p1, p1text ,p2, p2text,p3,p3text, p2raw from v$session where event like '%write%';
SOLUTION:
---------
Quick workaround is to set "_kks_use_mutex_pin" to false .
or
Apply the patch 5907779
RMAN: Restoring an RMAN Backup to Another Node [ID 73974.1]
library cache pin
library cache lock
ALTER DATABASE ADD LOGFILE group 7 ('/u02/oradata/P38/redo07a.log', '/u03/oradata/P38/redo07b.log') size 15728640;
ed cursorcheck
select a.value, s.username, s.sid, s.serial#
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current'
order by 1;
select sum(x.value) from (select a.value, s.username, s.sid, s.serial#
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current') x;
col max_open_cur for a7
select max(a.value) as highest_open_cur, p.value as max_open_cur
from v$sesstat a, v$statname b, v$parameter p
where a.statistic# = b.statistic#
and b.name = 'opened cursors current'
and p.name= 'open_cursors'
group by p.value;
=============================
Freespace:
set time on
column host_name format a25
select name,open_mode from gv$database;
select instance_name,host_name,status,logins from gv$instance;
set pages 500
set lines 120
set heading on
column tablespace_name for a30
column tbsize for 999999999.999
column tbfree for 999999999.999
column Largest for 99999.999
column ratio for 9999.99
column Required for 99999.999
select
a.tablespace_name ,
tbsize ,
tbfree ,
b.tbfree/a.tbsize*100 "% Free TBS" ,
b.Largest "Largest space"
from
( select tablespace_name,sum(bytes)/1024/1024 tbsize
from dba_data_files
group by tablespace_name) a,
( select tablespace_name,nvl(sum(bytes)/1024/1024,0) tbfree,
nvl(max(bytes)/1024/1024,0) Largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name(+)
order by 4 desc;
D:\IBM Oracle Docs\IBM\RBI_Requirements\Mail from Maruti CMDDB\CDBMSNEW_Tables_Details
select owner,segment_name Table_Name ,sum(bytes/1024/1024) Table_MB from dba_segments where segment_type = 'TABLE' and TABLESPACE_NAME not like 'SYS%' group by owner,segment_name order by 1,3;
select * from v$recover_file;
select distinct status from v$datafile;
archive log list;
alter system checkpoint;
alter system switch logfile;
07738900976
column file_name format a55
column tablespace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&UNDO%' order by 3;
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
select 'alter tablespace ' || tablespace_name || ' add datafile ' || ''' || '/CDBMS_DATA/cdbmsstg/oradata/cdbms_st/' || tablespace_name || '_C001.dbf' || ''' || ' size 1G autoextend on;' from dba_tablespaces order by 1;
select sid,serial#,program,event ,to_char(logon_time,'DD-MM-YYYY HH24:MI:SS') from gv$session where schemaname not like 'SYS';
select * from dba_tab_privs where grantee = 'MLOG$_VI_CHANNEL_T';
select * from dba_tab_privs where grantee = 'OERR';
@logon:
------
set lines 190
select sid,serial#,program ,to_char(logon_time,'DD-MM-YYYY HH24:MI:SS'),SQL_HASH_VALUE,username,sql_id from gv$session where schemaname not like 'SYS' and status='ACTIVE' order by logon_time;
======================
set lines 180
col username for a20
col machine for a25
col module for a45
col sql_id for a20
select count(*),username,sql_id,status,osuser,machine,module from v$session group by username,status,osuser,machine,module,sql_id order by 3;
==============
select sid,serial#,program ,to_char(logon_time,'DD-MM-YYYY HH24:MI:SS'),SQL_HASH_VALUE,sql_id from gv$session where sql_id is not null;
select sid,serial#,program ,to_char(logon_time,'DD-MM-YYYY HH24:MI:SS'),SQL_HASH_VALUE,sql_id from gv$session where sid=183;
Abhi. 9766673333
Riyaz FreeSpace:
=================
set pages 999
col tablespace_name format a40
col "size MB" format 999,999,999
col "free MB" format 99,999,999
col "% Used" format 999
select tsu.tablespace_name, ceil(tsu.used_mb) "size MB"
, decode(ceil(tsf.free_mb), NULL,0,ceil(tsf.free_mb)) "free MB"
, decode(100 - ceil(tsf.free_mb/tsu.used_mb*100), NULL, 100,
100 - ceil(tsf.free_mb/tsu.used_mb*100)) "% used"
from (select tablespace_name, sum(bytes)/1024/1024 used_mb
from dba_data_files group by tablespace_name union all
select tablespace_name || ' **TEMP**'
, sum(bytes)/1024/1024 used_mb
from dba_temp_files group by tablespace_name) tsu
, (select tablespace_name, sum(bytes)/1024/1024 free_mb
from dba_free_space group by tablespace_name) tsf
where tsu.tablespace_name = tsf.tablespace_name (+)
AND tsu.tablespace_name like '%TEMP%'
order by 4;
--AND tsu.tablespace_name like '%&TBS_NAME%'
prompt ======================Checking Datafiles of TABLESPACE=================================================
Yogesh / Farhad - 9921795572
Jaianand harik. - 9820237054
column file_name format a55
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&UNDO%' order by 3;
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
select count(file_id) from dba_data_files where tablespace_name like '%&TBS%';
column file_name format a55
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where file_name like '%&UNDO%' order by 3;
column file_name format a55
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where autoextensible='YES' order by 6;
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where file_name like '%&UNDO%' order by 3;
alter system set session_cached_cursors=150 scope=both sid='FBAU3FCR2';
srvctl relocate service -d fcprdfcr -s fcprodnode2 -i FBAU3FCR2 -t FBAU3FCR1
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where file_name like '%&FIleName%' order by 2;
select * from v$sort_usage -- No rows should be there to resize temp Tablespace
select * from v$undostat -- to Check UNDO Tablespace
select tablespace_name,count(file_name),sum(bytes/1024/1024) from dba_data_files group by tablespace_name order by 2;
select distinct tablespace_name,status,file_id,bytes,blocks,owner from DBA_UNDO_EXTENTS where status='UNEXPIRED' order by 1,3;
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%SYSTEM%';
== Check Possible Shrink
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&Ams%' order by 1;
select file_id,max((block_id+blocks-1)*8192)/1024/1024 from dba_extents where TABLESPACE_NAME like '%&AMS_MASTER%' group by file_id order by 1;
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where file_name like '%&AMS_MASTER%' order by 1;
select file_id,max((block_id+blocks-1)*8192)/1024/1024 from dba_extents where file_name like '%&AMS_MASTER%' group by file_id order by 1;
col segment_name for a30
set pages 200
set lines 200
select segment_name,file_id,sum(bytes/1024) from dba_extents where file_id = 43 group by segment_name,file_id;
set linesize 150
column file_name format a50
column tablespace_name format a10
column free_space format 9999.9999
select ddf.file_name
,ddf.tablespace_name
,sum(dfs.bytes)/1024/1024 free_space
from dba_data_files ddf, dba_free_space dfs
where ddf.file_id = dfs.file_id
and ddf.tablespace_name like 'MP1_DATA'
group by ddf.file_name,ddf.tablespace_name;
ALTER TABLE AUD$ DEALLOCATE UNUSED KEEP 500M;
@tempfile:
RESIZE :
ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' RESIZE 18M;
============
SHRINK :
ALTER TABLESPACE temp SHRINK SPACE KEEP 20M;
ALTER TABLESPACE temp SHRINK TEMPFILE '+FRA/hdfcuat/tempfile/temp.507.721312809';
=========================================
DROP Single Tempfile :
ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' DROP INCLUDING DATAFILES;
===========================================
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp_grp;
===================================
col file_name for a45
select tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files order by file_name;
=========================
col TABLESPACE for a10
col FILENAME for a50
set lines 190
SELECT d.tablespace_name tablespace , d.file_name filename, d.file_id fl_id, d.bytes/1024/1024
size_m
, NVL(t.bytes_cached/1024/1024, 0) used_m, TRUNC((t.bytes_cached / d.bytes) * 100) pct_used
FROM
sys.dba_temp_files d, v$temp_extent_pool t, v$tempfile v
WHERE (t.file_id (+)= d.file_id)
AND (d.file_id = v.file#);
==================================
alter tablespace temp add tempfile '&tempfilepath' size 1800M;
=======================================================
== Check Posible UNDO Shrink.
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&UNDO%' order by 3;
select file_id,max((block_id+blocks-1)*8192)/1024/1024 from dba_extents where TABLESPACE_NAME like '%&UNDO%' group by file_id order by 1;
=============================================
select object_type,count(object_type) from dba_objects where owner = 'SAM_SIT' group by rollup(object_type);
select sid,serial#,program,action,event from v$session where program like '%imp%';
select count(*) from dba_indexes where owner = 'SAM_SIT';
select object_name,owner,object_type,status from dba_objects where object_id=307196;
=============================================
set pages 200
set lines 200
column machine format a18
column event format a35
column program format a33
column schemaname for a10
column username for a10
column action format a50
col LT for a21
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,schemaname,username,status from v$session where logon_time like sysdate and schemaname <> 'SYS' order by logon_time desc;
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,schemaname,status from v$session where logon_time not like sysdate and schemaname <> 'SYS' order by logon_time;
col sidd for a55
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' SIDD --, Program
from v$session
where to_char(logon_time,'dd-mm-yyyy hh24') like '01-08-2014 21' and schemaname <> 'SYS' and program like 'JDBC%';
and lower(program) like 'plsqldev.exe' order by logon_time;
col sidd for a55
col LT for a22
col program for a30
col schemaname for a12
col osuser for a10
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' SIDD, to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,program,osuser, schemaname from v$session
where logon_time < sysdate - 1 and schemaname <> 'SYS' order by logon_time;
col osuser for a10
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' SIDD, to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,program,osuser,status from v$session
where osuser in ('bzp8xz', 'bz3l0j','bzztqb') order by 2;
--where sid=&SID;
select * from v$sess_io where sid in (select sid from v$session where program like '%(J0%');
select sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,schemaname,status from v$session order by logon_time;
col program for a30
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname from v$session order by logon_time;
@session:
set pages 200
set lines 200
column machine format a20
column event format a35
column program format a30
column schemaname for a10
column action format a50
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,status from v$session where schemaname not like 'SYS%' order by logon_time;
set pages 200
set lines 200
column machine format a20
column event format a35
column program format a20
column action format a20
column schemaname format a5
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname,action from v$session where sid in
(select distinct sid from
v$statname n,v$sesstat s
where n.STATISTIC# = s.STATISTIC# and name like 'session%memory%');
col LT for a35
select sid,serial#,machine,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,schemaname from v$session order by logon_time;
select spid, osuser, s.program from
v$process p, v$session s where p.addr=s.paddr
and id=&sid;
select sid,s.serial#, spid, osuser, s.program from
v$process p, v$session s where p.addr=s.paddr
and spid=&spid;
-- Enable row movement.
ALTER TABLE FLAG.FLAG_EMP_CFC_DETAIL ENABLE ROW MOVEMENT;
-- Recover space and amend the high water mark (HWM).
ALTER TABLE FLAG.FLAG_EMP_CFC_DETAIL SHRINK SPACE;
--- For UNDO
== Check Possible Shrink
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%UNDO%' order by 1;
select file_id,max((block_id+blocks-1)*8192)/1024/1024 from dba_extents where TABLESPACE_NAME like '%UNDO%' group by file_id order by 1;
SELECT to_char(stat.begin_time,'dd-mm-yyyy hh24:mi:ss'),
to_char(stat.end_time,'dd-mm-yyyy hh24:mi:ss'),
stat.undoblks * param.value / 1024 / 1024 undo_mb,
stat.undoblks * param.value / 1024 / 1024 / 10 / 60
undo_mb_per_sec,
stat.maxquerylen
FROM v$undostat stat,
v$parameter param
WHERE param.name = 'db_block_size';
ROLLBACK
select activeblks,UNEXPIREDBLKS,EXPIREDBLKS,TUNED_UNDORETENTION from v$undostat;
select distinct tablespace_name,status,file_id,bytes,blocks,owner from DBA_UNDO_EXTENTS where status<>'EXPIRED' order by 1;
select latch ,shrinks,extends,status,curext,curblk from V$ROLLSTAT where rownum <= 10;
SELECT TO_CHAR(BEGIN_TIME, 'MM/DD/YYYY HH24:MI:SS') BEGIN_TIME,
TO_CHAR(END_TIME, 'MM/DD/YYYY HH24:MI:SS') END_TIME,
UNDOTSN, UNDOBLKS, TXNCOUNT, MAXCONCURRENCY AS "MAXCON"
FROM v$UNDOSTAT WHERE rownum <= 144;
select tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&TBSP%';
create tablespace TBS_PRL_PROD1_INDX datafile '' size 2G;
@which Session is Using UNDO Tablespace ==============
col osuser for a15
col user for a10
col undo_tbs for a12
col SEGMENT_NM for a15
set pages 200
set lines 200
SELECT ds.TABLESPACE_NAME "UNDO_TBS",ds.RELATIVE_FNO "File Nos",r.name "SEGMENT_NM", s.sid, s.serial#,s.osuser, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,
substr(s.program, 1, 78) "COMMAND"
FROM sys.v_$session s, sys.v_$transaction t, sys.v_$rollname r,dba_segments ds
WHERE t.addr = s.taddr
and t.xidusn = r.usn
and ds.segment_name = r.name(+)
ORDER BY t.cr_get, t.phy_io;
SELECT r.name "RBS", s.sid, s.serial#,s.osuser, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,
substr(s.program, 1, 78) "COMMAND"
FROM sys.v_$session s, sys.v_$transaction t, sys.v_$rollname r
WHERE t.addr = s.taddr
and t.xidusn = r.usn
ORDER BY t.cr_get, t.phy_io;
arun.k74@wipro.com
select distinct tablespace_name,status,file_id,bytes,blocks,owner from DBA_UNDO_EXTENTS where status<>'EXPIRED' order by 1;
col program for a30
col event for a40
col action for a30
col username for a10
col schemaname for a5
select sid,serial#,program,event,action,schemaname,username from v$session where sid=;
==============================
CREATE PROFILE my_profile LIMIT
FAILED_LOGIN_ATTEMPTS 3 -- Account locked after 3 failed logins.
PASSWORD_LOCK_TIME 5 -- Number of days account is locked for. UNLIMITED required explicit unlock by DBA.
PASSWORD_LIFE_TIME 30 -- Password expires after 90 days.
PASSWORD_GRACE_TIME 3 -- Grace period for password expiration.
PASSWORD_REUSE_TIME 120 -- Number of days until a specific password can be reused. UNLIMITED means never.
PASSWORD_REUSE_MAX 10 -- The number of changes required before a password can be reused. UNLIMITED means never.
/
ALTER USER scott PROFILE my_profile;
alter profile DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
==============================
Advise
select distinct task_id,BENEFIT_TYPE from dba_advisor_recommendations where BENEFIT_TYPE like 'Enable%' order by BENEFIT_TYPE;
SELECT
r.type,
r.Rank,
r.benefit,
f.impact_type,
f.impact,
f.message
FROM
dba_advisor_recommendations r,
dba_advisor_findings f
WHERE r.task_name = 'TASK_4502'
AND r.finding_id = f.finding_id
AND r.task_id = f.task_id
ORDER BY r.rank ASC, r.benefit DESC;
===============
alter system set standby_file_management='manual';
alter database create datafile 'D:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\UNNAMED00196' as 'D:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\ams_transaction_data.317.718326941'
STEP1:- Check the name of the datafile on standby database
select name from v$datafile; ---- This command should show the datafile name as UNNAMEDxxxxx
STEP2:- ON STANDBY DATABASE
alter system set standby_file_management='manual';
STEP3:- Rename the datafile
alter database create datafile 'C:\ORACLE\ORA10G\DATABASE\UNNAMED00129' as 'C:\ORACLE\ORA10G\DATABASE\actual_dbfile_name.dbf'
STEP4:- On the standby database
alter system set standby_file_management='auto';
STEP5:- On the standby database
recover managed standby database disconnect;
shutdown and then reopen the standby database and continue applying the redo logs
SQL> show parameter stand
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
standby_archive_dest string %ORACLE_HOME%\RDBMS
standby_file_management string AUTO
SQL>
547 - 2
== If alter database create datafile 'OLD File' as 'NEW File'; Doesnot work
SQL> alter system set standby_file_management='AUTO'; -- Parameter status need to be checked
RMAN> run {
2> set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00012' to '+DATA_IDEAS/pinnacle/datafile/ideas.318.719999863';
3> restore datafile 12;
4> recover datafile 12;
5> }
alter database create datafile 'D:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\UNNAMED00005' as 'D:\APP\ORACLE\ORADATA\ORCL\DBSP101.DBF';
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history
where sequence# in (select max(sequence#) from v$log_history group by thread#);
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history
where sequence# = 567;
delete archivelog all completed before 'sysdate -1';
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history where sequence# = 3196;
RIYAZ STANDBY APPLIED APPLY LOG DETAILS
1. Please fire the sql first to determine which archive last came last and which was the last applied. Server standby 008
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd;
2. Check the archive gap.
SELECT PROCESS, STATUS,SEQUENCE#,BLOCK#,BLOCKS, DELAY_MINS FROM V$MANAGED_STANDBY;
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history
where to_char(first_time,'DD-MON-YY') >= '11-MAY-14' and to_char(first_time,'DD-MON-YY') <= '11-MAY-14';
alter database create standby controlfile as '/b01/backup/STANDBY_CTL.ctl';
alter database backup controlfile to trace;
alter database backup controlfile to 'g:\Controlfile.ctl';
alter database backup controlfile to '/home/ais/oradw/rr/control_SP1.ctl';
SCN RMAN RESTORE -- If Standby ARCHIVE Files are Missing
=========================================================
1....On Primary & Standby Database.
SQL> select name,open_mode,CURRENT_SCN from v$database;
SQL> select scn_to_timestamp(1447102) from dual; ---- e.g SCN NOS.
2....On Primary Database. ( a OR b OR c) ----- Take SCN Nos. from v$database (as above)
a. RMAN> BACKUP DEVICE TYPE SBT INCREMENTAL FROM SCN 750923 DATABASE;
b. RMAN> BACKUP INCREMENTAL FROM SCN 750923 DATABASE;
c. RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750983 DATABASE FORMAT '/tmp/incr_standby_%U';
3....On Primary Database.
Backup Controlfile
SQL> alter database create standby controlfile as 'BACKUP LOCATION\STANDBY_CTL.ctl';
4.... COPY Backedup FILES to Standby DB Server.
5.... On Standby Database.
SQL> shut immediate.
SQL> startup nomount
RMAN> restore controlfile from 'CTL FILE SAVED LOCATION\Control.ctl';
SQL> alter database mount standby database;
SQL> alter system set standby_Management parameter to MANUAL
6....On Standby Database
$ rman target=/
RMAN> catalog start with '<BACKUP FILE STORED LOCATION>';
7....On Standby Database.
START RECOVER
RMAN> RECOVER DATABASE NOREDO;
8....On Standby Database.
SQL> select name,open_mode,CURRENT_SCN from v$database;
SQL> select scn_to_timestamp(1447102) from dual; ---- e.g SCN NOS.
select timestamp_to_scn('09-JAN-09:12:00:10') from dual;
select timestamp_to_scn('10-JAN-14:10:00:10') from dual;
select scn_to_timestamp(8733) from dual;
select scn_to_timestamp(3196) from dual;
SELECT TIMESTAMP_TO_SCN('10-JAN-14 10.00.09.000000000 AM') FROM dual;
9....On Standby Database.
*** START real time RECOVERY ***
====================
SELECT c.index_name, i.uniqueness, c.column_name
FROM user_indexes i, user_ind_columns c
WHERE i.index_name = c.index_name
AND i.table_name = 'AMS_POLICY_DETAILS'
ORDER BY c.index_name, c.column_position
/
select thread#,max(sequence#) from v$log_history group by thread#;
create undo tablespace UNDOTBS002 datafile size 100M;
create undo tablespace UNDOTBS001 datafile size 100M;
select sum(bytes/1024/1024/1024) from dba_segments;
CREATE PUBLIC DATABASE LINK "CC_UAT1"
connect to WONUAT identified by WONUAT
using 'CCUAT';
Fcubuat2$
drop DATABASE LINK "FCCUAT.FCUBSMOLINK";
CREATE DATABASE LINK "FCUBSMOLINK"
connect to FCCMO_READ identified by Fccmo_1234
using 'MFUBSFLL25';
select DBMS_METADATA.GET_DDL('DB_LINK',db_link,OWNER) db_link_ddl
from dba_db_links
where db_link like '%&DB_LINK_Char%';
set long 9999999
select DBMS_METADATA.GET_DDL('TABLESPACE','TEMP') TEMP_TBS from dual;
from v$tempfile
where name like '%&DB_LINK_Char%';
set long 9999999
select DBMS_METADATA.GET_DDL('TABLESPACE',tablespace_name) TBS from dba_tablespaces where tablespace_name like 'SYSAUX';
BAAN.TTFGLD106954
set long 9999999
select DBMS_METADATA.GET_DDL('TABLE',table_name) TBS from dba_tables where table_name like 'TTFGLD106954';
set long 9999999
select DBMS_METADATA.GET_DDL('TABLE',table_name) TBS from dba_tables where table_name like 'COMP_CUSTOMER_HISTORY' and owner='CDB_ADMIN';
drop DATABASE LINK ARCHLINK_ECOD$.WORLD;
CREATE DATABASE LINK FLEXPROD_HOST.ARCHLINK_ECOD$.WORLD
CONNECT TO FC_ARCH_READ IDENTIFIED BY VALUES '05066CCD3894D446CB9C182BB5A2C0C5ABD2E8DC8ABF0DE9EB'
USING 'FCARCDB';
col owner for a20
col directory_path for a60
set lines 150
set pages 999
select * from dba_directories;
col GRANTEE for a20
col GRANTOR for a10
col PRIVILEGE for a15
select * from dba_tab_privs where table_name in (select DIRECTORY_NAME from dba_directories);
CREATE TEMPORARY TABLESPACE TEMP1 TEMPFILE '/u005/oradata/FDM11DVT/temp1_01.dbf' SIZE 1048M;
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1048576;
select DBMS_METADATA.GET_DDL('TABLESPACE','TEMP') from dual;
select DBMS_METADATA.GET_DDL('TABLESPACE','AMS_MASTER_DATA') from dual;
select DBMS_METADATA.GET_DDL('TABLESPACE','OCCLSS') from dual;
select DBMS_METADATA.GET_DDL('STARPERF',username) db_SCHEMA
from dba_USERS
where username like 'STARPERF';
set long 9999999
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS
where username like 'NEOLOG';
CREATE PUBLIC DATABASE LINK "AMS_Prod"
connect to AMSUAT identified by AMSUAT
using 'HDFCPROD11';
CREATE PUBLIC DATABASE LINK "HDFCDBIDB"
connect to IDBDOC identified by IDBDOC
using 'IDBPROD';
drop PUBLIC DATABASE LINK "AMS_Prod"
select 'grant select on ams.' || object_name || ' to amsuat;' from dba_objects where owner='AMS' and object_type = 'TABLE';
select dbms_metadata.get_ddl ('TABLE', 'AMS_USER_MASTER', 'AMS') from dual;
select dbms_metadata.get_ddl ('TABLE', 'AUD$', 'SYS') from dual;
select dbms_metadata.get_ddl ('TABLE', 'TTFGLD106954', 'BAAN') from dual;
select DBMS_METADATA.GET_DDL('TABLE',table_name,owner) TBS from dba_tables where table_name like 'TTFGLD106954' and owner='BAAN';
select dbms_metadata.get_ddl ('DB_LINK', 'CC_UAT', 'PUBLIC') from dual;
select dbms_metadata.get_ddl ('TABLE', 'KU$NOEXP_TAB1', 'SYS') from dual;
set long 999999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,owner) TBS from dba_tables where table_name like 'COMP_CUSTOMER_HISTORY' and owner='CDB_ADMIN';
set long 999999999
select DBMS_METADATA.GET_DDL('USER','STARPERF') db_SCHEMA from dual;
set long 999999999
select DBMS_METADATA.GET_DDL('USER','SAM_NEW') db_SCHEMA from dual;
CREATE USER "STARPERF" IDENTIFIED BY VALUES 'S:072FA01B7A9502EA75A18766B2385F
F6E827222215087CC72929D7721858;3C117B8C67D369D3'
DEFAULT TABLESPACE "AMS_TRANSACTION_DATA"
TEMPORARY TABLESPACE "TEMP"
column host format a6
column username format a10
column os_user format a8
column program format a30
column tsname format a12
select
b.machine host,
b.username username,
b.server,
b.osuser os_user,
b.program program,
a.tablespace_name ts_name,
row_wait_file# file_nbr,
row_wait_block# block_nbr,
c.owner,
c.segment_name,
c.segment_type
from
dba_data_files a,
v$session b,
dba_extents c
where
b.row_wait_file# = a.file_id
and
c.file_id = row_wait_file#
and
row_wait_block# between c.block_id and c.block_id + c.blocks - 1
and
row_wait_file# <> 0
and
type='USER'
;
=================
http://www.idevelopment.info/data/Oracle/DBA_tips/Automatic_Storage_Management/ASM_36.shtml
Moving database files from one diskgroup/mountpoint to other in ASM using RMAN
1) Database should be in archive log mode.
2) Take file offline which needs to be moved.
SQL > alter database datafile '+DATA1/hdfcuat/datafile/undotbs3.268.730589449' offline;
3) Use below cmd to copy datafile to other directory/mountpoint using below RMAN cmd. It will create file in other location with different name.
RMAN > COPY DATAFILE '+DATA1/hdfcuat/datafile/undotbs3.268.730589449' TO '+DATA2';
Above will create file in other location with different name.
4) Once the RMAN cmd is successfully executed, use below cmd to Rename old file to new file name.
SQL > ALTER DATABASE RENAME FILE '+DATA1/hdfcuat/datafile/undotbs3.268.730589449' to '+DATA2/hdfcuat/datafile/undotbs3.256.732542101';
5) Use below RMAN cmd to rename the ASM database file copy.
RMAN> SWITCH DATAFILE '+DATA2/hdfcuat/datafile/undotbs3.256.732542101' TO COPY;
6) Recover the New ASM datafile. (Copy all the archives in one location/server if there are multiple instances)
SQL> RECOVER DATAFILE '+DATA2/hdfcuat/datafile/undotbs3.256.732542101';
7) Bring New ASM datafile online.
SQL> ALTER DATABASE DATAFILE '+DATA2/hdfcuat/datafile/undotbs3.256.732542101' ONLINE;
8) Check status and file name with new location.
SELECT file_name FROM dba_data_files;
9) Drop old named datafile using below cmd if it exist in old path.
SQL> ALTER DISKGROUP +DATA1 DROP FILE '+DATA1/hdfcuat/datafile/undotbs3.268.730589449';
==========================================================================
We have created external table for Querying the CSV file from the same server & from Other Server. From the same server we are able to query & the ouput is fune , but to query the CSV file datas from other server we are facing Problem , below:
SQL> select * from test;
select * from test
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
error opening file \\HSLCC2\scott\TEST_3208_6236.log
Windows Server 2003 Enterprise x64 Edition (64Bit)
===============
SQL> select tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%UNDO%';
TABLESPACE_NAME FILE_NAME BYTES/1024/1024 AUT
------------------------------ ----------------------------------------------------------------- --------------- ---
UNDOTBS1 - hdfcuat1 +FRA/hdfcuat/datafile/undono1_11.dbf 2116.1875 YES
UNDOTBS2 - hdfcuat2 +DATA/hdfcuat/datafile/undotbs2.311.683717465 104 NO
UNDOTBS2 +DATA/hdfcuat/datafile/undotbs2.310.683717495 150 NO
UNDOTBS2 +DATA/hdfcuat/datafile/undotbs2.267.683717531 213 NO
UNDOTBS2 +FRA/hdfcuat/datafile/undotbs2.489.704573057 5400 YES
UNDOTBS002 +FRA/hdfcuat/datafile/undotbs002.492.716165505 100 NO
UNDOTBS2 +FRA/hdfcuat/datafile/undotbs2.487.704587779 3400 YES
UNDOTBS_01 +FRA/hdfcuat/datafile/undono1_1.dbf 7976.125 YES
UNDOTBS001 +DATA/hdfcuat/datafile/undotbs001.348.716165603 100 NO
9 rows selected.
prompt ======================TEMP TABLESPACE=================================================
SELECT tablespace_name, SUM(bytes_used/1024), SUM(bytes_free/1024)
FROM V$temp_space_header
GROUP BY tablespace_name;
prompt =================Finds Possible TABLESPACE Datafile to shrink==========================================
@shrink@
select 'alter database datafile '''||file_name ||''' resize '|| ceil( (nvl(hwm,1)*8192)/1024/1024 )||'m;' cmd from dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) b where a.file_id = b.file_id(+) and ceil(blocks*8192/1024/1024)- ceil((nvl(hwm,1)*8192)/1024/1024 ) > 0;
prompt ======================Possible TABLESPACE to Coalesce =================================================
select a.tablespace_name, a.file_id, a.block_id, a.blocks,b.block_id
from dba_free_space a, dba_free_space b
where a.tablespace_name like '%DATA%'
and b.tablespace_name like '%DATA%'
and a.file_id = b.file_id
and a.block_id+a.blocks = b.block_id;
DBA
=====
vinay 9820468856
Dhawal 9833105884
prasad 9920769718
prompt ======================Possible Alter Database TABLESPACE=================================================
select 'alter database datafile '''||file_name ||''' resize '|| ceil( (nvl(hwm,1)*8192)/1024/1024 )||'m;' cmd
from dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) b
where a.file_id = b.file_id(+)
and ceil(blocks*8192/1024/1024)- ceil((nvl(hwm,1)*8192)/1024/1024) > 0
and tablespace_name like '%UNDO%';
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 160
select file_id,tablespace_name,file_name,bytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%SYSTEM%';
select file_id,file_name,blocks,MAXBLOCKS from dba_data_files where TABLESPACE_NAME = 'SYSTEM';
select file_id,max(block_id) from dba_extents where TABLESPACE_NAME = 'SYSTEM' group by file_id;
===================================================================
Datafile
set linesize 150
column file_name format a50
column tablespace_name format a10
column free_space format 9999.9999
select ddf.file_name
,ddf.tablespace_name
,sum(dfs.bytes)/1024/1024 free_space
from dba_data_files ddf, dba_free_space dfs
where ddf.file_id = dfs.file_id
and ddf.tablespace_name like 'USERS'
group by ddf.file_name,ddf.tablespace_name;
===================================================================
External Value -- Hidden Parameters
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_px_xtgranule_size%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_compression_comp%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_job_queue_interval%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_cr_server_log_flush%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_fix_control%';
SELECT KSPFTCTXPN PARAMETER_NUMBER,
KSPPINM PARAMETER_NAME,
KSPPITY PARAMETER_TYPE,
KSPFTCTXVL PARAMETER_VALUE,
KSPFTCTXDF IS_DEFAULT,
KSPPIFLG MODIFICATION_FLAG,
KSPFTCTXVF VALUE_FLAG
FROM X$KSPPI X, X$KSPPCV2 Y
WHERE (X.INDX+1) = KSPFTCTXPN
and KSPPINM LIKE '%_allow_resetlogs_corruption%';
_allow_resetlogs_corruption
alter system set "_allow_resetlogs_corruption"=TRUE scope=spfile;
SQL> alter system set "_compression_compatibility"='11.2.0.0.0' scope=both;
System altered.
SQL>
SQL>
Hi,
Possible hot blocks in the buffer cache normally can be identified by a high or rapid increasing wait count on the CACHE BUFFERS CHAINS latch.
This latch is acquired when searching for data blocks cached in the buffer cache.
Since the Buffer cache is implemented as a sum of chains of blocks, each of those
chains is protected by a child of this latch when needs to be scanned. Contention
in this latch can be caused by very heavy access to a single block. This can
require the application to be reviewed.
ACTION PLAN
===========
Please perform the following action plan during the time of issue.
First determine which latch id(ADDR) are interesting by examining the number of
sleeps for this latch. The higher the sleep count, the more interesting the
latch id(ADDR) is:
SQL> select CHILD# "cCHILD"
, ADDR "sADDR"
, GETS "sGETS"
, MISSES "sMISSES"
, SLEEPS "sSLEEPS"
from v$latch_children
where name = 'cache buffers chains'
order by 5, 1, 2, 3;
Run the above query a few times to to establish the id(ADDR) that has the most
consistent amount of sleeps. Once the id(ADDR) with the highest sleep count is found
then this latch address can be used to get more details about the blocks
currently in the buffer cache protected by this latch.
The query below should be run just after determining the ADDR with
the highest sleep count.
SQL> column segment_name format a35
select /*+ RULE */
e.owner ||'.'|| e.segment_name segment_name,
e.extent_id extent#,
x.dbablk - e.block_id + 1 block#,
x.tch,
l.child#
from
sys.v$latch_children l,
sys.x$bh x,
sys.dba_extents e
where
x.hladdr = '&ADDR' and
e.file_id = x.file# and
x.hladdr = l.addr and
x.dbablk between e.block_id and e.block_id + e.blocks -1
order by x.tch desc ;
Example of the output :
SEGMENT_NAME EXTENT# BLOCK# TCH CHILD#
-------------------------------- ------------ ------------ ------ ----------
SCOTT.EMP_PK 5 474 17 7,668
SCOTT.EMP 1 449 2 7,668
column segment_name format a35
select /*+ RULE */
e.owner ||'.'|| e.segment_name segment_name,
e.extent_id extent#,
x.dbablk - e.block_id + 1 block#,
x.tch,
l.child#
from
sys.v$latch_children l,
sys.x$bh x,
sys.dba_extents e
where
x.hladdr = '&ADDR' and
e.file_id = x.file# and
x.hladdr = l.addr and
x.dbablk between e.block_id and e.block_id + e.blocks -1
order by x.tch desc ;
www.tirumala.org
select * from (select CHILD# "cCHILD"
, ADDR "sADDR"
, GETS "sGETS"
, MISSES "sMISSES"
, SLEEPS "sSLEEPS"
from v$latch_children
where name = 'cache buffers chains' and rownum <= 20
order by 5 desc) a
where rownum <= 20;
Depending on the TCH column (The number of times the block is hit by a SQL
statement), you can identify a hotblock. The higher the value of the TCH column,
the more frequent the block is accessed by SQL statements.
In order to reduce contention for this object the following mechanisms can be put in place:
1) Examine the application to see if the execution of certain DML and SELECT statements
can be reorganized to eliminate contention on the object.
2) Decrease the buffer cache -although this may only help in a small amount of cases.
3) DBWR throughput may have a factor in this as well.
If using multiple DBWR's then increase the number of DBWR's.
4) Increase the PCTFREE for the table storage parameters via ALTER TABLE
or rebuild. This will result in less rows per block.
5) Consider implementing reverse key indexes
(if range scans aren't commonly used against the segment)
2)Also upload the AWR report for the duration of 60min during the Good & Bad Period.
Regards
Naveen
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' "sids", to_char(logon_time,'dd-mm-yyyy hh24:mi'),username,schemaname,program from v$session where sid in (select SESSION_ID from v$locked_object where object_id = 172419)
order by 2;
col schemaname for a10
col program for a30
col sids for a70
select 'alter system kill session ''' || sid || ',' || serial# || ''' immediate;' "sids", to_char(logon_time,'dd-mm-yyyy hh24:mi'),status,username,schemaname,program
from v$session
where logon_time < sysdate - 20 and schemaname not like 'SYS%'
order by 2;
select sid,event,schemaname,module,to_char(logon_time,'dd/mm/yyyy hh:mi') from v$session where event like 'latch%' order by 5;
==================================================================================
DBAsupport.com Forums > Archives > Forum Archives > PCTFREE Vs PCTUSED
--------------------------------------------------------------------------------
PDAClick to See Complete Forum and Search --> : PCTFREE Vs PCTUSED
--------------------------------------------------------------------------------
ckwan02-23-2001, 08:12 PM
Dear all,
I want to pour some questions on the above topic questions :
1. I come across a statement saying that PCTUSED Parameter explanation - After a data block becomes full, as determined by PCTFREE, Oracle does not consider the block for the insertion of new rows until the percentage of the block being used falls below the parameter PCTUSED. Before this value is archived, Oracle uses the free space of the data block only for updates to rows already contained in the data block.
Q : What is the reason for this - PCTUSED ? Why they want to control that parameter ? Can I set it to 0 ?
Q: Is free list this pre-allocated ? Is this only use for PCTFREE ? Where does it store ?
Your answer is very much appreciated. Thanks.
--------------------------------------------------------------------------------
IT_girl20002-24-2001, 02:04 AM
hope this will provide you your answer...
The PCTFREE parameter specifies the percentage of
space in each data block that is reserved for growth
resulting from updates of rows in that data block. This
parameter has a default value of 10 percent.
For example, the value of the PCTFREE parameter is
specified as 20 in a CREATE TABLE statement. This
indicates that inserts to the block should stop as soon as
free space drops to 20 percent or less. The free space
thereafter can only be used for updates.
The PCTUSED parameter represents the minimum
percentage of the used space that the Oracle server tries
to maintain for each data block of the table. This
parameter has a default value of 40 percent.
When a data block is filled to the limit determined by the
value of the PCTFREE parameter, Oracle considers the
block unavailable for the insertion of new rows. The block
is unavailable for the insertion of new rows until the
percentage filled by the data of that block falls below the
value of the PCTUSED parameter.
Until the percentage of the block falls below the value of
the PCTUSED parameter, Oracle uses the free space of
the data block only for updating the rows contained in the
data block.
For example, if PCTUSED is defined as 40 percent, the
block is reused for inserts as soon as utilization drops to
less than 40 percent. Inserts continue until utilization
reaches 80 percent and the cycle repeats.
--------------------------------------------------------------------------------
rohitsn02-24-2001, 02:31 AM
Pctused and Pctfree are block storage parameters.
Pctused is used to find out how much percentage of the block will be used to store rows.Pctfree is used to find out how much percentage of the block will be used to store rows resulting from further updates to the rows in the same datablock.
Eg. If u keep pctused to 40% and pctfree 20.so u can insert rows till 40 %.if the limit exceeds 40%,still also u can insert rows in the datablock till the limit reaches 80% (100%-20%) as u have kept pctfree to 20%.Now if one goes on deleting the rows,the block is not said to be free unless and until pctused falls below 40%.As soon as pctused falls below 40% from deleting the rows, that block can be used to insert the rows.In this way the cycle continous.So it is recommended that u never sum up pctused+pctfree=100.Always have some gap between them this helps in reducing ur Oracle server for allocation and disallocation of freelists.
If any further doubts write to rohitsn@hotmail.com
--------------------------------------------------------------------------------
tamilselvan02-25-2001, 11:48 AM
This is an interesting question. I would like to share my experience.
In the last 3 months, I had interviewed 15 Oracle DBAs and asked the same question. Only one person answered correctly.
Both the parameters are applicable and used for each data block in the Database. I hope an example will give you the right answer.
Consider 8K block size. The total bytes 8 x 1024 = 8196 bytes
Each block requires approximately 117 bytes for the header. Please note that the header size varies depending upon the block size.
The total available bytes for data = ( 8196 – 117) = 8079 bytes.
A table is created with PCTFREE 20 PCTUSED 50 .
PCTRFREE in bytes = 1615
PCTUSED in bytes = 4039
Now the data available for insert and update = (8079 – (20 * 8079)/100 ) = 6463 Bytes.
Now user can insert new rows into this block as long as the old rows’ total bytes + new row’s total byte is less than or equal to 6463 bytes. If the new row’s total byte cannot be put into this block, then Oracle will get the next block from the free list, and inserts into it.
When a row is updated and the row’s data is expanded, then PCTFREE come into play. The updated row’s data is placed into PCTFREE’s area, provided the updated row’s new data can be fit into PCTFREE area. If it is not fit into that area, another new block will be obtained from the Freelist, and the row will be migrated. But the original row info (pointer) is kept in the old block. For subsequent access to this row involves 2 read I/O. That is why row migration should be avoided because of excessive I/Os.
ROW DELETION:
The PCTUSED parameter value (in this example 50 %) is the threshold limit for the old block to be added in the FREELIST. To understand better, let us assume that a block is of full data. Now the user starts deleting rows from the block. When a row is deleted, Oracle does not put the block into the FREELIST because it requires many recursive calls to update the FREELIST. The PCTUSED % (50) determines when the block should be added into FREELIST. When the total bytes in the block is less than or equal to 4039 bytes, then the block will be added into FREELIST.
If a table has high inserts and high deletion, then you should decrease the PCTUSED value in order to minimize the frequent update of FREELIST.
The best confidence booster is knowledge. Good Luck, guys.
--------------------------------------------------------------------------------
tamilselvan02-26-2001, 11:03 AM
Correction in earlier post.
The overhead for each block is 107 bytes, not 117 bytes.
Tamilselvan
--------------------------------------------------------------------------------
sambavan02-26-2001, 11:27 AM
That was one damn good explanation. But on reading this thread, I'm getting more questions than that of answers.
1. How do one get to check the over head for different block_sizes.
2. What happens when one sets the PCTFREE to 80%
Sorry for such a lame question, but was curious to know the answer, atleast to the first one.
Thanx,
Sam
--------------------------------------------------------------------------------
tamilselvan02-26-2001, 11:41 AM
Oracle says the overhead for each block varies from 84 bytes to 107 bytes.
I do not know how to cross check over head bytes for various block sizes.
Does anybody know the answer?
--------------------------------------------------------------------------------
pando02-26-2001, 11:44 AM
if pctfree is high then basically we are wasting hard drive space since only 10% of block is used for inserts, of course if you consider that you will update the rows so often and fill the 80% up then it´s up to you but I think it´s pretty rare
I say 10% but it can be less since pctfree+pctused cant be more than 100 and if we set pctused 20 and pctfree 80 most probably we will face perfomance issues because the block has to be put on freelist and taken off free list all the time.
As for block overhead I think there is a formula in Oracle DBA Handbook
--------------------------------------------------------------------------------
badrinathn02-26-2001, 11:47 AM
To add on to the question pool,
I understand that the pctused is used by oracle to put the block into the free list for future inserts.
1) Will any new blocks(extends) added will directly put into the freelist ?
2) I know that I have a table, in which I rarely have any updates and deletes but only insertions, then can I set the parameters for
PCT FREE = 100
and PCT USED=0?
Badrinath
--------------------------------------------------------------------------------
LND02-26-2001, 12:11 PM
badrinathn:
on site http://www.ixora.com.au/q+a/datablock.htm is good discussion of that issue. from my understanding, new blocks goes to so called master free list.
pctused=0 and pctfree=100 would make sense for insert only table.
--------------------------------------------------------------------------------
rsuri02-26-2001, 12:48 PM
shouldn't pctfree be more like 'Zero' for insert-only table ?
pctfree = 100 means nothing can be inserted !
--------------------------------------------------------------------------------
badrinathn02-26-2001, 12:52 PM
Hey, Thats correct,
In that case , for a insert only tables it means
pctfree = 0
and
pctused = 0
Advisors, what do you say?
--------------------------------------------------------------------------------
tamilselvan02-26-2001, 02:02 PM
When PCTFREE is set to 0, then every update on a row requires a row migration.
When PCTUSED is set to 0 , then after deleting all rows in the block, it will be added into FREELIST.
--------------------------------------------------------------------------------
pranavgovind12-19-2007, 09:22 PM
All,I just read this thread and i see very useful information. I just want to share my thoughts for PCTUSED Vs PCTFREE for insert only tables.
PCTFREE = 0 AND PCTUSED value does matter for insert only tables. PCTUSED will not play the role as long as we are not deleting any data in the block. Another point here is, we can not set PCTUSED=100 or PCTFREE = 100. The value 100 is invalid value. Also sum of PCTUSED and PCTFREE can not exceed 100. Pease reply if any one is not agreeing. Thanks
SQL> create table test
2 (no number)
3 pctused 0
4 pctfree 100;
pctfree 100
*
ERROR at line 4:
ORA-02211: invalid value for PCTFREE or PCTUSED
SQL> create table test(no number)
2 pctused 60
3 pctfree 41;
create table test(no number)
*
ERROR at line 1:
ORA-04000: the sum of PCTUSED and PCTFREE cannot exceed 100
--------------------------------------------------------------------------------
davey23uk12-21-2007, 02:17 PM
its 6 years old for gods sake
--------------------------------------------------------------------------------
dbasupport.com
Copyright 2010 Internet.com Inc. All Rights Reserved.
========================================================================================
======= Datagaurd
Max Details in \\10.50.11.28\d$\ronak\Datagaurd folder
select sequence#, applied from v$archived_log order by sequence#;
alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;
col name for a13
col value for a13
col unit for a30
set lines 132
select name, value, unit, time_computed from v$dataguard_stats where name in ('transport lag', 'apply lag');
select to_char(start_time, 'DD-MON-RR HH24:MI:SS') start_time, item , sofar
from v$recovery_progress
where item in ('Active Apply Rate', 'Average Apply Rate', 'Redo Applied');
@genarc:
-------
select to_char(trunc(first_time), 'Mon DD') "DG Date",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "12am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "01am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "02am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "03am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "04am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "05am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "06am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "07am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "08am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "09am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "10am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "11am",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "12pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "01pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "02pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "03pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "04pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "05pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "06pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "07pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "08pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "09pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "10pm",
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'9999') "11pm"
from v$log_history
group by trunc(first_time)
order by trunc(first_time) desc
;
select thread#, low_sequence#, high_sequence# from v$archive_gap;
select dest_id,max(sequence#), thread# from v$archived_log group by thread#,dest_id;
## On the primary run the below
select L.thread#, L.sequence#
from
(select thread#, sequence# from v$archived_log where dest_id=1) L
where L.sequence# not in
(select sequence# from v$archived_log where dest_id=2 and thread# = L.thread#);
select to_char(start_time, 'DD-MON-RR HH24:MI:SS') start_time, item , sofar
from v$recovery_progress
where item in ('Active Apply Rate', 'Average Apply Rate', 'Redo Applied');
col name for a13
col value for a13
col unit for a30
set lines 132
select name, value, unit, time_computed from v$dataguard_stats where name in ('transport lag', 'apply lag');
col name for a25
col value for a20
col unit for a40
select distinct name, value, unit, time_computed from v$dataguard_stats;
SELECT MESSAGE FROM V$DATAGUARD_STATUS;
select message, to_char(timestamp,’HH:MI:SS’) timestamp
from v$dataguard_status
where severity in (‘Error’,’Fatal’)
order by timestamp
col type for a30
col COMMENTS for a30
select * from v$recovery_progress;
col client_pid for a10;
select pid, process, status, client_process, client_pid, thread#, sequence#, block#, blocks from v$managed_standby;
select * from V$ARCHIVE_DEST_STATUS where dest_name like 'LOG_ARCHIVE_DEST_2';
select current_scn from v$database;
select scn_to_timestamp(190469922) from dual;
=======================================================================================
PGA
From Oracle FAQ
Jump to: navigation, search
The PGA (Program or Process Global Area) is a memory area (RAM) that stores data and control information for a single process. For example, it typically contains a sort area, hash area, session cursor cache, etc.
[edit] Auto tuning
PGA areas can be sized manually by setting parameters like hash_area_size, sort_area_size etc.
To allow Oracle to auto tune the PGA areas, set the WORKAREA_SIZE_POLICY parameter to AUTO and the PGA_AGGREGATE_TARGET to the size of memory that can be used for PGA. This feature was introduced in Oracle 9i.
Oracle 11g allows users to tune both PGA and SGA areas with a single parameter, called MEMORY_TARGET.
[edit] Monitor
PGA usage statistics:
select * from v$pgastat;
Determine a good setting for pga_aggregate_target:
select * from v$pga_target_advice order by pga_target_for_estimate;
Show the maximum PGA usage per process:
select max(pga_used_mem), max(pga_alloc_mem), max(pga_max_mem) from v$process;
# tnsnames.ora.ideasmintdb Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora.ideasmintdb
# Generated by Oracle configuration tools.
IPC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = IPC_test1))
)
(CONNECT_DATA =
(SERVICE_NAME = IDEAS2)
)
)
MINT =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MINT)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
HDFCDBPROD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.0.201)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = HDFCDB)
)
)
LISTENER_MINT2 =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.1.95)(PORT = 1521))
LISTENER_MINT1 =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.1.94)(PORT = 1521))
LISTENERS_PINNACLE =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
)
PINNACLE2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PINNACLE)
(INSTANCE_NAME = PINNACLE2)
)
)
PINNACLE1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PINNACLE)
(INSTANCE_NAME = PINNACLE1)
)
)
LISTENER_+ASM2 =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
PINNACLE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PINNACLE)
)
)
hdfcprod_new =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 124.30.56.83)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 124.30.56.84)(PORT = 1521))
(LOAD_BALANCE = yes)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = hdfcprod)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
MINT2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MINT)
(INSTANCE_NAME = MINT2)
)
)
MINT1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MINT)
(INSTANCE_NAME = MINT1)
)
)
IDEASUAT =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.0.252)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = IDEASUAT)
)
)
LISTENERS_MINT =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = MINTIDEASDB-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = IDEASMINTDB-vip)(PORT = 1521))
)
===== GOLDEN GATE
SQL> @$GGATE/marker_setup.sql
SQL> @$GGATE/ddl_setup.sql
SQL> @$GGATE/role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ggate;
SQL> @$GGATE/ddl_enable.sql
--extract group--
extract ext1
--connection to database--
userid ggate@prim, password qwerty
--hostname and port for trail--
rmthost newods, mgrport 7807
--path and name for trail--
rmttrail D:\GGS\v22234-01-170861\DIRDAT\CA
--DDL support
ddl include mapped objname sender.*;
--DML
table sender.*
extract ext1
userid ggate@prim, password qwerty
rmthost newods, mgrport 7807
rmttrail D:\GGS\v22234-01-170861\DIRDAT\CE
ddl include mapped objname sender.*;
table sender.*
add exttrail D:\GGS\v22234-01-170861\DIRDAT\CE, extract ext1
GGSCI (newods) 261> view params load1
EXTRACT load1
EXTTRAIL D:\GGS\v22234-01-170861\DIRDAT\CA
DISCARDFILE D:\GGS\v22234-01-170861\DIRRPT\EXTPUMP_DSC_CA.RPT,PURGE
USERID sys@prim, PASSWORD ggs sysdba
TABLE ggs.info;
view params global
GGSCHEMA ggate
CHECKPOINTTABLE ggate.checkpoint
delete replicat rep1, exttrail D:\GGS\v22234-01-170861\DIRDAT\CA, checkpointtable ggate.checkpoint
alter replicat rep3, exttrail D:\GGS\v22234-01-170861\DIRDAT\CE, checkpointtable ggate.checkpoint
--Replicat group --
replicat rep3
--source and target definitions
ASSUMETARGETDEFS
--target database login --
userid ggate@prim, password qwerty
--file for dicarded transaction --
discardfile D:\GGS\v22234-01-170861\DISCARD\rep3_discard.txt, append, megabytes 10
--ddl support
DDL
--Specify table mapping ---
map sender.*, target rr.*;
This example illustrates using the GoldenGate direct load method to extract records from an Oracle 11g database on Red Hat Linux platform and load the same into an Oracle 11g target database on an AIX platform.
The table PRODUCTS in the SH schema on the source has 72 rows and on the target database the same table is present only in structure without any data. We will be loading the 72 rows in this example from the source database to the target database using GoldenGate Direct Load method.
On Source
1) Create the Initial data extract process ‘load1'
GGSCI (redhat346.localdomain) 5> ADD EXTRACT load1, SOURCEISTABLE
EXTRACT added.
Since this is a one time data extract task, the source of the data is not the transaction log files of the RDBMS (in this case the online and archive redo log files) but the table data itself, that is why the keyword SOURCEISTABLE is used.
2) Create the parameter file for the extract group load1
EXTRACT: name of the extract group
USERID/PASSWORD: the database user which has been configured earlier for Extract ( this user is created in the source database)
RMTHOST: This will be the IP address or hostname of the target system
MGRPORT: the port where the Manager process is running
TABLE: specify the table which is being extracted and replicated. This can be specified in a number of ways using wildcard characters to include or exclude tables as well as entire schemas.
GGSCI (redhat346.localdomain) 6> EDIT PARAMS load1
EXTRACT load1
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST devu007, MGRPORT 7809
RMTTASK replicat, GROUP load2
TABLE sh.products;
On Target
3) Create the initial data load task ‘load2'
Since this is a one time data load task, we are using the keyword SPECIALRUN
GGSCI (devu007) 1> ADD REPLICAT load2, SPECIALRUN
REPLICAT added.
4) Create the parameter file for the Replicat group, load2
REPLICAT: name of the Replicat group created for the initial data load
USERID/PASSWORD: database credentials for the Replicat user (this user is created in the target database)
ASSUMETARGETDEFS: this means that the source table structure exactly matches the target database table structure
MAP: with GoldenGate we can have the target database structure entirely differ from that of the source in terms of table names as well as the column definitions of the tables. This parameter provides us the mapping of the source and target tables which is same in this case
GGSCI (devu007) 2> EDIT PARAMS load2
“/u01/oracle/software/goldengate/dirprm/rep4.prm” [New file]
REPLICAT load2
USERID ggs_owner, PASSWORD ggs_owner
ASSUMETARGETDEFS
MAP sh.customers, TARGET sh.customers;
On Source
SQL> select count(*) from products;
COUNT(*)
———-
72
On Target
SQL> select count(*) from products;
COUNT(*)
———-
0
On Source
5) Start the initial load data extract task on the source system
We now start the initial data load task load 1 on the source. Since this is a one time task, we will initially see that the extract process is runningand after the data load is complete it will be stopped. We do not have to manually start the Replicat process on the target as that is done when the Extract task is started on the source system.
On Source
GGSCI (redhat346.localdomain) 16> START EXTRACT load1
Sending START request to MANAGER …
EXTRACT LOAD1 starting
GGSCI (redhat346.localdomain) 28> info extract load1
EXTRACT LOAD1 Last Started 2010-02-11 11:33 Status RUNNING
Checkpoint Lag Not Available
Log Read Checkpoint Table SH.PRODUCTS
2010-02-11 11:33:16 Record 72
Task SOURCEISTABLE
GGSCI (redhat346.localdomain) 29> info extract load1
EXTRACT LOAD1 Last Started 2010-02-11 11:33 Status STOPPED
Checkpoint Lag Not Available
Log Read Checkpoint Table SH.PRODUCTS
2010-02-11 11:33:16 Record 72
Task SOURCEISTABLE
On Target
SQL> select count(*) from products;
COUNT(*)
———-
72
Coming Soon! – Creating an Online Extract and Replicat Group for Change Synchronization …..
http://gavinsoorma.com/2010/02/goldengate-concepts-and-architecture/
The Data Pump (not to be confused with the Oracle Export Import Data Pump) is an optional secondary Extract group that is created on the source system. When Data Pump is not used, the Extract process writes to a remote trail that is located on the target system using TCP/IP. When Data Pump is configured, the Extract process writes to a local trail and from here Data Pump will read the trail and write the data over the network to the remote trail located on the target system.
The advantages of this can be seen as it protects against a network failure as in the absence of a storage device on the local system, the Extract process writes data into memory before the same is sent over the network. Any failures in the network could then cause the Extract process to abort (abend). Also if we are doing any complex data transformation or filtering, the same can be performed by the Data Pump. It will also be useful when we are consolidating data from several sources into one central target where data pump on each individual source system can write to one common trail file on the target.
Create the Extract process
GGSCI (devu007) 1> ADD EXTRACT ext1, TRANLOG, BEGIN NOW
EXTRACT added.
Create a local trail
Using the ADD EXTRAIL command we will now create a local trail on the source system where the Extract process will write to and which is then read by the Data Pump process. We will link this local trail to the Primary Extract group we just created, ext1
GGSCI (devu007) 3> ADD EXTTRAIL /u01/oracle/software/goldengate/dirdat/lt, EXTRACT ext1
EXTTRAIL added.
Create the Data Pump group
On the source system create the Data Pump group and using the EXTTRAILSOURCE keywork specify the location of the local trail which will be read by the Data Pump process
GGSCI (devu007) 4> ADD EXTRACT dpump, EXTTRAILSOURCE /u01/oracle/software/goldengate/dirdat/lt
EXTRACT added.
Create the parameter file for the Primary Extract group
GGSCI (devu007) 5> EDIT PARAMS ext1
“/u01/oracle/software/goldengate/dirprm/ext1.prm” [New file]
EXTRACT ext1
USERID ggs_owner, PASSWORD ggs_owner
EXTTRAIL /u01/oracle/software/goldengate/dirdat/lt
TABLE MONITOR.WORK_PLAN;
Specify the location of the remote trail on the target system
Use the RMTTRAIL to specify the location of the remote trail and associate the same with the Data Pump group as it will be wriiten to over the network by the data pump process
GGSCI (devu007) 6> ADD RMTTRAIL /u01/oracle/ggs/dirdat/rt, EXTRACT dpump
RMTTRAIL added.
Create the parameter file for the Data Pump group
Note- the parameter PASSTHRU signifies the mode being used for the Data Pump which means that the names of the source and target objects are identical and no column mapping or filtering is being performed here.
GGSCI (devu007) 2> EDIT PARAMS dpump
“/u01/oracle/software/goldengate/dirprm/dpump.prm” [New file]
EXTRACT dpump
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST redhat346, MGRPORT 7809
RMTTRAIL /u01/oracle/ggs/dirdat/rt
PASSTHRU
TABLE MONITOR.WORK_PLAN;
ON TARGET SYSTEM
Create the Replicat group
The EXTTRAIL clause indicates the location of the remote trail and should be the same as the RMTTRAIL value that was used when creating the Data Pump process on the source system.
GGSCI (redhat346.localdomain) 2> ADD REPLICAT rep1, EXTTRAIL /u01/oracle/ggs/dirdat/rt
REPLICAT added.
Create the parameter file for the Replicat group
GGSCI (redhat346.localdomain) 3> EDIT PARAMS rep1
REPLICAT rep1
ASSUMETARGETDEFS
USERID ggs_owner, PASSWORD ggs_owner
MAP MONITOR.WORK_PLAN, TARGET MONITOR.WORK_PLAN;
ON SOURCE
On the source system, now start the Extract and Data Pump processes.
GGSCI (devu007) 3> START EXTRACT ext1
Sending START request to MANAGER …
EXTRACT EXT1 starting
GGSCI (devu007) 4> START EXTRACT dpump
Sending START request to MANAGER …
EXTRACT DPUMP starting
GGSCI (devu007) 5> info extract ext1
EXTRACT EXT1 Last Started 2010-02-18 11:23 Status RUNNING
Checkpoint Lag 00:40:52 (updated 00:00:09 ago)
Log Read Checkpoint Oracle Redo Logs
2010-02-18 10:42:19 Seqno 761, RBA 15086096
GGSCI (devu007) 6> INFO EXTRACT dpump
EXTRACT DPUMP Last Started 2010-02-18 11:23 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:02 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/lt000000
2010-02-18 11:15:10.000000 RBA 5403
Note- the data pump process is reading from the Local Trail file – /u01/oracle/software/goldengate/dirdat/lt000000
ON TARGET SYSTEM
Start the Replicat process
GGSCI (redhat346.localdomain) 4> START REPLICAT rep1
Sending START request to MANAGER …
REPLICAT REP1 starting
GGSCI (redhat346.localdomain) 5> STATUS REPLICAT rep1
REPLICAT REP1: RUNNING
Coming Next! – DDL change synchronization …
--Replicat group --
replicat rep1
--source and target definitions
ASSUMETARGETDEFS
--target database login --
userid ggate, password qwerty
--file for dicarded transaction --
discardfile D:\GGS\v22234-01-170861\DISCARD\rep1_discard.txt, append, megabytes 10
--ddl support
DDL
--Specify table mapping ---
map sender.*, target receiver.*;
In addition to providing replication support for all DML statements, we can also configure the GoldenGate environment to provide DDL support as well.
A number of prerequisite setup tasks need to be performed which we willl highlight here.
Run the following scripts from the directory where the GoldenGate software was installed.
The assumption here is that the database user GGS_OWNER has already been created and granted the required roles and privileges as discussed in our earlier tutorial.
Note - run the scripts as SYSDBA
SQL> @marker_setup
Marker setup script
You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter GoldenGate schema name:GGS_OWNER
Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGS_OWNER
======
Oracle GoldenGate not only provides us a replication solution that is Oracle version independent as well as platform independent, but we can also use it to do data transformation and data manipulation between the source and the target.
So we can use GoldenGate when the source and database database differ in table structure as well as an ETL tool in a Datawarehouse type environment.
We will discuss below two examples to demonstrate this feature – column mapping and filtering of data.
In example 1, we will filter the records that are extracted on the source and applied on the target – only rows where the JOB column value equals ‘MANAGER” in the MYEMP table will be considered for extraction.
In example 2, we will deal with a case where the table structure is different between the source database and the target database and see how column mapping is performed in such cases.
Example 1
Initial load of all rows which match the filter from source to target. The target database MYEMP table will only be populated with rows from the EMP table where filter criteria of JOB=’MANAGER’ is met.
On Source
GGSCI (redhat346.localdomain) 4> add extract myload1, sourceistable
EXTRACT added.
GGSCI (redhat346.localdomain) 5> edit params myload1
EXTRACT myload1
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST devu007, MGRPORT 7809
RMTTASK replicat, GROUP myload1
TABLE scott.myemp, FILTER (@STRFIND (job, “MANAGER”) > 0);
On Target
GGSCI (devu007) 2> add replicat myload1, specialrun
REPLICAT added.
GGSCI (devu007) 3> edit params myload1
“/u01/oracle/software/goldengate/dirprm/myload1.prm” [New file]
REPLICAT myload1
USERID ggs_owner, PASSWORD ggs_owner
ASSUMETARGETDEFS
MAP scott.myemp, TARGET sh.myemp;
On Source – start the initial load extract
GGSCI (redhat346.localdomain) 6> start extract myload1
Sending START request to MANAGER …
EXTRACT MYLOAD1 starting
On SOURCE
SQL> select count(*) from myemp;
COUNT(*)
———-
14
SQL> select count(*) from myemp where job=’MANAGER’;
COUNT(*)
———-
9
On TARGET
SQL> select count(*) from myemp where job=’MANAGER’;
COUNT(*)
———-
9
Create an online change extract and replicat group using a Filter
GGSCI (redhat346.localdomain) 10> add extract myload2, tranlog, begin now
EXTRACT added.
GGSCI (redhat346.localdomain) 11> add rmttrail /u01/oracle/software/goldengate/dirdat/bb, extract myload2
RMTTRAIL added.
GGSCI (redhat346.localdomain) 11> edit params myload2
EXTRACT myload2
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST 10.53.200.225, MGRPORT 7809
RMTTRAIL /u01/oracle/software/goldengate/dirdat/bb
TABLE scott.myemp, FILTER (@STRFIND (job, “MANAGER”) > 0);
On Target
GGSCI (devu007) 2> add replicat myload2, exttrail /u01/oracle/software/goldengate/dirdat/bb
REPLICAT added.
GGSCI (devu007) 3> edit params myload2
“/u01/oracle/software/goldengate/dirprm/myload2.prm” [New file]
REPLICAT myload2
ASSUMETARGETDEFS
USERID ggs_owner, PASSWORD ggs_owner
MAP scott.myemp, TARGET sh.myemp;
On Source – start the online extract group
GGSCI (redhat346.localdomain) 13> start extract myload2
Sending START request to MANAGER …
EXTRACT MYLOAD2 starting
GGSCI (redhat346.localdomain) 14> info extract myload2
EXTRACT MYLOAD2 Last Started 2010-02-23 11:04 Status RUNNING
Checkpoint Lag 00:27:39 (updated 00:00:08 ago)
Log Read Checkpoint Oracle Redo Logs
2010-02-23 10:36:51 Seqno 214, RBA 103988
On Target
GGSCI (devu007) 4> start replicat myload2
Sending START request to MANAGER …
REPLICAT MYLOAD2 starting
GGSCI (devu007) 5> info replicat myload2
REPLICAT MYLOAD2 Last Started 2010-02-23 11:05 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:08 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/bb000000
First Record RBA 989
On Source we now insert two rows into the MYEMP table – one which has the JOB value of ‘MANAGER’ and the other row which has the job value of ‘SALESMAN’
On SOURCE
SQL> INSERT INTO MYEMP
2 (empno,ename,job,sal)
3 VALUES
4 (1234,’GAVIN’,’MANAGER‘,10000);
1 row created.
SQL> commit;
Commit complete.
SQL> INSERT INTO MYEMP
2 (empno,ename,job,sal)
3 VALUES
4 (1235,’BOB’,’SALESMAN‘,1000);
1 row created.
SQL> commit;
Commit complete.
SQL> select count(*) from myemp;
COUNT(*)
———-
16
SQL> select count(*) from myemp where job=’MANAGER’;
COUNT(*)
———-
10
On Target, we will see that even though two rows have been inserted into the source MYEMP table, on the target MYEMP table only one row is inserted because the filter has been applied which only includes the rows where the JOB value equals ‘MANAGER’.
SQL> select count(*) from myemp;
COUNT(*)
———-
10
Example 2 – source and target table differ in column structure
In the source MYEMP table we have a column named SAL whereas on the target, the same MYEMP table has the column defined as SALARY.
Create a definitions file on the source using DEFGEN utility and then copy that definitions file to the target system
GGSCI (redhat346.localdomain) > EDIT PARAMS defgen
DEFSFILE /u01/oracle/ggs/dirsql/myemp.sql
USERID ggs_owner, PASSWORD ggs_owner
TABLE scott.myemp;
[oracle@redhat346 ggs]$ ./defgen paramfile /u01/oracle/ggs/dirprm/defgen.prm
***********************************************************************
Oracle GoldenGate Table Definition Generator for Oracle
Version 10.4.0.19 Build 002
Linux, x64, 64bit (optimized), Oracle 11 on Sep 18 2009 00:09:13
Copyright (C) 1995, 2009, Oracle and/or its affiliates. All rights reserved.
Starting at 2010-02-23 11:22:17
***********************************************************************
Operating System Version:
Linux
Version #1 SMP Wed Dec 17 11:41:38 EST 2008, Release 2.6.18-128.el5
Node: redhat346.localdomain
Machine: x86_64
soft limit hard limit
Address Space Size : unlimited unlimited
Heap Size : unlimited unlimited
File Size : unlimited unlimited
CPU Time : unlimited unlimited
Process id: 14175
***********************************************************************
** Running with the following parameters **
***********************************************************************
DEFSFILE /u01/oracle/ggs/dirsql/myemp.sql
USERID ggs_owner, PASSWORD *********
TABLE scott.myemp;
Retrieving definition for SCOTT.MYEMP
Definitions generated for 1 tables in /u01/oracle/ggs/dirsql/myemp.sql
If we were to try and run the replicat process on the target without copying the definitions file, we will see an error as shown below which pertains to the fact that the columns in the source and target database are different and GoldenGate is not able to resolve that.
2010-02-23 11:31:07 GGS WARNING 218 Aborted grouped transaction on ‘SH.MYEMP’, Database error 904 (ORA-00904: “SAL”: invalid identifier).
2010-02-23 11:31:07 GGS WARNING 218 SQL error 904 mapping SCOTT.MYEMP to SH.MYEMP OCI Error ORA-00904: “SAL”: invalid identifier (status = 904), SQL .
We then ftp the definitions file from the source to the target system – in this case to the dirsql directory located in the top level GoldenGate installed software directory
We now go and make a change to the original replicat parameter file and change the parameter ASSUMEDEFS to SOURCEDEFS which provides GoldenGate with the location of the definitions file.
The other parameter which is included is the COLMAP parameter which tells us how the column mapping has been performed. The ‘USEDEFAULTS’ keyword denotes that all the other columns in both tables are identical except for the columns SAL and SALARY which differ in both tables and now we are mapping the SAL columsn in source to the SALARY column on the target.
REPLICAT myload2
SOURCEDEFS /u01/oracle/software/goldengate/dirsql/myemp.sql
USERID ggs_owner, PASSWORD ggs_owner
MAP scott.myemp, TARGET sh.myemp,
COLMAP (usedefaults,
salary = sal);
We now go and start the originall replicat process myload2 which had abended because of the column mismatch (which has now been corrected via the parameter change) and we see that the process now is running without any error.
now go and start the process which had failed after table modification
GGSCI (devu007) 2> info replicat myload2
REPLICAT MYLOAD2 Last Started 2010-02-23 11:05 Status ABENDED
Checkpoint Lag 00:00:03 (updated 00:11:44 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/bb000000
2010-02-23 11:31:03.999504 RBA 1225
GGSCI (devu007) 3> start replicat myload2
Sending START request to MANAGER …
REPLICAT MYLOAD2 starting
GGSCI (devu007) 4> info replicat myload2
REPLICAT MYLOAD2 Last Started 2010-02-23 11:43 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:03 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/bb000000
2010-02-23 11:31:03.999504 RBA 1461
Coming Next! – Monitoring the GoldenGate environment …..
MARKER TABLE
-------------------------------
OK
MARKER SEQUENCE
-------------------------------
OK
Script complete.
SQL> alter session set recyclebin=OFF;
Session altered.
SQL> @ddl_setup
GoldenGate DDL Replication setup script
Verifying that current user has privileges to install DDL Replication...
You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: On Oracle 10g and up, system recycle bin must be disabled.
NOTE: Stop all DDL replication before starting this installation.
Enter GoldenGate schema name:GGS_OWNER
You will be prompted for the mode of installation.
To install or reinstall DDL replication, enter INITIALSETUP
To upgrade DDL replication, enter NORMAL
Enter mode of installation:INITIALSETUP
Working, please wait ...
Spooling to file ddl_setup_spool.txt
Using GGS_OWNER as a GoldenGate schema name, INITIALSETUP as a mode of installation.
Working, please wait ...
RECYCLEBIN must be empty.
This installation will purge RECYCLEBIN for all users.
To proceed, enter yes. To stop installation, enter no.
Enter yes or no:yes
DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGS_OWNER
DDLORA_GETTABLESPACESIZE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
CLEAR_TRACE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
CREATE_TRACE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
TRACE_PUT_LINE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
INITIAL_SETUP STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDLVERSIONSPECIFIC PACKAGE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDLREPLICATION PACKAGE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDLREPLICATION PACKAGE BODY STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDL HISTORY TABLE
-----------------------------------
OK
DDL HISTORY TABLE(1)
-----------------------------------
OK
DDL DUMP TABLES
-----------------------------------
OK
DDL DUMP COLUMNS
-----------------------------------
OK
DDL DUMP LOG GROUPS
-----------------------------------
OK
DDL DUMP PARTITIONS
-----------------------------------
OK
DDL DUMP PRIMARY KEYS
-----------------------------------
OK
DDL SEQUENCE
-----------------------------------
OK
GGS_TEMP_COLS
-----------------------------------
OK
GGS_TEMP_UK
-----------------------------------
OK
DDL TRIGGER CODE STATUS:
Line/pos Error
---------- -----------------------------------------------------------------
No errors No errors
DDL TRIGGER INSTALL STATUS
-----------------------------------
OK
DDL TRIGGER RUNNING STATUS
-----------------------------------
ENABLED
STAYMETADATA IN TRIGGER
-----------------------------------
OFF
DDL TRIGGER SQL TRACING
-----------------------------------
0
DDL TRIGGER TRACE LEVEL
-----------------------------------
0
LOCATION OF DDL TRACE FILE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/gavin/gavin/trace/ggs_ddl_trace.log
Analyzing installation status...
STATUS OF DDL REPLICATION
--------------------------------------------------------------------------------
SUCCESSFUL installation of DDL Replication software components
Script complete.
SQL>
SQL> @role_setup
GGS Role setup script
This script will drop and recreate the role GGS_GGSUSER_ROLE
To use a different role name, quit this script and then edit the params.sql script to change
the gg_role parameter to the preferred name. (Do not run the script.)
You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter GoldenGate schema name:GGS_OWNER
Wrote file role_setup_set.txt
PL/SQL procedure successfully completed.
Role setup script complete
Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:
GRANT GGS_GGSUSER_ROLE TO
where is the user assigned to the GoldenGate processes.
SQL> grant ggs_ggsuser_role to ggs_owner;
Grant succeeded.
SQL> @ddl_enable
Trigger altered.
SQL> @ddl_pin GGS_OWNER
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Turn Recyclebin OFF
We need to set the parameter recyclebin to OFF via the ALTER SYSTEM SET RECYCLEBIN=OFF command in order to prevent this error which we will see if we try and configure DDL support and then start the Extract process.
2010-02-19 11:13:30 GGS ERROR 2003 RECYCLEBIN must be turned off. For 10gr2 and up, set RECYCLEBIN in parameter file to OFF. For 10gr1, set _RECYCLEBI
N in parameter file to FALSE. Then restart database and extract.
2010-02-19 11:13:30 GGS ERROR 190 PROCESS ABENDING.
Enable additional logging at the table level
Note- We had earlier enabled additional supplemental logging at the database level. Using the ADD TRANDATA command we now enable it at even the table level as this is required by GoldenGate for DDL support.
GGSCI (redhat346.localdomain) 5> DBLOGIN USERID ggs_owner, PASSWORD ggs_owner
Successfully logged into database.
GGSCI (redhat346.localdomain) 6> ADD TRANDATA scott.emp
Logging of supplemental redo data enabled for table SCOTT.EMP.
Edit the parameter file for the Extract process to enable DDL synchronization
We had earlier created a parameter file for an Extract process ext1. We now edit that parameter file and add the entry
DDL INCLUDE MAPPED
This means that DDL support is now enabled for all tables which have been mapped and in this case it will only apply to the SCOTT.EMP table as that is the only table which is being processed here. We can also use the INCLUDE ALL or EXCLUDE ALL or wildcard characters to specify which tables to enable the DDL support for.
GGSCI (redhat346.localdomain) 1> EDIT PARAM EXT1
EXTRACT ext1
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST 10.53.100.100, MGRPORT 7809
RMTTRAIL /u01/oracle/software/goldengate/dirdat/rt
DDL INCLUDE MAPPED
TABLE scott.emp;
Test the same
We will now alter the structure of the EMP table by adding a column and we can see that this new table structure is also reflected on the target system.
On Source
SQL> ALTER TABLE EMP ADD NEW_COL VARCHAR2(10);
Table altered.
On Target
SQL> desc emp
Name Null? Type
—————————————– ——– —————————-
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(20)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
MYCOL VARCHAR2(10)
NEW_COL VARCHAR2(10)
These errors are characteristic to memory exhaustion problems. Either enough memory is not available on the server, or, the memory is not configured to sustain the Oracle software needs.
Please apply the suggested solutions from 'ORA-07445 [ACCESS_VIOLATION] [unable_to_trans_pc] on Windows Platforms (Doc ID 456801.1)'. I will place the SR in monitoring status, waiting for your feedback for 1 week. The ora-7445 mentioned in the note is not mandatory, but the memory issues and the suggestions are valid, so please implement the recommendations.
I will follow up with you next Monday, June 20th.
Best regards,
Adina
Global Customer Services
Solution
Please refer to Note 342443.1 and apply latest minipack.
Have sufficient physical memory on Server so that you can allocate more SGA/PGA to the database.
1) Increase SGA_MAX_SIZE and SGA_TARGET so that you can accommodate following pools.
2) Restart the instance.
3) Increase INIT.ORA memory parameters and make sure following pools are set to recommended value i.e. 200M.
a) SHARED_POOL_SIZE
b) JAVA_POOL_SIZE
c) STREAMS_POOL_SIZE
Directing LogMiner Operations and Retrieving Data of Interest
You direct LogMiner operations using the DBMS_LOGMNR and DBMS_LOGMNR_D PL/SQL packages, and retrieve data of interest using the V$LOGMNR_CONTENTS view, as follows:
Specify a LogMiner dictionary.
Use the DBMS_LOGMNR_D.BUILD procedure or specify the dictionary when you start LogMiner (in Step 3), or both, depending on the type of dictionary you plan to use.
Specify a list of redo log files for analysis.
Use the DBMS_LOGMNR.ADD_LOGFILE procedure, or direct LogMiner to create a list of log files for analysis automatically when you start LogMiner (in Step 3).
Start LogMiner.
Use the DBMS_LOGMNR.START_LOGMNR procedure.
Request the redo data of interest.
Query the V$LOGMNR_CONTENTS view. (You must have the SELECT ANY TRANSACTION privilege to query this view.)
End the LogMiner session.
Use the DBMS_LOGMNR.END_LOGMNR procedure.
You must have been granted the EXECUTE_CATALOG_ROLE role to use the LogMiner PL/SQL packages and to query the V$LOGMNR_CONTENTS view.
Note:
When mining a specified time or SCN range of interest within archived logs generated by an Oracle RAC database, you must ensure that you have specified all archived logs from all redo threads that were active during that time or SCN range. If you fail to do this, any queries of V$LOGMNR_CONTENTS will return only partial results (based on the archived logs specified to LogMiner through the DBMS_LOGMNR.ADD_LOGFILE procedure). This restriction is also in effect when you are mining the archived logs at the source database using the CONTINUOUS_MINE option. You should only use CONTINUOUS_MINE on an Oracle RAC database if no thread is being enabled or disabled.
DBMS_LOGMNR.ADD_LOGFILE
DBMS_LOGMNR_D.BUILD
DBMS_LOGMNR.ADD_LOGFILE
DBMS_LOGMNR.START_LOGMNR
V$LOGMNR_CONTENTS
DBMS_LOGMNR.END_LOGMNR
Check in that table st_inward_temp
======== Restore from RMAN (Any DB can be used for the same)========
399302992110
399303211009
run
{
set archivelog destination to '/opt/oracle/admin/RMAN_18082014';
restore archivelog from scn 399302992110 until scn 399303211009;
}
run
{
set archivelog destination to '/archive/arch/MD1';
restore archivelog from scn 4872613932 until scn 4873978397;
}
run
{
set archivelog destination to '/opt/oracle/admin/RMAN_18082014/';
restore archivelog from sequence until sequence 140580;
}
run
{
allocate channel 'T1' type 'SBT_TAPE' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt.P44)';
set archivelog destination to '/u025/';
restore archivelog from sequence 140481 until sequence 140580;
release channel 'T1';
}
2 7194 12-JAN-2014 01:30:06
1 7855 12-JAN-2014 01:30:06
1 7856 12-JAN-2014 03:41:56
7213
7873
run
{
allocate channel 'T1' type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=ustlscbu104,NSR_CLIENT=ustsmcdcvtc011,NSR_DATA_VOLUME_POOL=Oracletape)';
allocate channel 'T2' type 'SBT_TAPE' parms 'ENV=(NSR_SERVER=ustlscbu104,NSR_CLIENT=ustsmcdcvtc011,NSR_DATA_VOLUME_POOL=Oracletape)';
set archivelog destination to '/u115/dbarchive/SGRP/';
restore archivelog from sequence 7855 until sequence 7873 thread 1;
restore archivelog from sequence 7194 until sequence 7213 thread 2;
release channel 'T1';
release channel 'T1';
}
@
2025 - 2042
cd /u025/
gz *.arc
scp *.arc.gz bznvjs@ustlsoi011:/u025/arch/TST44
scp P44_control_hot_20140511.ctl qz4x1r@ustlsoi011:/home/oracle/rr
======== LOG MINING ==================
EXECUTE DBMS_LOGMNR.ADD_LOGFILE('/adhocfcdump/rman_bak/rr/1_75430_740933967.dbf');
EXECUTE DBMS_LOGMNR.ADD_LOGFILE('/adhocfcdump/rman_bak/rr/2_69405_740933967.dbf');
execute DBMS_LOGMNR.START_LOGMNR();
create table LOGMNR_rr as select * from V$LOGMNR_CONTENTS where 1 = 2;
select * from V$LOGMNR_CONTENTS where upper(seg_name) = upper('st_inward_temp');
insert into LOGMNR_rr (select * from V$LOGMNR_CONTENTS where upper(seg_name) = upper('st_inward_temp'));
execute DBMS_LOGMNR.END_LOGMNR();
=======================================
select sid,serial#,SOFAR,TOTALWORK,START_TIME,LAST_UPDATE_TIME,time_remaining from gv$session_longops where sofar <> totalwork;
Hi
Kindly check the query below / depends on AWR retention
command type (7) - delete
SELECT st.executions_total||'--'||SP.SQL_ID||'--'||COST ||'--'||ds.BEGIN_INTERVAL_TIME||'--'||ds.END_INTERVAL_TIME
FROM DBA_HIST_SQL_PLAN SP,DBA_HIST_SQLSTAT ST
,DBA_HIST_SNAPSHOT ds WHERE
SP.SQL_ID=ST.SQL_ID AND ds.SNAP_ID=ST.SNAP_ID AND
st.executions_total> 1 and cost >1 and
to_date(to_char(ds.BEGIN_INTERVAL_TIME,'dd-mm-yyyy hh24:mi'),'dd-mm-yyyy hh24:mi') >= to_date('15-11-2011 13:00','dd-mm-yyyy hh24:mi')
and to_date(to_char(ds.BEGIN_INTERVAL_TIME,'dd-mm-yyyy hh24:mi'),'dd-mm-yyyy hh24:mi')
<= to_date('15-11-2011 15:00','dd-mm-yyyy hh24:mi')
AND SP.SQL_ID IN
(SELECT SQL_ID FROM DBA_HIST_SQLTEXT WHERE SQL_ID IN (
SELECT distinct SP.SQL_ID FROM DBA_HIST_SQL_PLAN SP,DBA_HIST_SQLSTAT ST
,DBA_HIST_SNAPSHOT ds WHERE
SP.SQL_ID=ST.SQL_ID AND ds.SNAP_ID=ST.SNAP_ID
) and COMMAND_TYPE IN (7))
ORDER BY st.executions_total,COST,ds.BEGIN_INTERVAL_TIME;
Regards
Prasad Joshi
select sid,SQL_HASH_VALUE,opname,sofar,totalwork,round(time_remaining/60,2) time_remain_mins from gv$session_longops where time_remaining >0 order by time_remaining desc;
/
select sid,SQL_HASH_VALUE,opname,sofar,totalwork,round(time_remaining/60,2) time_remain_mins from gv$session_longops where time_remaining >0 order by time_remaining desc
=== Check Session remaining Time.
col target for a30
col opname for a30
col program for a30
col event for a40
select s.sid,l.opname,l.target,l.sofar,l.totalwork,round(l.time_remaining/60,2) time_remain_mins,l.SQL_HASH_VALUE,s.serial#,s.program,s.event
from gv$session_longops l,gv$session s
where s.sid=l.sid
and time_remaining >0
and program like '%sqlplus%'
order by time_remaining desc
;
col target for a30
col opname for a30
col program for a30
col event for a40
select s.sid,l.opname,l.target,l.sofar,l.totalwork,round(l.time_remaining/60,2) time_remain_mins,l.SQL_HASH_VALUE,s.serial#,s.program
from gv$session_longops l,gv$session s
where s.sid=l.sid
and time_remaining >0
and program like '%sqlplus%'
order by time_remaining desc
;
col target for a30
col opname for a30
col program for a30
col event for a40
select s.sid,l.opname,l.target,l.sofar,l.totalwork,round(l.time_remaining/60,2) time_remain_mins,l.SQL_HASH_VALUE,s.serial#,s.program,s.event
from v$session_longops l, v$session s
where s.sid=l.sid
--and time_remaining >0
and program like '%sqlplus%'
order by time_remaining desc
;
grant select on CASE_INFORMATION to wondersii;
AUDIT_TRAIL
PROPOSALS
STAFFO
M_PRDCTS
M_MST_GRP_DTL
M_BRANCH
SLA_BRANCH_MASTER
--- STATSPACK
sqlplus "/ as sysdba"
@?/rdbms/admin/spcreate.sql
conn perfstat/perfstat
exec statspack.snap; --- Start SnapShot
@?/rdbms/admin/spreport.sql
-------------------------------------------------------------------------
Installation of the Oracle Statspack tool is a relatively simple process. The following is a step-by-step guide to the process of installing Oracle Statspack on a UNIX system.
1. Navigate to the $ORACLE_HOME/rdbms/admin directory as follows:
# cd $ORACLE_HOME/rdbms/admin/
2. Start the Statspack install script, spcreate.sql, as follows:
# sqlplus "/ as sysdba" @spcreate.sql
3. Enter a password for the PERFSTAT user when prompted.
4. Enter the default tablespace (tools) for the PERFSTAT user when prompted.
5. Enter the temporary tablespace (temp) for the PERFSTAT user when prompted.
6. Exit sqlplus as follows:
SQL> exit
To collect statistics
1. Connect to the database as the PERFSTAT user as follows:
sqlplus perfstat/<password>
2. Create a snapshot with the statspack package as follows:
SQL> execute statspack.snap(i_snap_level=>7);
3. Exit SQLPLUS as follows:
SQL> exit
To run a Statspack report.
1. Navigate to the $ORACLE_HOME/rdbms/admin directory as follows:
# cd $ORACLE_HOME/rdbms/admin/
2. Run the standard Statspack report as follows:
# sqlplus perfstat/<password> @spreport
* Enter a beginning snapshot ID.
* Enter an ending snapshot ID.
* Enter a name for the report or accept the default.
* Exit SQLPLUS as follows:
SQL> exit
Removing Statspack
To deinstall Statspack, connect as a user with SYSDBA privilege and run the following SPDROP script from SQL*Plus. For example:
SQL> CONNECT / AS SYSDBA
SQL> @?/rdbms/admin/spdrop
The SPDROP.SQL script calls the following scripts:
SPDTAB.SQL - drops tables and public synonyms
SPDUSR.SQL - drops the user
Check each of two output files produced (SPDTAB.LIS, SPDUSR.LIS) to ensure that the package was completely deinstalled.
Managing and Sharing Statspack Performance Data
This section discusses the following topics:
Sharing Data Through Export
Removing Unnecessary Data
Truncating All Statspack Data
Sharing Data Through Export
If you want to share data with other sites (for example, if Oracle Support requires the raw statistics), then you can export the PERFSTAT user. An export parameter file (SPUEXP.PAR) is supplied for this purpose. To use this file, supply the export command with the userid parameter, along with the export parameter file name. For example:
exp userid=perfstat/my_perfstat_password parfile=spuexp.par
This creates a file called SPUEXP.DMP and the log file SPUEXP.LOG. If you want to load the data into another database, use the import command.
See Also:
Oracle9i Database Utilities for more information on using export and import
Removing Unnecessary Data
Purge unnecessary data from the PERFSTAT schema using the SPPURGE.SQL script. This deletes snapshots that fall between the begin and end snapshot IDs you specify.
Note:
You should export the schema as a backup before running this script, either using your own export parameters or those provided in SPUEXP.PAR.
Purging can require the use of a large rollback segment, because all data relating to each snapshot ID to be purged is deleted. You can avoid rollback segment extension errors in one of two ways:
Specify a smaller range of snapshot IDs to purge.
Explicitly use a large rollback segment, by executing the SET TRANSACTION USE ROLLBACK SEGMENT statement before running the SPPURGE.SQL script.
See Also:
Oracle9i SQL Reference
When you run SPPURGE.SQL, it displays the instance to which you are connected and the available snapshots. It then prompts you for the low snap ID and high snap ID. All snapshots that fall within this range are purged.
Example 21-6 Sample Run of SPPURGE.SQL
SQL> CONNECT perfstat/my_perfstat_password
SQL> SET TRANSACTION USE ROLLBACK SEGMENT rbig;
SQL> @?/rdbms/admin/sppurge
Database Instance currently connected to
========================================
Instance
DB Id DB Name Inst Num Name
----------- ---------- -------- ----------
720559826 PERF 1 perf
Snapshots for this database instance
====================================
Snap
Snap Id Level Snapshot Started Host Comment
---------- ----- --------------------- --------------- -------------------
1 5 30 Feb 2000 10:00:01 perfhost
2 5 30 Feb 2000 12:00:06 perfhost
3 5 01 Mar 2000 02:00:01 perfhost
4 5 01 Mar 2000 06:00:01 perfhost
Caution:
SPPURGE.SQL deletes all snapshots ranging between the lower and upper bound snapshot IDs specified for the database instance connected to. You might want to export this data before continuing.
Specify the Low Snap ID and High Snap ID range to purge
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for losnapid: 1
Using 1 for lower bound.
Enter value for hisnapid: 2
Using 2 for upper bound.
Deleting snapshots 1 - 2
Purge of specified snapshot range complete. If you want to rollback the purge,
it is still possible to do so. Exiting from SQL*Plus automatically commits the
purge.
SQL> -- end of example output
To purge in batch mode, you must assign values to the SQL*Plus variables that specify the low and high snapshot IDs to purge. The variables are:
LOSNAPID: Begin snapshot ID
HISNAPID: End snapshot ID
Example 21-7 Running SPPURGE.SQL in Batch Mode
SQL> CONNECT perfstat/my_perfstat_password
SQL> DEFINE losnapid=1
SQL> DEFINE hisnapid=2
SQL> @?/rdbms/admin/sppurge
When SPPURGE.SQL is run, it does not prompt for the information provided by the variables.
Truncating All Statspack Data
To truncate all performance data indiscriminately, use SPTRUNC.SQL. This script truncates all statistics data gathered.
Note:
Oracle Corporation recommends that you export the schema as a backup before running this script, either using your own export parameters or those provided in SPUEXP.PAR.
Example 21-8 Sample Run of SPTRUNC.SQL
SQL> CONNECT perfstat/my_perfstat_password
SQL> @?/rdbms/admin/sptrunc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note:
Running SPTRUNC.SQL removes all data from Statspack tables. You might want to export the data before continuing.
If you would like to continue, enter any string, followed by <return>.
Enter value for anystring:
entered - starting truncate operation
Table truncated.
<etc>
Truncate operation complete.
----------------------
spool c:\Object_Check_IDB_OUTPUT.txt
select count(*) from dba_objects;
select object_type,count(*) from dba_objects group by object_type;
select owner,count(*) from dba_objects where status = 'INVALID' group by owner order by 1;
select owner,count(*) from dba_objects group by owner;
select count(*) from dba_synonyms;
select count(*) from dba_queues;
spool off;
k-- AUDIT
set head off
spool d:\audit_TEST.log;
select distinct a from (
select 'audit ' || a.privilege || ' by ' || username || ' by access;' a
from dba_users u, (select user_name,privilege from dba_priv_audit_opts) a)
order by 1
/
select distinct a from (
select 'noaudit ' || a.privilege || ' by ' || username || ';' a
from dba_users u, (select user_name,privilege from dba_priv_audit_opts where USER_NAME = 'TEST' and privilege like 'CREATE%') a
where u.created like '18-SEP-10')
order by 1
/
select distinct a from (
select 'noaudit ' || a.privilege || ' by ' || username || ';' a
from dba_users u, (select user_name,privilege from dba_priv_audit_opts where USER_NAME = 'TEST' and privilege like 'CREATE%') a
where u.created like '18-SEP-10')
order by 1
/
select user_name,privilege from dba_priv_audit_opts where USER_NAME = 'SYS';
select user_name,audit_option from dba_stmt_audit_opts where USER_NAME = 'SYS';
select ACTION_NAME,username,OWNER,OBJ_NAME,OBJ_PRIVILEGE,EXTENDED_TIMESTAMP from dba_audit_trail where username = 'AMS' order by 6;
select ACTION_NAME,username,OWNER,OBJ_NAME,OBJ_PRIVILEGE,EXTENDED_TIMESTAMP from dba_audit_trail where username = 'TESTRR2' order by 6;
select user_name,audit_option from dba_stmt_audit_opts where USER_NAME = 'TESTRR';
select user_name,privilege from dba_priv_audit_opts where USER_NAME = 'TESTRR';
select ACTION_NAME,username,OWNER,OBJ_NAME,OBJ_PRIVILEGE,EXTENDED_TIMESTAMP from dba_audit_trail where order by 6;
Auditing is disabled by default, but can enabled by setting the AUDIT_TRAIL static parameter, which has the following allowed values.
AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }The following list provides a description of each setting:
•none or false - Auditing is disabled.
•db or true - Auditing is enabled, with all audit records stored in the database audit trial (SYS.AUD$).
•db,extended - As db, but the SQL_BIND and SQL_TEXT columns are also populated.
•xml- Auditing is enabled, with all audit records stored as XML format OS files.
•xml,extended - As xml, but the SQL_BIND and SQL_TEXT columns are also populated.
•os- Auditing is enabled, with all audit records directed to the operating system's audit trail.
Note. In Oracle 10g Release 1, db_extended was used in place of db,extended. The XML options are new to Oracle 10g Release 2.
The AUDIT_SYS_OPERATIONS static parameter enables or disables the auditing of operations issued by users connecting with SYSDBA or SYSOPER privileges, including the SYS user. All audit records are written to the OS audit trail.
The AUDIT_FILE_DEST parameter specifies the OS directory used for the audit trail when the os, xml and xml,extended options are used. It is also the location for all mandatory auditing specified by the AUDIT_SYS_OPERATIONS parameter.
Statement level
Auditing will be done at statement level.
Statements that can be audited are found in STMT_AUDIT_OPTION_MAP.
SQL> audit table by scott;
Audit records can be found in DBA_STMT_AUDIT_OPTS.
SQL> select * from DBA_STMT_AUDIT_OPTS;
Object level
Auditing will be done at object level.
These objects can be audited: tables, views, sequences, packages, stored procedures and stored functions.
SQL> audit insert, update, delete on scott.emp by hr;
Audit records can be found in DBA_OBJ_AUDIT_OPTS.
SQL> select * from DBA_OBJ_AUDIT_OPTS;
Privilege level
Auditing will be done at privilege level.
All system privileges that are found in SYSTEM_PRIVILEGE_MAP can be audited.
SQL> audit create tablespace, alter tablespace by all;
Specify ALL PRIVILEGES to audit all system privileges.
Audit records can be found in DBA_PRIV_AUDIT_OPTS.
SQL> select * from DBA_PRIV_AUDIT_OPTS;
SELECT_PRIV
INSERT_PRIV
DELETE_PRIV
UPDATE_PRIV
REFERENCES_PRIV
ALTER_PRIV
INDEX_PRIV
audit grant on test.test1 by access;
noaudit grant on test.test1;
select ACTION_NAME,username,OWNER,grantee,OBJ_NAME,OBJ_PRIVILEGE from dba_audit_trail username = 'RONAK';
Obj_Privilege has below 16 Audit Trail Grants Systems, There is 16 (-) Hifns which means Grants.
HiPNS:
1 - ALTER
2 -
3 -
4 - DELETE
5 -
6 -
7 - INSERT
8 -
9 -
10 - SELECT
11 - UPDATE
12 -
13 -
14 -
15 -
16 -
grant insert,update,delete on test1 to rr;
---Y--Y---Y-----
audit alter any trigger by test by access;
AUDIT GRANT PROCEDURE BY USER;
AUDIT GRANT DIRECTORY
AUDIT GRANT SEQUENCE
AUDIT GRANT TABLE
AUDIT GRANT TYPE
AUDIT ROLE
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to ' || grantee from DBA_TAB_PRIVS where grantee like 'WONUAT';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to CP;' from DBA_TAB_PRIVS where owner like 'BLTS';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to || grantee ||';' from DBA_TAB_PRIVS where table_name in (select table_name from dba_external_tables);
ams_rate_master 10 - 144
SQL> select SQL_TEXT from v$sqltext where HASH_VALUE='3783944380' order by PIECE;
SQL_TEXT
----------------------------------------------------------------
SELECT DECODE(MDCG.DCMNT_CTGRY_CD,NULL,0, MDCG.DCMNT_CTGRY_CD) ,
DT.DCMNT_TYP_CD , DT.DSPLY_TXT, DECODE(NBD.DCMNT_TYP_CD,NULL,''
,'CHECKED') CHKSEQ, MWD.REQUIRED_YN FROM DCMNT_TYPS DT, NB_DCMNT
S NBD, M_WD_DCMNTS MWD, M_DCMNT_CTGRY_GRP_MAP MDCG WHERE NBD.NB_
REF_NO(+) = :B3 AND NBD.DCMNT_TYP_CD(+) = DT.DCMNT_TYP_CD AND MW
D.WD_DCMNT_GRP_CD = :B2 AND MWD.DCMNT_TYP_CD = DT.DCMNT_TYP_CD A
ND MWD.DCMNT_TYP_CD = MDCG.DCMNT_TYP_CD(+) AND MWD.DELETE_YN = :
B1 AND DT.DELETE_YN = :B1 ORDER BY MWD.DSPLY_SEQ, DT.DSPLY_TXT
vijay goka
ameya kul
vinayak sawant
supratim chaudh
=== Archive Check in Hours
select to_char(first_time,'YYYY-MON-DD') day,
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'99') "00",
to_char(sum(decode(to_char(first_time,'HH24'),'01',1,0)),'99') "01",
to_char(sum(decode(to_char(first_time,'HH24'),'02',1,0)),'99') "02",
to_char(sum(decode(to_char(first_time,'HH24'),'03',1,0)),'99') "03",
to_char(sum(decode(to_char(first_time,'HH24'),'04',1,0)),'99') "04",
to_char(sum(decode(to_char(first_time,'HH24'),'05',1,0)),'99') "05",
to_char(sum(decode(to_char(first_time,'HH24'),'06',1,0)),'99') "06",
to_char(sum(decode(to_char(first_time,'HH24'),'07',1,0)),'99') "07",
to_char(sum(decode(to_char(first_time,'HH24'),'08',1,0)),'99') "08",
to_char(sum(decode(to_char(first_time,'HH24'),'09',1,0)),'99') "09",
to_char(sum(decode(to_char(first_time,'HH24'),'10',1,0)),'99') "10",
to_char(sum(decode(to_char(first_time,'HH24'),'11',1,0)),'99') "11",
to_char(sum(decode(to_char(first_time,'HH24'),'12',1,0)),'99') "12",
to_char(sum(decode(to_char(first_time,'HH24'),'13',1,0)),'99') "13",
to_char(sum(decode(to_char(first_time,'HH24'),'14',1,0)),'99') "14",
to_char(sum(decode(to_char(first_time,'HH24'),'15',1,0)),'99') "15",
to_char(sum(decode(to_char(first_time,'HH24'),'16',1,0)),'99') "16",
to_char(sum(decode(to_char(first_time,'HH24'),'17',1,0)),'99') "17",
to_char(sum(decode(to_char(first_time,'HH24'),'18',1,0)),'99') "18",
to_char(sum(decode(to_char(first_time,'HH24'),'19',1,0)),'99') "19",
to_char(sum(decode(to_char(first_time,'HH24'),'20',1,0)),'99') "20",
to_char(sum(decode(to_char(first_time,'HH24'),'21',1,0)),'99') "21",
to_char(sum(decode(to_char(first_time,'HH24'),'22',1,0)),'99') "22",
to_char(sum(decode(to_char(first_time,'HH24'),'23',1,0)),'99') "23"
from v$log_history
where to_char(first_time,'YYYY') = 2010 and to_char(first_time,'MM') = 10
group by to_char(first_time,'YYYY-MON-DD') order by 1;
=== Recover Until Time
SQL> select 'recover standby database until time ''' || to_char(sysdate,'yyyy-mm-dd') || ':00:05:00'';' from dual;
SQL> recover standby database until time '2010-05-22:11:59:00';
SQL> select name,to_char(CHECKPOINT_TIME,'dd-mm-yyyy hh24:mi:ss') from v$datafile;
SQL> select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history where sequence# in (select max(sequence#) from v$log_history group by thread#);
recover database using backup controlfile until time '2011-10-16:12:00:00';
8 rows selected.
SQL> select username,schemaname,program,sid,serial# from v$session where sid=2896;
USERNAME SCHEMANAME PROGRAM SID SERIAL#
---------- ------------ ---------------------------------------------------------------- ---------- ----------
WONDERSII WONDERSII w3wp.exe 2896 60
SQL> select username,schemaname,program,sid,serial#,machine from v$session where sid=2896;
USERNAME SCHEMANAME PROGRAM SID SERIAL# MACHINE
---------- ------------ ---------------------------------------------------------------- ---------- ---------- ---------------
WONDERSII WONDERSII w3wp.exe 2896 60 HDFCSLDM\VMWOND
ERSWEB5
OBJ$
WRI$_ADV_OBJECTS
WRI$_ADV_OBJSPACE_TREND_DATA
WRI$_SEGADV_OBJLIST -- VIP Table
SYS.WRH$_SQLTEXT
SYS.WRH$_SQL_PLAN
SYS.WRI$_ADV_ACTIONS
SYS.WRI$_ADV_OBJECTS
SYS.WRI$_ADV_RATIONALE
SYS.WRI$_DBU_FEATURE_METADATA
SYS.WRI$_DBU_FEATURE_USAGE
SYS.WRI$_DBU_HWM_METADATA
SELECT snap_id, startup_time FROM dba_hist_snapshot ORDER BY 1,2;
oracle -
EXP--- This table is getting Used by Export to Take export. In Oracle 11g this table is having 1 more Column POLYTYP, that is the reason Export not working from Oracle 11G to Oracle 10G.
SQL> desc EXU9RLS
Name Null? Type
----------------------------------------- -------- ----------------------------
OBJOWN NOT NULL VARCHAR2(30)
OBJNAM NOT NULL VARCHAR2(30)
POLGRP NOT NULL VARCHAR2(30)
POLICY NOT NULL VARCHAR2(30)
POLOWN NOT NULL VARCHAR2(30)
POLSCH VARCHAR2(30)
POLFUN NOT NULL VARCHAR2(30)
STMT VARCHAR2(28)
CHKOPT NOT NULL NUMBER
ENABLED NOT NULL NUMBER
SPOLICY NUMBER
select inst_id,sid,serial#,program,event,action,machine,terminal,p1,p2,p3,schemaname from gv$session where sid=633;
select OPEN_RESETLOGS,DATABASE_ROLE,PLATFORM_NAME,SWITCHOVER_STATUS from v$database;
office 123,
kesar resi.,
above bhagwati hotel,
charkop,
VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'begin rr_update_resource_master; commit; end;',
SYSDATE, 'SYSDATE + 120/1440');
commit;
END;
/
print jobno
select log_user,what,job,broken,FAILURES,TOTAL_TIME,to_char(next_date,'dd-mm-yyyy hh24:mi:ss'),to_char(this_date,'dd-mm-yyyy hh24:mi:ss'),to_char(last_date,'dd-mm-yyyy hh24:mi:ss') from dba_jobs where job=81;
--upper(what) like '%AMS_PKG_UDAAN_DCHANNEL.AMS_SP_HIBERNATE_JOB%';
select log_user,what,job,broken,FAILURES,TOTAL_TIME,to_char(next_date,'dd-mm-yyyy hh24:mi:ss'),to_char(this_date,'dd-mm-yyyy hh24:mi:ss') from dba_jobs where job=1703;
col what for a60
col next_date for a20
col last_date for a20
select log_user,what,job,broken,FAILURES,TOTAL_TIME,to_char(next_date,'dd-mm-yyyy hh24:mi:ss') Next_Date,to_char(last_date,'dd-mm-yyyy hh24:mi:ss') Last_date,interval
from dba_jobs WHERE upper(what) like '%CREATE_REJTXNRPT%';
broken = 'Y';
job=1703;IN (76268,76269,76270);
col log_user for a10
col what for a60
col next_date for a20
col last_date for a20
select log_user,job,broken,FAILURES,TOTAL_TIME,to_char(next_date,'dd-mm-yyyy hh24:mi:ss') Next_Date,to_char(last_date,'dd-mm-yyyy hh24:mi:ss') Last_date,interval
from dba_jobs where last_date like sysdate;
WHERE job=1783;
VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'begin pclmmed.SP_INSTTMEDCLM; end;',
SYSDATE,'SYSDATE + 120/1440');
commit;
END;
/
print jobno
begin
dbms_job.change(755,'begin etl.pk_job_controller.sp_run_group(''CP-Daily-Schedulers''); end;',trunc(sysdate)+1,'trunc(sysdate)+1+8/24');
commit;
end;
/
exec dbms_job.next_date(755, SYSDATE + 11.5/24);
VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'begin etl.pk_job_controller.sp_run_group(''CP-Daily-Schedulers''); end;',
SYSDATE+1,'SYSDATE + 120/1440');
commit;
END;
/
print jobno
NOTE :- To stop a JOB in DBA_JOBS. 1st Disable DBA_JOB & then kill session. The only way to stop DBA_JOBS
BEGIN
DBMS_JOB.change(444,
'begin PRL_PKG_EXTERNAL_UPLOADS.sp_update_resource_master; commit; end;',
SYSDATE+120/1440, 'SYSDATE+180/1440');
commit;
END;
exec DBMS_JOB.run(464);
BEGIN
DBMS_JOB.REMOVE(6865);
COMMIT;
END;
BEGIN
DBMS_JOB.REMOVE(19718);
COMMIT;
END;
BEGIN
DBMS_IJOB.REMOVE(27192);
COMMIT;
END;
/
BEGIN
DBMS_JOB.broken(28730,TRUE);
COMMIT;
END;
/
BEGIN
DBMS_JOB.REMOVE(28730);
COMMIT;
END;
LOG_USER
------------------------------
WHAT
-----------------------------------------------------------------------------------------------------------------
-
JOB B FAILURES TOTAL_TIME TO_CHAR(NEXT_DATE,' TO_CHAR(THIS_DATE,'
---------- - ---------- ---------- ------------------- -------------------
HSLRNRPROD
EOD_UPD_INFC.PROCESS_FILE('001','BASE','SALES','220','cmanil',TO_DATE('22.06.2012', 'dd.MM.yyyy')) ;
19718 N 9 400 23-06-2012 17:01:07
BEGIN
DBMS_JOB.REMOVE(51);
COMMIT;
END;
BEGIN
DBMS_JOB.REMOVE(2);
COMMIT;
END;
BEGIN
DBMS_JOB.REMOVE(24);
COMMIT;
END;
EXEC DBMS_JOB.BROKEN(2670,TRUE);
EXEC DBMS_JOB.BROKEN(2670,TRUE);
EXEC DBMS_JOB.BROKEN(519,TRUE);
EXEC DBMS_JOB.BROKEN(520,TRUE);
EXEC DBMS_JOB.BROKEN(3208,TRUE);
EXEC DBMS_JOB.BROKEN(3196,TRUE);
EXEC DBMS_JOB.BROKEN(51309,TRUE);
EXEC DBMS_JOB.BROKEN(51644,TRUE);
exec DBMS_JOB.run(3);
BEGIN
DBMS_JOB.change(3,
'viking.viking1',
SYSDATE+20/1440, 'SYSDATE+180/1440');
commit;
END;
VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'viking.viking1;',
SYSDATE+20/1440,'SYSDATE + 120/1440');
commit;
END;
/
print jobno
======= DIRECTORIES / DATAPMP ================
CREATE OR REPLACE DIRECTORY test_dir AS '/u01/app/oracle/oradata/';
GRANT READ, WRITE ON DIRECTORY test_dir TO scott;
expdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIR dumpfile=EMP_DEPT.dmp logfile=expdpEMP_DEPT.log SCHEMAS=SCOTT,HR,ALI
impdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIR dumpfile=EMP_DEPT.dmp logfile=impdpEMP_DEPT.log
CREATE OR REPLACE DIRECTORY datapmp_exp AS 'd:\datapmp_exp';
GRANT READ, WRITE ON DIRECTORY datapmp_exp to system;
set oracle_sid=hdfcprod2
expdp system/oracle directory=datapmp_exp dumpfile=expdp_FULL_19082010_%u.dmp logfile=expdp_FULL_24092010.log full=y filesize=25G
set oracle_sid=hdfcamh
impdp system/oracle directory=DATAPMP_EXP dumpfile=expdp_FULL_19082010_%u.dmp logfile=IMP_AMS_TAB_01092010.log
--- DataPMP Script ---
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (set fDate=DATAPMP_exphdfcprod_%%j%%k%%l)
echo -+++++++++++++++++++++++- EXPORT log -+++++++++++++++++++++++->> D:\datapmp_exp\logs\Datapmp_HDFCPRODEXP.Log
Del D:\datapmp_exp\*.* /q >> D:\datapmp_exp\logs\Datapmp_HDFCPRODEXP.Log
set oracle_sid=hdfcprod
expdp system/oracle directory=datapmp_exp dumpfile=%fdate%.dmp logfile=%fdate%.log
echo -+++++++++++++++++++++++- EXPORT log -+++++++++++++++++++++++- >> D:\datapmp_exp\logs\Datapmp_HDFCPRODEXP.Log
exit
---- Datapmp Example -----
move E:\datapmp_exp\EXPDP_PRL_Sys_1.dmp E:\datapmp_exp\EXPDP_PRL_Sys_1_Prev.dmp
move E:\datapmp_exp\EXPDP_PRL_Sys_1.log E:\datapmp_exp\EXPDP_PRL_Sys_1_Prev.log
set oracle_sid=prlprod
expdp system/oracle directory=datapmp_exp dumpfile=expdp_PRL_Sys_1.dmp logfile=expdp_PRL_Sys_1.log tables=prl_prod.PRL_CASE_AUDIT_TRAIL EXCLUDE=STATISTICS,CONSTRAINT,TRIGGER query=\"WHERE PCAT_CR_DT like sysdate - 1\"
xcopy E:\Datapmp_exp\EXPDP_PRL_Sys_1.dmp z:\
xcopy E:\Datapmp_exp\EXPDP_PRL_Sys_1.log z:\
move D:\datapmp_exp\impdp_PRL_Sys_1.log D:\datapmp_exp\impdp_PRL_Sys_1_Prev.log
set oracle_sid=hdfcprod2
impdp system/oracle directory=datapmp_exp dumpfile=expdp_PRL_Sys_1.dmp logfile=impdp_PRL_Sys_1.log tables=PRL_CASE_AUDIT_TRAIL remap_schema=prl_prod:SAM_NEW remap_tablespace=TBS_PRL_PROD:AMS_TRANSACTION_DATA remap_tablespace=TBS_PRL_PROD_INDX:INDX TABLE_EXISTS_ACTION=append
del D:\datapmp_exp\EXPDP_PRL_SYS_1.*
SELECT a.sid, c.pid, c.spid, a.username, b.event, b.wait_time, b.seconds_in_wait, b.p1, b.p2, b.p3
FROM v$session a, v$session_wait b, v$process c
WHERE a.sid = b.sid
AND a.paddr = c.addr
AND b.event LIKE 'enq: RO%' ;
018023289
Paras Query:
Large:
set lines 200
set pages 9999
col logon for a20
col client_info for a30
col status for a10
col program for a30
col event for a30
col username for a15
col running_since for a20
select
a.inst_id,a.sid,a.program,a.event,a.username,a.status,a.sql_hash_value,
to_char(logon_time,'dd-mm-yy hh:mi:ss') "LOGON",
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "RUNNING_SINCE"
from
gv$session a
where
a.type='USER'
AND floor(last_call_et/3600)*60+floor(mod(last_call_et,3600)/60) > 5
AND a.STATUS = 'ACTIVE'
AND a.SID > 10
order by a.last_call_et;
set lines 200
set pages 9999
col logon for a20
col client_info for a30
col status for a10
col program for a30
col event for a30
col username for a15
col running_since for a20
select
a.inst_id,a.sid,a.program,a.event,a.username,a.status,a.sql_hash_value,
to_char(logon_time,'dd-mm-yy hh:mi:ss') "LOGON",
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) "RUNNING_SINCE",
last_call_et
from
gv$session a
where
a.type='USER'
AND floor(last_call_et/3600)*60+floor(mod(last_call_et,3600)/60) > 2
AND a.STATUS = 'ACTIVE'
AND a.SID > 10
order by a.last_call_et;
select sql_text from v$sqltext where HASH_VALUE='&HASH_VALUE' order by piece;
3786238237
1439292066
224658237
select sid,serial#,program,event,last_call_et,floor(last_call_et/3600)*60+floor(mod(last_call_et,3600)/60) from v$session where schemaname not like 'SYS';
select sql_text from v$sqltext where HASH_VALUE='&HASH_VALUE' order by piece;
select decode(lob.kglobtyp, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE',
7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
11, 'PACKAGE BODY', 12, 'TRIGGER',
13, 'TYPE', 14, 'TYPE BODY',
19, 'TABLE PARTITION', 20, 'INDEX PARTITION', 21, 'LOB',
22, 'LIBRARY', 23, 'DIRECTORY', 24, 'QUEUE',
28, 'JAVA SOURCE', 29, 'JAVA CLASS', 30, 'JAVA RESOURCE',
32, 'INDEXTYPE', 33, 'OPERATOR',
34, 'TABLE SUBPARTITION', 35, 'INDEX SUBPARTITION',
40, 'LOB PARTITION', 41, 'LOB SUBPARTITION',
42, 'MATERIALIZED VIEW',
43, 'DIMENSION',
44, 'CONTEXT', 46, 'RULE SET', 47, 'RESOURCE PLAN',
48, 'CONSUMER GROUP',
51, 'SUBSCRIPTION', 52, 'LOCATION',
55, 'XML SCHEMA', 56, 'JAVA DATA',
57, 'SECURITY PROFILE', 59, 'RULE',
62, 'EVALUATION CONTEXT',
'UNDEFINED') object_type,
lob.KGLNAOBJ object_name,
pn.KGLPNMOD lock_mode_held,
pn.KGLPNREQ lock_mode_requested,
ses.sid,
ses.serial#,
ses.username
FROM
x$kglpn pn,
v$session ses,
x$kglob lob,
v$session_wait vsw
WHERE
pn.KGLPNUSE = ses.saddr and
pn.KGLPNHDL = lob.KGLHDADR
and lob.kglhdadr = vsw.p1raw
and vsw.event like '%free%'
order by lock_mode_held desc;
select sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi'),sql_hash_value from gv$session where sid=266;
set lines 200
set pages 200
col event for a40
col program for a30
col inst_id for 99
col serial# for 999999
select inst_id,sid,serial#,event,program,action,sql_hash_value,to_char(logon_time,'dd-mm-yyyy hh24:mi'),client_info from gv$session where (event like '%free%' or event like '%local%' or event like '%local%') order by sql_hash_value,logon_time;
select SQL_TEXT from v$sqltext where HASH_VALUE='3114014027' order by PIECE;
set lines 200
set pages 200
col event for a40
col program for a30
col inst_id for 99
col serial# for 999999
col Logon_Time for a20
select inst_id,sid,serial#,event,program,action,sql_hash_value,to_char(logon_time,'dd-mm-yyyy hh24:mi') Logon_time,client_info from gv$session where sid in (select distinct session_id from gv$locked_object) order by logon_time;
Hdfc Bank Customer Support - 61606161
explain plan for
SELECT f_docnumber,f_docclassnumber,f_entrydate,f_archivedate,f_deletedate,f_retentbase,f_retentdisp,f_retentoffset,f_pages,f_doctype,f_accessrights,f_docformat,f_doclocation,f_ce_os_id,f_accessrights_rd,f_accessrights_wr,f_accessrights_ax,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42,a43,a44,a45,a46,a47,a48,a49,a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,a60,a61,a62,a63,a64,a65,a66,a67,a68,a69,a70,a71 FROM f_sw.doctaba WHERE f_docnumber = 29683505;
@?/rdbms/admin/utlxpls.sql
======= SCHEDULER JOBS =============
SELECT name FROM dba_dependencies
WHERE referenced_name = 'DBMS_SCHEDULER'
UNION
SELECT referenced_name FROM dba_dependencies
WHERE name = 'DBMS_SCHEDULER';
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),
to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss'),failure_count from dba_scheduler_jobs where upper(JOB_action) like '%CREATE_REJTXNRPT%';
EXEC DBMS_STATS.gather_table_stats('PRL_PROD', 'RESOURCE_MASTER_MIRROR');
EXEC DBMS_STATS.gather_table_stats('FLEXPROD_HOST', 'CH_ACCT_CUST_XREF_AUDIT', cascade => true);
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,enabled,REPEAT_INTERVAL,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss'),failure_count from dba_scheduler_jobs where JOB_NAME like '%AGENT%';
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss'),failure_count from dba_scheduler_jobs where JOB_NAME like '%Mat_View%';
select owner,job_name,to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),JOB_ACTION from dba_scheduler_jobs where job_name like '%SP_WONDERS_DATA_CHECK%';
UPDATE_MEDICAL_FOR_CLIAMS SCHEDULED EXECUTABLE BEGIN pclmmed.SP_INSTTMEDCLM; END;
SET LONG 100000
SELECT DBMS_METADATA.get_ddl('PROCOBJ','MY_TEST_JOB', 'TEST') AS job_def FROM dual;
SET LONG 100000
SELECT DBMS_METADATA.get_ddl('PROCOBJ',JOB_NAME, owner) AS job_def FROM
dba_scheduler_jobs where job_name = 'AMS_PKG_WALLET_LEADS_JOB' and owner = 'AMS';
begin
dbms_scheduler.drop_job
(
job_name => 'prl_prod.Mat_View_Refersh'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'prl_prod.Mat_View_Refersh',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN DBMS_SNAPSHOT.REFRESH(LIST => ''PRL_PROD.PRL_MVIEW_DMC_INW_TAT_DET_REP''
,PUSH_DEFERRED_RPC => TRUE
,REFRESH_AFTER_ERRORS => FALSE
,PURGE_OPTION => 1
,PARALLELISM => 0
,ATOMIC_REFRESH => TRUE
,NESTED => FALSE); END;',
start_date => TO_DATE('10/23/2012 06:00 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Mat View Referesh'
);
end;
/
wondersii.PRC_NEW_COMP_SMS_1;
begin
dbms_scheduler.create_job
(
job_name => 'WONDERSII.PRC_NEW_COMP_SMS',
job_type => 'PLSQL_BLOCK',
job_action => 'begin wondersii.PRC_NEW_COMP_SMS_1; wondersii.PRC_NEW_COMP_SMS_2; end;',
start_date => TO_DATE('10/04/2012 07:00 AM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Send SMS PRC_NEW_COMP_SMS_1 N 2'
);
end;
/
GP.GP_UNIT_STMT_PKG.SP_EXT_UNIT_STMTS;
rrrr
begin
dbms_scheduler.create_job
(
job_name => 'GP.GP_UNIT_STMT',
job_type => 'PLSQL_BLOCK',
job_action => 'begin GP.GP_UNIT_STMT_PKG.SP_EXT_UNIT_STMTS; end;',
start_date => TO_DATE('11/21/2012 07:00 AM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
enabled => true,
comments => 'GP.GP_UNIT_STMT_PKG.SP_EXT_UNIT_STMTS'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'prl_prod.AMS_AGENT_DATA_UPLOAD',
job_type => 'PLSQL_BLOCK',
job_action => 'begin prl_prod.prl_pkg_external_uploads.sp_update_agent_master; commit; end;',
start_date => TO_DATE('05/26/2012 09:00 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=MINUTELY; INTERVAL=360',
enabled => true,
comments => 'External Upload rr2'
);
end;
begin
dbms_scheduler.create_job
(
job_name => 'wondersii.UPDATE_MEDICAL_FOR_CLIAMS',
job_type => 'PLSQL_BLOCK',
job_action => 'begin wondersii.pclmmed.SP_INSTTMEDCLM; end;',
start_date => TO_DATE('10/30/2010 09:30 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Update Medical for Claim'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'HSLRNRPROD.EOD_AgreementClosure_SJOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin HSLRNRPROD.EOD_AgreementClosure(''001'',''100'',get_businessdate(''001''),''SYSTEM'',NULL); end;',
start_date => TO_DATE('09/13/2012 02:00 AM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'EOD Agreement JOB'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'ams.AMS_SP_CHANGE_REQUEST_SJOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin ams.AMS_SP_CHANGE_REQUEST; end;',
start_date => TO_DATE('09/13/2012 10:30 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Executing AMS_SP_CHANGE_REQUEST'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'CP.PK_CONTROLLER_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin ETL.PK_JOB_CONTROLLER.sp_run_group(''CP Daily Extraction''); ETL.PK_JOB_CONTROLLER.sp_run_group(''Purge Unit Statements''); end;',
start_date => TO_DATE('08/07/2012 03:00 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Execute ETL Controller Job'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'GP.PK_CONTROLLER_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'begin ETL.PK_JOB_CONTROLLER.sp_run_group(''GP-Daily Extraction''); END;',
start_date => TO_DATE('08/31/2012 03:10 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Execute ETL Controller Job'
);
end;
/
begin dbms_scheduler.drop_job(job_name => 'GP.PK_CONTROLLER_JOB'); end;
/
BEGIN
-- Job defined by existing schedule and inline program.
DBMS_SCHEDULER.create_job (
job_name => 'PRL_PROD.JOB_UPDATE_RESOURCE_MASTER',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN PRL_PROD.rr_UPDATE_RESOURCE_MASTER; COMMIT; END;',
start_date => TO_DATE('10/20/2012 08:00 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=MINUTELY; INTERVAL=20',
enabled => TRUE ,
comments => 'Job defined by existing schedule and inline program.');
END;
/
====================================
===EXECUTING EXECUTABLE from Scheduler JOBS
Need to start JOB Scheduler Service from Services.msc
select status, error#, substr(additional_info,1,500)
from user_scheduler_job_run_details
where job_name = 'EXP_MDEALING';
begin
dbms_scheduler.create_job
(
job_name => 'SYSTEM.EXP_MDEALUAT',
job_type => 'EXECUTABLE',
job_action => 'D:\BKP_Test\MFundMcy.bat',
repeat_interval => 'FREQ=DAILY',
enabled => FALSE,
comments => 'Exp Backup to D:\BKP_Test\MFundMcy.bat'
);
end;
/
exp sys/sys@neft_khr filename=E:\shaik\ABC.dmp logfile=E:\shaik\ABC.log rows=N
select username,owner,obj_name,action_name,timestamp from dba_audit_trail where obj_name like upper('%ap_sp_get%') order by 5;
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),
to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss'),failure_count
from dba_scheduler_jobs where JOB_NAME like '%AMS_PKG_POLICY%';
Begin
Dbms_scheduler.set_attribute
(
name => 'AMS.LTS_LEADS_SUMMARY_CALC_MERGE'
,attribute => 'repeat_interval'
,value => 'FREQ=DAILY;BYHOUR=9;BYMINUTE=0;BYSECOND=0'
);
End;
/
Begin
Dbms_scheduler.set_attribute
(
name => 'AMS.AMS_PKG_UNIT_STATEMENT'
,attribute => 'repeat_interval'
,value => 'FREQ=WEEKLY; BYDAY=MON; BYHOUR=18; BYMINUTE=14;'
);
End;
/
Begin
Dbms_scheduler.set_attribute
(
name => 'wondersii.PRC_NEW_COMP_SMS'
,attribute => 'repeat_interval'
,value => 'FREQ=DAILY;BYHOUR=21;BYMINUTE=20;BYSECOND=0'
);
End;
/
FREQ=WEEKLY; BYDAY=TUE; BYHOUR=11; BYMINUTE=24;
BEGIN
-- Job defined by existing schedule and inline program.
DBMS_SCHEDULER.create_job (
job_name => 'AMS.TEST_TRUNCATE',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN ams.RR_PKG; END;',
start_date => TO_DATE('12/22/2011 09:45 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => TRUE ,
comments => 'AMS.TEST_TRUNCATE');
END;
/
select
EXEC DBMS_SCHEDULER.DROP_JOB('AMS.TEST_TRUNCATE3');
EXEC DBMS_SCHEDULER.DROP_JOB('AMS.TEST_TRUNCATE');
exec DBMS_SCHEDULER.RUN_JOB('AMS.TEST_TRUNCATE');
exec DBMS_SCHEDULER.RUN_JOB('WONDERSII.PRC_NEW_COMP_SMS');
EXEC DBMS_SCHEDULER.DROP_JOB('CP.PK_CONTROLLER_JOB');
insert into ams.AMS_USAGE_DETAIL_PZ_BKPPP (select * from ams.AMS_POLICY_DETAILS);
commit;
exec DBMS_SCHEDULER.RUN_JOB('AMS.TEST_TRUNCATE');
create or replace procedure ams.rr_PKG is
begin
EXECUTE IMMEDIATE 'TRUNCATE TABLE AMS_USAGE_DETAIL_PZ_BKPPP';
End rr_PKG;
/
begin
EXECUTE IMMEDIATE 'TRUNCATE TABLE AMS_USAGE_DETAIL_PZ_BKPPP';
end;
/
create table ams.AMS_USAGE_DETAIL_PZ_BKPPP as (select * from ams.AMS_POLICY_DETAILS);
drop table ams.AMS_USAGE_DETAIL_PZ_BKPPP;
select count(*) from ams.AMS_USAGE_DETAIL_PZ_BKPPP;
insert into ams.AMS_USAGE_DETAIL_PZ_BKPPP (select * from ams.AMS_POLICY_DETAILS);
commit;
exec DBMS_SCHEDULER.RUN_JOB('AMS.TEST_TRUNCATE');
SQL> insert into ams.AMS_USAGE_DETAIL_PZ_BKPPP (select * from ams.AMS_POLICY_DETAILS);
4566350 rows created.
Elapsed: 00:01:33.76
SQL> commit;
Commit complete.
Elapsed: 00:00:00.14
SQL> exec DBMS_SCHEDULER.RUN_JOB('AMS.TEST_TRUNCATE');
PL/SQL procedure successfully completed.
Elapsed: 00:00:55.96
SQL>
====================================
begin
dbms_scheduler.create_job
(
job_name => 'ARC_MOVE_3',
job_type => 'EXECUTABLE',
job_action => '/home/arup/dbtools/move_arcs.sh',
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
enabled => true,
comments => 'Move Archived Logs to a Different Directory'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'ARC_MOVE_3',
job_type => 'EXECUTABLE',
job_action => '/home/arup/dbtools/move_arcs.sh',
repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
enabled => true,
comments => 'Move Archived Logs to a Different Directory'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'WONDERSII.UPDATE_MEDICAL_FOR_CLIAMS',
job_type => 'EXECUTABLE',
job_action => 'BEGIN WONDERSII.PCLMMED.SP_INSTTMEDCLM; END;',
start_date => TO_DATE('10/18/2010 09:30 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Update Medical for Claim'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'IDEAS.JOB_IDEAS_UPDATE_BUSINESSDATE',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN IDEAS.IDEAS_UPDATE_BUSINESSDATE; COMMIT; END;',
start_date => TO_DATE('11/13/2010 01:00 AM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'IDEAS_UPDATE_BUSINESSDATE'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'wondersii.UPDATE_MEDICAL_FOR_CLIAMS',
job_type => 'PLSQL_BLOCK',
job_action => 'begin wondersii.pclmmed.SP_INSTTMEDCLM; end;',
start_date => TO_DATE('10/30/2010 09:45 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=DAILY',
enabled => true,
comments => 'Update Medical for Claim'
);
end;
/
begin
dbms_scheduler.create_job
(
job_name => 'JOB_SP_WONDERS_DATA_CHECK',
job_type => 'EXECUTABLE',
job_action => 'begin WONDERSII.SP_WONDERS_DATA_CHECK; end;',
start_date => TO_DATE('08/25/2010 4:21 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'freq=daily;byhour=6;byminute=30;bysecond=0',
enabled => true,
comments => 'Executes SP_WONDERS_DATA_CHECK Proc. daily at 6:30 AM'
);
end;
/
BEGIN
-- Job defined by existing schedule and inline program.
DBMS_SCHEDULER.create_job (
job_name => 'IDEAS.JOB_IDEAS_UPLOAD_RECEIPT',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN IDEAS.IDEAS_UPLOAD_RECEIPT; COMMIT; END;',
start_date => TO_DATE('04/14/2011 09:05 PM','mm/dd/yyyy hh12:mi AM'),
repeat_interval => 'FREQ=MINUTELY; INTERVAL=180',
enabled => TRUE ,
comments => 'Job defined for IDEAS Upload Receipt.');
END;
/
select to_char(sysdate,'dd-mm-yyyy hh24:mi:ss') from dual;
EXEC DBMS_SCHEDULER.DROP_JOB('IDEAS.JOB_IDEAS_UPLOAD_RECEIPT');
EXEC DBMS_SCHEDULER.RUN_JOB('WONDERSII.UPDATE_MEDICAL_FOR_CLIAMS');
EXEC DBMS_SCHEDULER.ENABLE('JOB_SCHEDULE_SMSAMSMAST');
EXEC DBMS_SCHEDULER.DISABLE('AMSLTS.REMOVEEXPIRED_ASPNET_SESSITEMS');
EXEC DBMS_SCHEDULER.DISABLE('AMS.AMS_PKG_UNIT_STATEMENT');
EXEC DBMS_SCHEDULER.ENABLE('AMS.AMS_PKG_UNIT_STATEMENT');
EXEC DBMS_SCHEDULER.STOP_JOB('SYS.JOB_IDEAS_UPLOAD_RECEIPT');
EXEC DBMS_SCHEDULER.STOP_JOB('IDEAS.JOB_IDEAS_UPLOAD_RECEIPT');
EXEC DBMS_SCHEDULER.RUN_JOB('IDEAS.JOB_IDEAS_UPDATE_BUSINESSDATE');
EXEC DBMS_SCHEDULER.DISABLE('JOB_IDEAS_UPLOAD_RECEIPT');
EXEC DBMS_SCHEDULER.DISABLE('UNAUTHCHECKJOB');
EXEC DBMS_SCHEDULER.ENABLE('IDEAS.JOB_IDEAS_UPDATE_BUSINESSDATE');
EXEC DBMS_SCHEDULER.DROP_JOB('CP.SMS_OFFLINE_USER_TXN');
EXEC DBMS_SCHEDULER.RUN_JOB('MFUNDMCY.EXP_MDEALING');
Farzad - 9867156217
SELECT name FROM dba_dependencies
WHERE referenced_name = 'DBMS_SCHEDULER'
UNION
SELECT referenced_name FROM dba_dependencies
WHERE name = 'DBMS_SCHEDULER';
set lines 200
set pages 200
col owner for a12
col JOB_ACTION for a50
select owner,job_name,state,job_type,job_action,run_count,to_char(LAST_RUN_DURATION,'dd-mm-yyyy hh24:mi:ss'),to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),to_char(LAST_START_DATE,'dd-mm-yyyy hh24:mi:ss') from dba_scheduler_jobs where JOB_NAME like '%RECEIPT%';
select owner,job_name,to_char(NEXT_RUN_DATE,'dd-mm-yyyy hh24:mi:ss'),JOB_ACTION from dba_scheduler_jobs where job_name like '%SP_WONDERS_DATA_CHECK%';
To show details on job run:
select log_date
, job_name
, status
, req_start_date
, actual_start_date
, run_duration
from dba_scheduler_job_run_details
To show running jobs:
select job_name
, session_id
, running_instance
, elapsed_time
, cpu_used
from dba_scheduler_running_jobs;
To show job history:
select log_date
, job_name
, status
from dba_scheduler_job_log;
show all schedules:
select schedule_name, schedule_type, start_date, repeat_interval
from dba_scheduler_schedules;
show all jobs and their attributes:
select *
from dba_scheduler_jobs
show all program-objects and their attributes
select *
from dba_scheduler_programs;
show all program-arguments:
select *
from dba_scheduler_program_args;
FREQ=DAILY
freq=daily;byhour=0;byminute=0;bysecond=0
FREQ=MINUTELY;INTERVAL=60
FREQ = HOURLY; INTERVAL = 1
FREQ=DAILY
FREQ=DAILY
freq=monthly;interval=1;bymonthday=1;byhour=01;byminute=01;bysecond=01
FREQ=DAILY;BYHOUR=11;BYMINUTE=24;
To run a job every Tuesday at 11:24, you could use any of the following (they are all equivalent):
FREQ=DAILY; BYDAY=TUE; BYHOUR=11; BYMINUTE=24;
FREQ=WEEKLY; BYDAY=TUE; BYHOUR=11; BYMINUTE=24;
FREQ=YEARLY; BYDAY=TUE; BYHOUR=11; BYMINUTE=24;
So far, this isn't much easier than the old-style Interval syntax. However, Calendaring syntax makes it much easier to specify more complex expressions. For example, to run a job every 3rd month on the 11th of the month, use the INTERVAL clause:
FREQ=MONTHLY; INTERVAL=3; BYMONTHDAY=11;
Varying intervals are much easier to express, too. To run a job Tuesday and Thursday at 11, 14 and 22 o'clock:
FREQ=WEEKLY; BYDAY=TUE,THUR; BYHOUR=11,14,22;
==============
creation2:
set long 999999
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS
where username like 'SWPROWHUB1';
set long 999999
select DBMS_METADATA.GET_DDL('TABLESPACE',tablespace_name) db_Tablespace
from dba_tablespaces
where tablespace_name like 'MFUND';
set long 999999
select DBMS_METADATA.GET_DDL('PROFILE',profile) db_SCHEMA
from dba_Profiles
where PROFILE like '&MFUND';
set long 999999
select DBMS_METADATA.GET_DDL('PROFILE',profile) db_SCHEMA
from dba_Profiles
where PROFILE like 'WONDERS';
@getprofile:
set long 999999
select DBMS_METADATA.GET_DDL('PROFILE',profile) db_SCHEMA
from dba_Profiles
where PROFILE like '&profile';
set long 999999
select DBMS_METADATA.GET_DDL('TYPE',object_name,'PRL_PROD') db_SCHEMA
from dba_objects
where object_type = 'TYPE' and owner like 'PRL%' and object_name = 'MYSCALARTYPE';
set long 999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,'SWPROWHUB1') db_SCHEMA
from dba_tables
where table_name = 'AUDIT_TRAIL';
set long 999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,'SAM_NEW') db_SCHEMA
from dba_tables
where table_name = 'ROOTWISE_AGENT_DETAILS';
set long 999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,'AMS') db_SCHEMA
from dba_external_tables
where table_name = 'AMS_ELA_COMMISSION_DETAILS';
set long 999999
select DBMS_METADATA.GET_DDL('TABLE',table_name,owner) db_SCHEMA
from dba_external_tables
where table_name = upper('ams_lts_ext_lead_non_cc_upl');
set long 999999
select DBMS_METADATA.GET_DDL('SYNONYM',synonym_name,'PUBLIC') db_SCHEMA
from dba_synonyms
where synonym_name like 'AMS_PKG_ALT_LEAD_DETAILS';
set long 999999
select DBMS_METADATA.GET_DDL('SYNONYM',synonym_name,'PUBLIC') db_SCHEMA
from dba_synonyms
where synonym_name like 'TOAD_SPACE';
drop PUBLIC SYNONYM TOAD_SPACE;
CREATE OR REPLACE PUBLIC SYNONYM TOAD_SPACE FOR TOAD.TOAD_SPACE;
set long 999999
select DBMS_METADATA.GET_DDL('INDEX',index_name,'SWPROWHUB1') db_SCHEMA
from dba_indexes
where index_name like 'IDX_AUDIT_TRAIL_FK';
CREATE USER "WONDERSTEAM" IDENTIFIED BY VALUES '6A2F67D21BA72AD5'
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
PROFILE "APP_USER_PROFILE" ;
CREATE USER "WONDERSII_BKP" IDENTIFIED BY VALUES 'D6BA72C81E0C6EBE'
DEFAULT TABLESPACE "TS_WONDERSII_DATA"
TEMPORARY TABLESPACE "TEMP"
PROFILE "WONDERS"
ACCOUNT LOCK ;
CREATE USER "WONDERSII" IDENTIFIED BY VALUES '8CAB501D9F604C89'
DEFAULT TABLESPACE "TS_WONDERSII_DATA"
TEMPORARY TABLESPACE "TEMP"
PROFILE "WONDERS" ;
CREATE USER "SAM_NEW" IDENTIFIED BY VALUES 'S:9CD142D3F27506DE4CB7F42413909B58C3FA7D039E28C364376447677440;9E332FF57FAC41C4'
DEFAULT TABLESPACE "AMS_TRANSACTION_DATA"
TEMPORARY TABLESPACE "TEMPGRP5";
exec ams.Analyze_SB_Tables_rr; == VIVEK Execute this.
======= SCHEMA @creation SQL Script ==============
BIPLUS, HAAS, HPS, HSS
undefine USR
define USR=&USRS
set head off
set echo off
set feedback off
set long 999999
set lines 160
set pages 200
spool ./SSRINI_Creation_Script2.sql
select name,open_mode from gv$database;
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA from dba_USERS where username like '&&USR';
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like '&&USR';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = '&&USR';
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee = '&&USR';
spool off;
set head on
set echo on
set feedback on
================================================================================================================
============ Schema Creation SHELL Script =====================================
Both this Files to be created
$ cat SC.sh
echo "set head off" > ./Users.sql
echo "set feedback off" >> ./Users.sql
echo "set lines 30" >> ./Users.sql
echo "set pages 999" >> ./Users.sql
echo "spool ./Users_rr.out" >> ./Users.sql
echo "select username from dba_users order by 1;" >> ./Users.sql
echo "spool off " >> ./Users.sql
echo "exit" >> ./Users.sql
sqlplus "/ as sysdba" @./Users.sql
echo "`cat ./Users_rr.out"
v1=`cat Users_rr.out`
for filename in $v1
do
echo "Schema Creation in Process for : $filename"
echo "define USR=$filename" > ./Schema_Creation.sql
echo "`cat ./Schema_Creation.txt`" >> ./Schema_Creation.sql
sqlplus "/ as sysdba" @/u025/OWIP_rr/Schema_Creation.sql
done
$
$
$
$ cat Schema_Creation.txt
set lines 160
set pages 2002
set time on
column machine format a20
column event format a35
column program format a30
column schemaname for a10
column action format a50
set head off
set echo off
set feedback off
set long 999999
set lines 160
set pages 200
column FC_cdt new_value file_time noprint
column FC_DB new_value file_DB noprint
column FC_Usr new_value file_Usr noprint
select to_char(sysdate,'dd_mm_yyyy_hh24_mi_ss') FC_cdt from dual;
select instance_name FC_DB from gv$instance;
select username FC_Usr from dba_users where username = '&&USR';
spool ./&file_DB._&file_Usr._Session_Check_&file_time..sql
select name,open_mode from gv$database;
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA from dba_USERS where username like '&&USR';
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like '&&USR';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = '&&USR';
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee = '&&USR';
spool off;
set head on
set echo on
set feedback on
exit
================================================================================================================
spool c:\User_Priv.sql
select 'grant '|| PRIVILEGE || ' to SWPRO;' from DBA_SYS_PRIVS where grantee like 'SWPRO';
select 'grant '|| PRIVILEGE || ' to SWUSER;' from DBA_SYS_PRIVS where grantee like 'SYS';
spool off;
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to amslts1;' from DBA_TAB_PRIVS where grantee = 'AMSLTS';
select 'grant '|| GRANTED_ROLE || ' to amslts1;' from DBA_role_PRIVS where grantee = 'AMSLTS';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = 'PLANPROD';
select * from DBA_tab_PRIVS where grantee = 'HP_DBSPI';
select * from DBA_role_PRIVS where granted_role = 'HP_DBSPI';
select * from DBA_sys_PRIVS where grantee = 'HP_DBSPI';
SELECT 'grant CREATE VIEW,CREATE TABLE,ALTER SESSION,CREATE CLUSTER,CREATE SYNONYM,CREATE SEQUENCE,CREATE DATABASE LINK to '||grantee||';'
FROM dba_role_privs WHERE granted_role = 'CONNECT' AND grantee
NOT IN ('SYS', 'OUTLN', 'SYSTEM', 'CTXSYS', 'DBSNMP','LOGSTDBY_ADMINISTRATOR',
'ORDSYS','ORDPLUGINS', 'OEM_MONITOR', 'WKSYS', 'WKPROXY','WK_TEST',
'WKUSER', 'MDSYS', 'LBACSYS', 'DMSYS','WMSYS', 'OLAPDBA', 'OLAPSVR',
'OLAP_USER','OLAPSYS', 'EXFSYS', 'SYSMAN', 'MDDATA','SI_INFORMTN_SCHEMA',
'XDB', 'ODM');
select distinct grantee from dba_sys_privs
where privilege = 'CREATE VIEW'
and privilege = 'CREATE TABLE'
and privilege = 'ALTER SESSION'
and privilege = 'CREATE CLUSTER'
and privilege = 'CREATE SYNONYM'
and privilege = 'CREATE SEQUENCE'
and privilege = 'CREATE DATABASE LINK';
and grantee ;
select 'grant '|| GRANTED_ROLE || ' to SWUSER;' from DBA_role_PRIVS where grantee = 'SYS';
select owner,sum(bytes/1024/1024/1024) from dba_segments where owner in (select username from dba_users where default_tablespace like 'USERS%') group by owner order by 2;
define USR=&USRS
set head off
set echo off
set feedback off
set long 999999
spool c:\SAM_NEW_USER_Creation_Script.sql
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS
where username like '&&USR';
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like '&&USR';
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee = '&&USR';
spool off;
set head on
set echo on
set feedback on
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like 'LEAP';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where table_name = 'CP_DIR_CLIENT';
spool d:\Priv_Wondersii.txt
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee like 'WONDERSII';
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = 'WONDERSII';
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee = 'WONDERSII';
spool off;
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where table_name in (select directory_name from dba_directories);
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where table_name = 'AMS_ELA_COMMISSION_DETAILS';
set head off
set echo off
set feedback off
set lines 120
set pages 999
set long 999999
spool c:\USER_Creation_Script.sql
select 'Create tablespace ' || tablespace_name || ' datafile size 2G autoextend on;' from dba_tablespace;
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS where default_tablespace not like 'SYS%';
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
spool off;
set head on
set echo on
set feedback on
spool C:\Privs.txt
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
select 'grant '|| PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS where grantee in (select username from dba_users where default_tablespace not like 'SYS%');
spool off
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = 'SWPROWHUB1';
=========================================
set long 999999
select DBMS_METADATA.GET_DDL('INDEX',index_name) db_SCHEMA
from dba_indexes
where table_name = 'AMS_LA_NGTV_CMSN_DETAILS';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS where grantee = 'AMS';
======= PRIVILEGES ==============
set long 999999
select DBMS_METADATA.GET_DDL('USER',username) db_SCHEMA
from dba_USERS
where username like 'SAM_NEW';
SET LONG 100000
SELECT DBMS_METADATA.get_ddl('PROCOBJ','MY_TEST_JOB', 'TEST') AS job_def FROM dual;
spool D:\Wipro-DBA\Privileges\DBA_SYS_PRIVS_All_Users.txt
select 'grant '|| PRIVILEGE || ' to SAM_NEW;' from DBA_SYS_PRIVS where grantee like 'AMS';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to SAM_NEW;' from DBA_TAB_PRIVS where grantee = 'ETL';
select 'grant '|| GRANTED_ROLE || ' to SAM_NEW;' from DBA_role_PRIVS where grantee = 'ETL';
spool D:\Wipro-DBA\Privileges\DBA_SYS_PRIVS_All_Users.txt
select 'grant '|| PRIVILEGE || ' to ' || grantee || ';' from DBA_SYS_PRIVS;
spool off;
spool D:\Wipro-DBA\Privileges\DBA_TAB_PRIVS_All_Users.txt
select 'grant ' || PRIVILEGE || ' on ' || owner || '.' || table_name || ' to ' || grantee || ';' from DBA_TAB_PRIVS;
spool off;
spool D:\Wipro-DBA\Privileges\DBA_ROLE_PRIVS_All_Users.txt
select 'grant '|| GRANTED_ROLE || ' to ' || grantee || ';' from DBA_role_PRIVS;
spool off;
==== PRIV Dynamic Query
select 'grant SELECT,INSERT,UPDATE,DELETE ON ' || owner || '.' || table_name || ' to SIUDCDGR with grant option;' from dba_tables where num_rows is not null and TABLESPACE_NAME is not null and owner in (select username from dba_users where default_tablespace not in ('SYSTEM','SYS','SYSAUX','RMAN'))
select 'grant SELECT,INSERT,UPDATE,DELETE ON ' || owner || '.' || table_name || ' to SIUDCDGR with grant option;' from dba_tables where num_rows is not null and TABLESPACE_NAME is not null and owner in (select username from dba_users where default_tablespace not in ('SYSTEM','SYS','SYSAUX','RMAN'))
set pages 200
set lines 200
col owner for a10
col db_link for a45
col host for a20
select * from dba_db_links;
select grantee,table_owner,table_name,PRIVILEGE from DBA_TAB_PRIVS where grantee = 'AMSLTS';
select grantee,table_owner,table_name,PRIVILEGE from DBA_TAB_PRIVS where grantee = 'LTSSEC';
select grantee,PRIVILEGE,ADMIN_OPTION from DBA_SYS_PRIVS where grantee = 'SAM_NEW';
select grantee,GRANTED_ROLE,ADMIN_OPTION from DBA_role_PRIVS where grantee = 'SAM_NEW';
select grantee,PRIVILEGE,table_name from DBA_TAB_PRIVS where table_name like 'AMS_DIR_CFY%';
select distinct PRIVILEGE from DBA_TAB_PRIVS;
select distinct PRIVILEGE from DBA_SYS_PRIVS;
select distinct GRANTED_ROLE from DBA_role_PRIVS;
Granyted in 11g System
grant GLOBAL QUERY REWRITE to system;
grant SELECT_CATALOG_ROLE to system;
grant CREATE PUBLIC SYNONYM to sam_sit;
select 'grant '|| PRIVILEGE || ' to sam_sit;' from DBA_SYS_PRIVS where grantee = 'SAM';
select 'grant '|| PRIVILEGE || ' on ' || table_name || ' to ETL;' from DBA_TAB_PRIVS where grantee = 'ETL';
select 'grant '|| GRANTED_ROLE || ' to sam_sit;' from DBA_role_PRIVS where grantee = 'SAM';
DBMS_SWRF_INTERNAL
---NOTE : -----
To provide a user, select privilege on all the schemas -- Grant -- SELECT ANY TABLE -- This will provide select priv. on all the user except SYS Users
e.g :-
grant select any table to abc;
-- This will provide select on all the table in database except of tables owned by SYS.
create user sam_sit identified by sam_sit default tablespace ams_transaction_data quota unlimited on ams_transaction_data;
@fullexp
grant DATAPUMP_EXP_FULL_DATABASE to user;
grant DATAPUMP_IMP_FULL_DATABASE to user;
grant IMP_FULL_DATABASE to sam_sit;
grant CONNECT to sam_sit;
grant RESOURCE to sam_sit;
grant CREATE PUBLIC SYNONYM to sam_sit;
grant CREATE ANY CONTEXT to sam_sit;
grant UNLIMITED TABLESPACE to sam_sit;
grant CREATE ANY DIRECTORY to sam_sit;
grant DROP PUBLIC SYNONYM to sam_sit;
grant ALTER SESSION to sam_sit;
grant SELECT on V_$THREAD to SAM_SIT;
grant SELECT on V_$PROCESS to SAM_SIT;
grant SELECT on V_$SESSION to SAM_SIT;
grant SELECT on V_$LATCH to SAM_SIT;
grant SELECT on V_$MYSTAT to SAM_SIT;
grant SELECT on V_$STATNAME to SAM_SIT;
grant SELECT on V_$PARAMETER to SAM_SIT;
grant SELECT on V_$INSTANCE to SAM_SIT;
grant SELECT on V_$SESSION_WAIT to SAM_SIT;
grant SELECT on V_$SYSTEM_EVENT to SAM_SIT;
grant SELECT on GV_$THREAD to SAM_SIT;
grant SELECT on GV_$PROCESS to SAM_SIT;
grant SELECT on GV_$SESSION to SAM_SIT;
grant SELECT on GV_$LATCH to SAM_SIT;
grant SELECT on GV_$MYSTAT to SAM_SIT;
grant SELECT on GV_$STATNAME to SAM_SIT;
grant SELECT on GV_$PARAMETER to SAM_SIT;
grant SELECT on GV_$INSTANCE to SAM_SIT;
grant SELECT on GV_$SESSION_WAIT to SAM_SIT;
grant SELECT on GV_$SYSTEM_EVENT to SAM_SIT;
grant SELECT on V_$CONTEXT to SAM_SIT;
grant SELECT on GV_$CONTEXT to SAM_SIT;
grant EXECUTE on DBMS_SESSION to SAM_SIT;
grant EXECUTE on DBMS_LOCK to SAM_SIT;
grant READ on SAM_MASTERS to SAM_SIT;
grant WRITE on SAM_MASTERS to SAM_SIT;
======= LOCKS ========
column owner format a10
column object_name format a30
column machine format a15
column object_type format a10
column osuser format a15
column schemaname format a12
select c.owner,c.object_name,c.object_type,b.sid,b.serial#,b.schemaname,b.status,b.osuser,b.machine
from v$locked_object a,v$session b,sys.dba_objects c
where b.sid = a.session_id
and a.object_id = c.object_id
order by 2;
and object_name = 'M_USERS'
======= CPU UTIL Prasad ==========
set pages 400
set lines 300
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.osuser,1,23) USER_NM,
substr(ss.machine,1,23) MACHINE_NM,
substr(ss.program,1,17) program,
value
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%CPU used by this session%'
and se.sid = ss.sid
and ss.username is not null
and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >=10000
order by substr(name,1,25), value desc
/
======= Memory UTIL Prasad ==========
set pages 400
set lines 1000
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.osuser,1,23) USER_NM,
substr(ss.machine,1,23) MACHINE_NM,
substr(ss.program,1,17) program, name,
value
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and upper(name) like '%MEMORY%'
and se.sid = ss.sid
and ss.username is not null
and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >=10000
order by substr(name,1,25), value desc
/
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.osuser,1,23) USER_NM,
substr(ss.machine,1,23) MACHINE_NM,
substr(ss.program,1,17) program,
value,sn.name
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and (name like '%session connect time%' or name like '%CPU used by this session%')
and se.sid = ss.sid
and ss.username is not null
and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >= 10000
order by value
;
Jyotsna Lotilikar - 9833495581
select inst_id,sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi')
from gv$session where sid in (select session_id from gv$locked_object where object_id=229790) order by logon_time;
select inst_id,sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi'),schemaname
from gv$session where program not like '%w3wp%' and program not like '%ORACLE%' order by logon_time;
select sql_hash_value,event,action from v$session where sid=599;
select SQL_TEXT from v$sqltext where HASH_VALUE='3114014027' order by PIECE;
select SQL_TEXT from v$sqltext where HASH_VALUE='2440604873' order by PIECE;
select * from gv$locked_object order by 5;
select status,object_name,object_type,owner from dba_objects where object_name like '%CP_MAIL_PKG%';
select schemaname,inst_id,sid,serial#,program,event , to_char(logon_time,'dd-mm-yyyy hh24:mi') from gv$session where program like 'sqlplus.exe';
select status,object_name,object_type,owner from dba_objects where object_name like '%MV_PCRSTSH_PLAN_STORE_LIST%';
Truncat table Issue
ams_pkg_salesbinder.ams_sp_cal_salesbinder;
----CHECK Session working on--------
select inst_id,sid,serial#,sql_hash_value,event from gv$session where username = 'ALT';
----CHECK Session Hanged OR Working fine.-----
select * from v$sess_io where sid in (select sid from v$session where username = 'ETL');
------
ramesh.lakshmana@wipro.com - 9741494008
SQL> show parameter resou
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
resource_limit boolean FALSE
resource_manager_cpu_allocation integer 16
resource_manager_plan string SCHEDULER[0x3008]:DEFAULT_MAIN
TENANCE_PLAN
SQL>
select username,sid,serial#,program,event,action,to_char(logon_time,'DD-MM-YYYY hh24:mi:ss') from v$session where sid= &sid;
select inst_id,username,sid,serial#,program,event,action,to_char(logon_time,'DD-MM-YYYY hh24:mi:ss'),sql_hash_value from gv$session where sid = 1;
select * from DBA_DML_LOCKS order by 3;
select * from DBA_DDL_LOCKS where session_id = 1 order by 2;
-- Analyze Tables
BEGIN
DBMS_STATS.gather_table_stats('RSPROD_ARCH','REQUEST',
ESTIMATE_PERCENT => 0.1,
METHOD_OPT => 'FOR COLUMNS CLOSEDDATE SIZE 254');
END;
/
BEGIN
dbms_stats.Gather_table_stats('SH', 'SALES', -
method_opt => 'FOR ALL COLUMNS SIZE 1 FOR COLUMNS SIZE 254 CUST_ID');
END;
/
PL/SQL procedure successfully completed.
SELECT column_name, num_distinct, histogram
FROM user_tab_col_statistics
WHERE table_name = 'SALES';
There are several other cases where you may need to provide a more complex setting for the METHOD_OPT parameter. Take for example a scenario where you don’t want any form of statistics on a column. There is no way to tell Oracle don’t gather statistics on a particular column, so you need to do the reverse and explicitly list the column you want to have statistics gathered on using the FOR COLUMNS syntax. Let’s assume we don’t want statistics of any kind on the PROD_ID column of the SALES TABLE. Then the DBMS_STATS.GATHER_TABLE_STATS command would be as follows;
BEGIN
dbms_stats.delete_column_stats('SH', 'SALES', 'PROD_ID');
END;
/
PL/SQL procedure completed successfully.
BEGIN
dbms_stats.Gather_table_stats('SH', 'SALES',-
method_opt => 'FOR COLUMNS SIZE 254 CUST_ID TIME_ID CHANNEL_ID PROMO_ID
QUANTITY_SOLD AMOUNT_SOLD');
END;
/
PL/SQL procedure completed successfully.
-- The average row length still got recorded accurately even though we did not gather statistics on the PROD_ID column.
SELECT num_rows, avg_row_len
FROM user_tables
WHERE table_name = 'SALES';
SELECT column_name, num_distinct, histogram
FROM user_tab_col_statistics
WHERE table_name = 'SALES';
Note the FOR COLUMNS syntax is only valid for the GATHER_TABLE_STATS procedure.
Finally, at the start of this post I mentioned that the METHOD_OPT parameter can also be used to create extended statistics. Extended statistics encompasses two additional types of column statistics; column groups and expression statistics. In the example below, a column group will be automatically created on the PROD_ID and CUST_ID column in the SALES table. It will be given a system-generated name and will have all of the base column statistics gathered on it.
BEGIN
dbms_stats.Gather_table_stats('SH', 'SALES',
method_opt => 'FOR ALL COLUMNS SIZE 254 FOR COLUMNS SIZE 254(PROD_ID, CUST_ID)');
END;
/
PL/SQL procedure successfully completed.
SELECT column_name, num_distinct, histogram
FROM user_tab_col_statistics
WHERE table_name = 'SALES';
Rather than specifying the METHOD_OPT parameter in the statistics gathering command it is highly recommended that you specify any non-default value for the METHOD_OPT via DBMS_STATS.SET_TABLE_PREFS.
BEGIN
dbms_stats.Set_table_prefs('SH', 'SALES', 'METHOD_OPT', -
'FOR ALL COLUMNS SIZE 254 FOR COLUMNS SIZE 1 PROD_ID');
END;
/
scsprod
10.1.6.53
scs
EXEC DBMS_STATS.gather_schema_stats (ownname => 'SCS', cascade =>true,estimate_percent => 40);
EXEC DBMS_STATS.gather_schema_stats (ownname => 'PDMLINK80', cascade =>true,estimate_percent => 40);
create index ams.AMS_LA_COMMISSION_DETAILS_COL_2 on (agent_id,as_on_date);
@analyzedynamic:
---------------
SELECT 'EXEC DBMS_STATS.gather_table_stats(''' || owner || ''',''' || table_name || ''',cascade => true);' from dba_tables where to_char(LAST_ANALYZED,'DD-MON-YY') not like '%JUN-12' and owner='IDEAS';
select owner,table_name,last_analyzed from dba_tables where table_name = 'AMS_CONVERTED_RECEIPT_PREMIUM';
--EXEC DBMS_STATS.gather_table_stats('POS_PROD', 'POS_TRN_PLS_RES2');
--EXEC DBMS_STATS.gather_table_stats('POS_PROD', 'POS_TRN_CLS_RES2');
EXEC DBMS_STATS.gather_table_stats('LEAP', 'DW_WT_POS_FE_1');
EXEC DBMS_STATS.gather_table_stats('FCCPROD', 'STTB_UPLOAD_EXCEPTION');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_LA_COMMISSION_DETAILS');
EXEC DBMS_STATS.gather_table_stats('IDEAS', 'IDEAS_QC_FIELD_ERROR');
EXEC DBMS_STATS.gather_table_stats('PRL_PROD', 'PRL_CASE_AUDIT_TRAIL');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_PREMIUM_DEFECIT_HISTORY');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_PREMIUM_DEFECIT');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_CONVERTED_RECEIPT_PREMIUM');
EXEC DBMS_STATS.gather_table_stats('PRL_PROD', 'RESOURCE_MASTER_MIRROR');
EXEC DBMS_STATS.gather_table_stats('IDEAS', 'DW_WT_IDEAS_6');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_CONVERTED_RECEIPT_PREMIUM',estimate_percent => 15,cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_AGENT_HIERARCHY_TEMP',estimate_percent => 15,cascade => true);
EXEC DBMS_STATS.gather_table_stats('CP', 'CP_CLIENT_MASTER',cascade => true);
EXEC DBMS_STATS.gather_table_stats('CP', 'CP_USAGE_MASTER');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_RN_HRPRECS');
EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMPLOYEES');
EXEC DBMS_STATS.gather_table_stats('AMS', 'ROOTWISE_AGENT_DETAILS',estimate_percent => 15,cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_CLIENT_MASTER', estimate_percent => 15,cascade => true);
EXEC DBMS_STATS.gather_table_stats('IWAN_STG', 'ADDRESS_ROW_FORM', estimate_percent => dbms_stats.auto_sample_size,cascade => true);
EXEC DBMS_STATS.gather_table_stats('IWAN_STG', 'REPDB_CI', estimate_percent => dbms_stats.auto_sample_size,cascade => true);
--EXEC DBMS_STATS.gather_schema_stats (ownname => 'MFUNDMCY', cascade =>true,estimate_percent => dbms_stats.auto_sample_size);
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_CONVERTED_RECEIPT_PREMIUM',cascade => true);
EXEC DBMS_STATS.gather_table_stats('MFUNDMCY', 'WEB_T_PORTFOLIO',cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_PD_TOTALSCORECARD_RPT',cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'REPDB_CI',cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMS', 'ADDRESS_ROW_FORM',cascade => true);
EXEC DBMS_STATS.gather_table_stats('AMH', 'AMS_SALES_AGGREGATION_MAIN',cascade => true);
EXEC DBMS_STATS.gather_table_stats('PRL_WF_PROD', 'INSTANCE_STATE',cascade => true);
EXEC DBMS_STATS.gather_table_stats('ETL', 'ETL_GTT_WAIT_STATS');
EXEC DBMS_STATS.gather_table_stats('ETL', 'ETL_RUN_STATS');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_AGENT_HIERARCHY');
EXEC DBMS_STATS.gather_table_stats('HSLRNRPROD', 'COL_MST_OTHERADDRESS');
EXEC DBMS_STATS.gather_table_stats('HSLRNRPROD', 'COL_MST_PHONENUMBERS');
EXEC DBMS_STATS.gather_table_stats('AMS', 'AMS_PRPSL_DETAILS',cascade => true);
EXEC DBMS_STATS.gather_table_stats('BHADRESHD', 'TFORECASTN',cascade => true);
EXEC DBMS_STATS.unlock_table_stats('FLEXPROD_HOST', 'XF_ST_CAP_INPUT_TXN');
EXEC DBMS_STATS.gather_table_stats('FLEXPROD_HOST', 'XF_ST_CAP_INPUT_TXN', estimate_percent => 15,cascade => true);
ams_policy_details_exclude
EXEC DBMS_STATS.gather_table_stats('MFUNDMCY', 'WEB_T_PORTFOLIO',cascade => true);
EXEC DBMS_STATS.gather_schema_stats (ownname => 'MFUNDMCY', cascade =>true,estimate_percent => dbms_stats.auto_sample_size);
select table_name
from dba_tables
where table_name like '%STAT%'
and table_name not like 'WRH%'
and table_name not like 'WRI%'
and owner='SYS';
Object Level
exec dbms_stats.create_stat_table('SYS','&stattablename');
exec dbms_stats.export_database_stats('&stattable','&statid','SYS');
exec dbms_stats.export_schema_stats('&owner','&stattablename','&statid','SYS');
======================= EVENT Check===========================
select event, total_waits,
round(time_waited/100) "TIME(s)",
average_wait*10 "AVG(ms)",
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') time
from v$system_event
where time_waited > 100 and (event like '%KSV%' or event like '%async%')
order by time_waited
============== Log Switch Time =================================
@dailyarch
set lines 120;
set pages 999;
select substr(time,1,5) day,
to_char(sum(decode(substr(time,10,2),'00',1,0)),'99') "00",
to_char(sum(decode(substr(time,10,2),'01',1,0)),'99') "01",
to_char(sum(decode(substr(time,10,2),'02',1,0)),'99') "02",
to_char(sum(decode(substr(time,10,2),'03',1,0)),'99') "03",
to_char(sum(decode(substr(time,10,2),'04',1,0)),'99') "04",
to_char(sum(decode(substr(time,10,2),'05',1,0)),'99') "05",
to_char(sum(decode(substr(time,10,2),'06',1,0)),'99') "06",
to_char(sum(decode(substr(time,10,2),'07',1,0)),'99') "07",
to_char(sum(decode(substr(time,10,2),'08',1,0)),'99') "08",
to_char(sum(decode(substr(time,10,2),'09',1,0)),'99') "09",
to_char(sum(decode(substr(time,10,2),'10',1,0)),'99') "10",
to_char(sum(decode(substr(time,10,2),'11',1,0)),'99') "11",
to_char(sum(decode(substr(time,10,2),'12',1,0)),'99') "12",
to_char(sum(decode(substr(time,10,2),'13',1,0)),'99') "13",
to_char(sum(decode(substr(time,10,2),'14',1,0)),'99') "14",
to_char(sum(decode(substr(time,10,2),'15',1,0)),'99') "15",
to_char(sum(decode(substr(time,10,2),'16',1,0)),'99') "16",
to_char(sum(decode(substr(time,10,2),'17',1,0)),'99') "17",
to_char(sum(decode(substr(time,10,2),'18',1,0)),'99') "18",
to_char(sum(decode(substr(time,10,2),'19',1,0)),'99') "19",
to_char(sum(decode(substr(time,10,2),'20',1,0)),'99') "20",
to_char(sum(decode(substr(time,10,2),'21',1,0)),'99') "21",
to_char(sum(decode(substr(time,10,2),'22',1,0)),'99') "22",
to_char(sum(decode(substr(time,10,2),'23',1,0)),'99') "23"
from
v$log_history
group by substr(time,1,5);
This log switch script is handy because it displays the log switch activity as a two-dimensional table, showing log switches by hours of the day and log switches by date:
--------------------------------------------
select nvl(ss.USERNAME,'ORACLE Back PROC') username,name,
se.SID,
VALUE cpu_usage
from v$session ss,
v$sesstat se,
v$statname sn
where se.STATISTIC# = sn.STATISTIC#
and (NAME like '%CPU used by this session%'
or NAME like 'session pga memory')
and se.SID = ss.SID and value <> 0
and ss.sid = &SID
order by sid desc;
SELECT
e.SID,
e.username,
e.status,
a.UGA_MEMORY,
b.PGA_MEMORY
FROM
(select y.SID, TO_CHAR(ROUND(y.value/1024),99999999) || ' KB' UGA_MEMORY from v$sesstat y, v$statname z where y.STATISTIC# = z.STATISTIC# and NAME = 'session uga memory') a,
(select y.SID, TO_CHAR(ROUND(y.value/1024),99999999) || ' KB' PGA_MEMORY from v$sesstat y, v$statname z where y.STATISTIC# = z.STATISTIC# and NAME = 'session pga memory') b,
v$session e
WHERE
e.sid=a.sid
AND
e.sid=b.sid
--and a.sid in (453,560,297,321)
and a.sid in (386,364)
ORDER BY
e.status,
a.UGA_MEMORY desc;
====== QUERY Taken Time =============
column username format a10
select sesion.sid,sesion.serial#,
sesion.username,
optimizer_mode,
hash_value,
address,
round(cpu_time/1000000/60,0) CPU_MIN,
round(elapsed_time/1000000/60,0) QURY_RUN_MIN,
sql_text
from v$sqlarea sqlarea, v$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null and sesion.sid = &SID;
-- Logon Time , STatus
select s.username "Oracle User",s.osuser "OS User",i.consistent_gets "Consistent Gets",
i.physical_reads "Physical Reads",s.status "Status",s.sid "SID",s.serial# "Serial#",
s.machine "Machine",s.program "Program",to_char(logon_time, 'DD/MM/YYYY HH24:MI:SS') "Logon Time",
w.seconds_in_wait "Idle Time", P.SPID "PROC",
name "Stat CPU", value
from v$session s, v$sess_io i, v$session_wait w, V$PROCESS P, v$statname n, v$sesstat t
where s.sid = i.sid
and s.sid = w.sid (+)
and 'SQL*Net message from client' = w.event(+)
and s.osuser is not null
and s.username is not null
and s.paddr=p.addr
and n.statistic# = t.statistic#
and n.name like '%cpu%'
and t.SID = s.sid
order by 6 asc, 3 desc, 4 desc;
=======================================================================================
=======================================================================================
=======================================================================================
=======================================================================================
=======================================================================================
-- Database HIT Ratio
select 100 * (1-(pr.value/(bg.value + cg.value))) || '%' as "Hit Ratio",
pr.value "Phys R",
bg.value "Bl. Gets",
cg.value "Cons Gets"
from
v$sysstat pr,
v$sysstat bg,
v$sysstat cg
where
pr.name='physical reads' and
bg.name='db block gets' and
cg.name ='consistent gets';
-- LOCKS
column osuser format a10
column owner format a10
column object_name format a15
column machine format a15
select c.owner,c.object_name,c.object_type,b.sid,b.serial#,b.status,b.osuser,b.machine
from v$locked_object a,v$session b,dba_objects c
where b.sid = a.session_id
and a.object_id = c.object_id
order by 2;
Here Log File means oracle Online Redo Log Files (this files records all the changes (transactions) done (like Inserts / Updates / Deletes) through any sessions inside the Oracle database). We observed that Oracle sessions where not able to read / Write in the Online redo log file, due to which the sessions got hanged / wait state, on this (Log File Sync) WAIT EVENT .
-- CPU Utilization
select * from
(SELECT se.username, ss.sid, value CPU_Usage
FROM v$session se, v$sesstat ss, v$statname st
WHERE ss.statistic# = st.statistic#
AND name LIKE '%roll%'
AND se.sid = ss.SID and value > 10000
AND se.username IS NOT NULL
ORDER BY value DESC) a;
-- INACTIVE Sessions Query Taking Time;
select * from
(SELECT se.username, ss.sid, value CPU_Usage
FROM v$session se, v$sesstat ss, v$statname st
WHERE ss.statistic# = st.statistic#
AND name LIKE '%CPU used by this session%'
AND se.sid = ss.SID and value <> 0
AND se.username IS NOT NULL and se.sid in (select sid from v$session where status = 'INACTIVE')
ORDER BY value DESC) a where rownum <= 15;
--QUERY Taking time & Inf. by SID
column username format a10
select sesion.sid,sesion.serial#,
sesion.username,
optimizer_mode,
hash_value,
address,
round(cpu_time/1000000/60,0) CPU_MIN,
round(elapsed_time/1000000/60,0) QURY_RUN_MIN,
sql_text
from v$sqlarea sqlarea, v$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null
and sesion.sid = &SID;
select SQL_TEXT from v$sqltext where HASH_VALUE='&HASH_VALUE' order by PIECE;
-- ACTIVE - INACTIVE --
select
s.username,
s.sid,
s.serial#,
p.pid ppid,
s.status,
s.osuser,
substr(s.program,1,20) client_program,
s.process client_process,
substr(p.program,1,20) server_program,
p.spid server_pid
from v$session s, v$process p
where s.username is not null
and p.addr(+) = s.paddr and s.sid = &sid
order by username, sid;
/
--ALL QUERY Taking TIME ---------
column username format a10
select sesion.sid,sesion.serial#,
sesion.username,
optimizer_mode,
hash_value,
address,
round(cpu_time/1000000/60,0) CPU_MIN,
round(elapsed_time/1000000/60,0) QURY_RUN_MIN,
sql_text
from v$sqlarea sqlarea, v$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null
order by elapsed_time desc;
================
@killinactive:
select 'alter system kill session ''' ||sid|| ',' || serial#|| ''' immediate;' from v$session where status='INACTIVE' and username='<>';
--- User Creation
18:42:46 SQL> create user USR28 identified by usr28 default tablespace AMS_BIG_MASTER_DATA;
User created.
18:43:54 SQL> grant create session to USR28;
Grant succeeded.
18:44:19 SQL> grant create any table, select any table, create any trigger to usr28;
set pages 200
set lines 200
column machine format a20
column event format a35
column program format a20
column action format a20
select sid,serial#,machine,program,event,action,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),schemaname
from v$session;
create table logon_tbl (who varchar2(30), when date);
create or replace trigger trg_logon_db
after insert on usr28.sess for each row
begin
insert into usr28.logon_tbl (who, when) values (user, sysdate);
end trg_logon_db;
/
Manoj - 9221081723
create or replace trigger trg_logon_db
after logon on database
begin
insert into usr28.logon_tbl (who, when) values (user, sysdate);
end trg_logon_db;
/
select TRIGGER_NAME,TABLE_OWNER,TABLE_NAME,STATUS,action_type from user_triggers where trigger_name = 'TRG_LOGON_DB';
create table sess(
sid number,
serial number,
USERNAME varchar2(20),
schemaname varchar2(20),
STATUS varchar2(8),
machine varchar2(64),
terminal varchar2(16),
program varchar2(64),
action varchar2(32),
SQL_HASH_VALUE number,
logon_time date
);
==== Final Trigger ===========
drop trigger usr28.USR28_LOGON_S10;
drop trigger usr28.trg_logon_db;
drop trigger sys.USR28_LOGON_S10;
drop trigger sys.trg_logon_db;
create or replace trigger USR28_LOGON_S10
before insert on usr28.logon_tbl for each row
begin
insert into usr28.sess (sid,serial,username,schemaname,status,machine,terminal,program,action,sql_hash_value,logon_time)
(select sid,serial#,username,schemaname,status,machine,terminal,program,action,sql_hash_value,logon_time from v$session
where logon_time = (select max(logon_time) from v$session) and (schemaname = 'USR28' or username = 'USR28'));
end;
/
create or replace trigger trg_logon_db
after logon on database
begin
insert into usr28.logon_tbl (who, when) values (user, sysdate);
end trg_logon_db;
/
====================================================================
-- With SID
column username format a10
select sesion.sid,sesion.serial#,
sesion.username,
optimizer_mode,
hash_value,
address,
round(cpu_time/1000000/60,0) CPU_MIN,
round(elapsed_time/1000000/60,0) QURY_RUN_MIN,
sql_text
from v$sqlarea sqlarea, v$session sesion
where sesion.sql_hash_value = sqlarea.hash_value
and sesion.sql_address = sqlarea.address
and sesion.username is not null and sesion.sid = &SID
order by elapsed_time desc;
-- Logon TIME, Status, by SID
column "Oracle User" format a10
column Program format a20
column "Stat CPU" format a20
column "OS User" format a10
select s.username "Oracle User",s.osuser "OS User",i.consistent_gets "Consistent Gets",
i.physical_reads "Physical Reads",s.status "Status",s.sid "SID",s.serial# "Serial#",
s.machine "Machine",s.program "Program",to_char(logon_time, 'DD/MM/YYYY HH24:MI:SS') "Logon Time",
w.seconds_in_wait "Idle Time", P.SPID "PROC",
name "Stat CPU", value
from v$session s, v$sess_io i, v$session_wait w, V$PROCESS P, v$statname n, v$sesstat t
where s.sid = i.sid
and s.sid = w.sid (+)
and 'SQL*Net message from client' = w.event(+)
and s.osuser is not null
and s.username is not null
and s.paddr=p.addr
and n.statistic# = t.statistic#
and n.name like '%cpu%'
and t.SID = s.sid
and s.sid = &SID
order by 6 asc, 3 desc, 4 desc;
-- CPU in Seconds.
select * from
(select
ss.username,
se.SID,
VALUE/100 cpu_usage_seconds
from
v$session ss,
v$sesstat se,
v$statname sn
where
se.STATISTIC# = sn.STATISTIC#
and
NAME like '%CPU used by this session%'
and
se.SID = ss.SID
and
ss.status='INACTIVE' and ss.username <> 'CP'
and
ss.username is not null
order by VALUE desc) where rownum <= 15;
select sid,serial#,program,status from v$session where status = 'INACTIVE';
-- Checking Tablespace Size
SET LINES 150
SET pages 300
col "Tablespace" FOR a30
col "Total MB" FOR a15
col "Used MB" FOR a15
col "% Used" FOR a15
SELECT
tablespace_name "Tablespace",
d.STATUS "Status",
TO_CHAR((a.bytes / 1048576),'99,999,990.900') "Total MB",
TO_CHAR(((a.bytes - DECODE(f.bytes, NULL, 0, f.bytes)) / 1048576),'99,999,990.900') "Used MB",
TO_CHAR((((a.bytes - DECODE(f.bytes, NULL, 0, f.bytes)) / 1048576)*100) / (a.bytes / 1048576),'999,999.9') "% Used"
FROM
(sys.dba_tablespaces d JOIN sys.sm$ts_avail a USING (tablespace_name))
LEFT OUTER JOIN sys.sm$ts_free f USING (tablespace_name)
ORDER BY 5;
Prompt ================Uptime==================
select to_char(STARTUP_TIME,'dd/mm/yyyy hh24:mm') from v$instance;
prompt ======================TEMP TABLESPACE=================================================
SELECT tablespace_name, SUM(bytes_used/1024/1024), SUM(bytes_free/1024/1024)
FROM V$temp_space_header
GROUP BY tablespace_name;
=======================================================================================
=======================================================================================
=======================================================================================
=======================================================================================
=======================================================================================
Good Links
===========
http://www.oraclefaq.net/2007/06/21/how-to-delete-a-node-from-3-node-rac-in-10gr2/
http://www.idevelopment.info/data/Oracle/DBA_tips/Oracle10gRAC/CLUSTER_22.shtml#Remove%20the%20Node%20from%20the%20Cluster
RMAN
======
SQL> create tablespace rman datafile size 1G autoextend on;
Tablespace created.
SQL> CREATE USER rman IDENTIFIED BY rman
2 TEMPORARY TABLESPACE temp1
3 DEFAULT TABLESPACE rman
4 QUOTA UNLIMITED ON rman;
User created.
SQL> GRANT connect, resource, recovery_catalog_owner TO rman;
Grant succeeded.
SQL> select count(*) from dba_objects where owner = 'RMAN';
COUNT(*)
----------
252
SQL>
C:\>set oracle_sid=hlportal1
C:\>rman catalog=rman/rman
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 21:13:15 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN> create catalog tablespace "rman";
error creating db
ORACLE error from recovery catalog database: ORA-00959: tablespace 'rman' does not exist
ORACLE error from recovery catalog database: ORA-00942: table or view does not exist
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-06433: error installing recovery catalog
RMAN> create catalog tablespace rman;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "rman": expecting one of: "double-quoted-string, identifier, single-quoted-string"
RMAN-01007: at line 1 column 27 file: standard input
RMAN> create catalog;
recovery catalog created
RMAN> exit
Recovery Manager complete.
C:\>rman catalog=rman/rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 21:15:59 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: HLPORTAL (DBID=214138538)
connected to recovery catalog database
RMAN> reister database;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "advise, allocate, alter, backup, @, catalog, chang
RMAN-01008: the bad identifier was: reister
RMAN-01007: at line 1 column 1 file: standard input
RMAN> exit
Recovery Manager complete.
C:\>rman catalog=rman/rman target=/
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 21:16:52 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: HLPORTAL (DBID=214138538)
connected to recovery catalog database
RMAN> create catalog;
recovery catalog created
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>
change backuppiece '' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16982_1_20100425_IMLC1N5E_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16983_1_20100425_INLC1N5E_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16984_1_20100425_IOLC1N5E_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16985_1_20100425_IPLC1PEF_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16986_1_20100425_IQLC1PGQ_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16987_1_20100425_IRLC1PJG_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16988_1_20100425_ISLC1RQB_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16989_1_20100425_ITLC1RS3_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16990_1_20100425_IULC1RUP_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16991_1_20100425_IVLC1U4L_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16992_1_20100425_J0LC1U7V_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16993_1_20100425_J1LC1U9D_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16994_1_20100425_J2LC20G3_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16995_1_20100425_J3LC20G4_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16996_1_20100425_J4LC20I6_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16997_1_20100426_J5LC235S_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16998_1_20100426_J6LC235T_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_16999_1_20100426_J7LC2397_1_1.BAK' uncatalog;
change backuppiece 'E:\Backup\Backup_Compress\Rman\DAILY_FULL_17000_1_20100426_J8LC25P4_1_1.BAK' uncatalog;
catalog start with '';
catalog start with 'E:\Backup\';
restore database;
crosscheck backup;
list backupset;
CROSSCHECK backup of database;
crosscheck backupset;
delete expired backupset;
catalog start with 'E:\Backup\';
restore database;
crosscheck archivelog all;
restore controlfile from 'E:\Backup\C-2213995706-20100426-00';
RMAN> run {
2> set newname for datafile '+DATA/hdfcprod/datafile/system.322.656800181' to 'E:\hdfcprod\datafile\system.322.656800181';
3> recover datafile 1;
4> switch datafile 1;
5> }
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update' UNTIL TIME 'SYSDATE-7';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_upd'
DATABASE;
}
RMAN> BACKUP SPFILE TO DESTINATION '/u01/backups';
RMAN> BACKUP TAG 'weekly_full_db_bkup' DATABASE ;
BACKUP tag 'Mdealing_Full_25102011' INCREMENTAL LEVEL 0 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
RUN {
RECOVER COPY OF DATABASE WITH TAG 'Mdealing_Full_25102011';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'Mdealing_Full_incr_25102011'
DATABASE;
}
BACKUP tag 'Mdealing_Full_25102011' INCREMENTAL LEVEL 0 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
BACKUP tag 'Mdealing_INCR1_25102011' INCREMENTAL LEVEL 1 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
FINAL Differential INCREMENTAL BACKUP;
backup as copy current controlfile format 'E:\Requets_Backup\Control_25102011.ctl';
----------- BACKUP ------------------
BACKUP tag 'Mdealing_FULL_25102011' INCREMENTAL LEVEL 0 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
BACKUP tag 'Mdealing_INCR1_25102011' INCREMENTAL LEVEL 1 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
BACKUP tag 'Mdealing_INCR1_25102011' INCREMENTAL LEVEL 1 DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
----------- RESOTRE -----------------
RMAN> restore database;
RMAN> recover copy of database with tag 'Mdealing_INCR2_25102011';
==== Tablespace Level RMAN
-- Backup --
RMAN> BACKUP INCREMENTAL LEVEL 1 TABLESPACE tools FORMAT 'c:\RMANBKUP\tools_L1';
-- Restore --
RMAN> run { allocate channel t1 type 'sbt_tape' parms
2> 'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
3> sql "alter tablespace TEST_TS offline immediate";
4> restore tablespace TEST_TS;
5> recover tablespace TEST_TS;
6> sql "alter tablespace TEST_TS online";
7> release channel t1;
8> }
Normal RMAN Backup ====
BACKUP tag 'HLOPS2_BKP' DATABASE filesperset 10 format 'E:\Request_backup\daily_FULL_DB_%s_%p_%T_%U.bak' include current controlfile;
===================================================================
set newname for datafile '+DATA/hdfcprod/datafile/system.322.656800181' to 'D:\oracle\product\10.2.0\Oradata\hdfcprod\datafile\system.322.656800181';
connect target sys/sys@ORCL;
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
report obSOlete;
CROSSCHECK BACKUP;
CROSSCHECK COPY;
DELETE EXPIRED BACKUP;
DELETE EXPIRED COPY;
delete obsolete;
release channel;
CHANGE BACKUPPIECE '/oradata2/oft7qq' UNCATALOG;
RESTORING Through RMAN ARCHIVE BACKUPPIECE
===========================================
RMAN run{
RMAN set archivelog destination to 'F:\PRLPROD\ARCHIVE';
RMAN }
RMAN list backup of archivelog all; ## check Sequence
RMAN restore archivelog from sequence 11111 until sequence 222222;
SQL> recover database using backup controlfile;
Provide ARCH FileName;
Then Provide REDO Log File;
IT will show MEDIA RECOVERY COMPLETE
SQL> alter database open resetlogs;
SQL> shut immediate;
SQL> alter database open;
restore archivelog from logseq=100 until logseq=110;
restore archivelog from time='15-JUN-05' until time='20-JUN-05';
recover database;
restore archivelog from time='15-JUN-05' until time='20-JUN-05';
=== BACKUP Database / Controlfile / Archive log Files in BACKUPPIECES
======================================================================
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'F:\RMAN_Backup\HDFCAML_Controlfile\%F';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'TO YOUR PATH/%F';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
=== RCV File Riyaz
run
{
allocate channel ch1 type disk maxpiecesize 4G;
allocate channel ch2 type disk maxpiecesize 4G;
allocate channel ch3 type disk maxpiecesize 4G;
allocate channel ch4 type disk maxpiecesize 4G;
BACKUP AS COMPRESSED BACKUPSET DATABASE format 'TO YOU PATH\daily_FULL_DB_%s_%p_%T_%U.bak' filesperset 10;
BACKUP ARCHIVELOG from time 'sysdate-1' format 'TO YOU PATH\daily_ARCH_%s_%p_%T_%U.bak' filesperset 10 ;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
connect target /
HDFCBANK
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/fc_precut_dump/RMAN_06062013/FULL_DB_%s_%p_%T_%U.bak';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/fc_precut_dump/RMAN_06062013/FULL_DB_%s_%p_%T_%U.bak';
run
{
backup as compressed backupset database plus archivelog skip inaccessible including current controlfile;
backup current controlfile;
backup current controlfile for standby;
}
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/odgdump/SCN_19072013/%F';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/odgdump/SCN_19072013/SCN_DB_%s_%p_%T_%U.bak';
BACKUP INCREMENTAL FROM SCN 47987632 DATABASE;
==Perfect
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/odgdump/SCN_19072013/%F';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/odgdump/SCN_19072013/SCN_DB_%s_%p_%T_%U.bak';
BACKUP INCREMENTAL FROM SCN 47987632 DATABASE;
run
{
backup as compressed backupset database plus archivelog skip inaccessible;
backup current controlfile;
}
SCN RMAN RESTORE
=====================
1....On Standby Database.
select name,open_mode,CURRENT_SCN from v$database;
2....On Primary Database.
a. BACKUP DEVICE TYPE SBT INCREMENTAL FROM SCN 750923 DATABASE;
b. BACKUP INCREMENTAL FROM SCN 750923 DATABASE;
c. BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750983 DATABASE
FORMAT '/tmp/incr_standby_%U';
3....On Primary Database.
Backup Controlfile
3....On Standby Database.
RESTORE at STANDBY Side
RMAN> CATALOG START WITH '/standbydisk1/incrback/';
4....On Standby Database.
START RECOVER
RMAN> RECOVER DATABASE NOREDO;
========
backup as copy current controlfile format 'F:\RMAN_Backup\HDFCAML_Controlfile\HDFCAML_CTL.cfl';
backup as copy current controlfile format 'E:\Requets_Backup\Control_25102011.ctl';
============================================================================================================
Incremental Differential Backup
BACKUP INCREMENTAL LEVEL 0 DATABASE format 'D:\wipro-dba\RMAN_Incremental\daily_FULL_DB_%s_%p_%T_%U.bak' filesperset 10;
BACKUP INCREMENTAL LEVEL 1 DATABASE format 'D:\SAM_NEW\daily_FULL_DB_1_%s_%p_%T_%U.bak' filesperset 10;
Incremental CUMULATIVE Backup
BACKUP INCREMENTAL LEVEL 0 CUMULATIVE DATABASE format 'D:\wipro-dba\RMAN_Incremental\daily_FULL_DB_%s_%p_%T_%U.bak' filesperset 10;
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE format 'D:\SAM_NEW\daily_FULL_DB_1_%s_%p_%T_%U.bak' filesperset 10;
To store the change tracking file in the database area, set DB_CREATE_FILE_DEST in the target database. Then issue the following SQL statement to enable change tracking:
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
============================================================================================================
================== Parag Mail
Hi,
As discussed with Swapnil, he is Telling both ETL & CC Applications are running Slow.
As Analyzed, found that there is constant LOCK on below Tables with Session & also it is utilizing , Find details below:
SID SERIAL# PROCEDURE Running SCHEMA USER
====== ========= ======================== ========= ==========
214 479 begin AMS.AMS_PKG_BL.AMS_INCENTI ETL ETL
556 4512 begin cp_sch_pkg.sp_ia_payment; SYS ETL
Lock Acquired in Table:
========================
214 Session on Node 1:
ETL_RUN_STATS
ETL_WAIT_STATS
ETL_GTT_WAIT_STATS
556 Session on Node 2:
CP_IA_PAYMENT_ALERT_DTL
Revert if anything needs to be done from my side.
==================================================================
== Rename UNNAMED File to Proper File name.
alter database create datafile 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00012' as '+DATA_IDEAS/pinnacle/datafile/ideas.318.719999863';
select 'set newname for datafile ,' || name || ', to ,DOG'|| name || ';' from v$datafile;
select 'set newname for datafile ''' || name || ''' to ''DOG'|| name || ''';' from v$datafile;
select 'alter database rename file ''' || name || ''' to ''DOG'|| name || ''';' from v$tempfile;
select 'alter database rename file ''' || member || ''' to ''DOG'|| member || ''';' from v$logfile;
select tablespace_name||',set newname for datafile ,' || file_name || ', to ,DOG'|| file_name || ',;,' ||bytes/1024/1024/1024 from dba_data_files order by 1;
column file_name format a65
column tablepsace_name format a22
set pages 200
set lines 200
select tablespace_name||','||file_name||','||bytes/1024/1024/1024 from dba_data_files order by 1;
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
col FN for a15
select substr(file_name,1,4) FN, sum(bytes/1024/1024/1024) from dba_data_files group by substr(file_name,1,4);
== If alter database create datafile 'OLD File' as 'NEW File'; Doesnot work
RMAN> run {
2> set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00012' to '+DATA_IDEAS/pinnacle/datafile/ideas.318.719999863';
3> restore datafile 12;
4> recover datafile 12;
5> }
select thread#,sequence#,to_char(first_time,'DD-MON-YYYY HH24:MI:SS') from v$log_history
where sequence# in (select max(sequence#) from v$log_history group by thread#);
=========================================================================
Oracle 11g
alter system set optimizer_features_enable='10.2.0.4' scope=memory
alter session set optimizer_features_enable='10.2.0.4'
VAR R REFCURSOR;
EXEC ALT_PKG_LGWISE_REPORTS.ALT_SP_GET_MTD_SUMMARY_REP('HD01',0,:r);
print r;
Oracle 11g AWR Report Starting
Assign Parameters:
SQL> show parameter CONTROL_MANAGEMENT_PAC
NAME_COL_PLUS_SHOW_PARAM TYPE VALUE_COL_PLUS_SHOW_PARAM
---------------------------------------- ----------- ------------------------------
control_management_pack_access string DIAGNOSTIC+TUNING
SQL>
SQL> show parameter statistics_level
NAME_COL_PLUS_SHOW_PARAM TYPE VALUE_COL_PLUS_SHOW_PARAM
---------------------------------------- ----------- ------------------------------
statistics_level string TYPICAL
SQL>
select distinct STAT_NAME,VALUE from V$sess_TIME_MODEL order by 1;
select snap_interval, retention from dba_hist_wr_control;
select distinct STAT_NAME,VALUE from V$Sys_TIME_MODEL order by 1;
col stat_name for a35
select * from V$OSSTAT ;
select * from v$license;
SELECT a.job_name, a.enabled, c.window_name, c.schedule_name, c.start_date, c.repeat_interval
FROM dba_scheduler_jobs a, dba_scheduler_wingroup_members b, dba_scheduler_windows c
WHERE job_name='GATHER_STATS_JOB'
And a.schedule_name=b.window_group_name
And b.window_name=c.window_name;
Execute Procedures
like:
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
END;
/
BEGIN
DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 1440,
interval => 60);
END;
/
@$ORACLE_HOME/rdbms/admin/awrextr.sql
@?/rdbms/admin/awrload.sql
@$ORACLE_HOME/rdbms/admin/awrrpt.sql
BEGIN
DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE (low_snap_id => 102, high_snap_id => 122, dbid => 8187786345);
END;
/
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.
Workload Repository Views
The following workload repository views are available:
V$ACTIVE_SESSION_HISTORY - Displays the active session history (ASH) sampled every second.
V$METRIC - Displays metric information.
V$METRICNAME - Displays the metrics associated with each metric group.
V$METRIC_HISTORY - Displays historical metrics.
V$METRICGROUP - Displays all metrics groups.
DBA_HIST_ACTIVE_SESS_HISTORY - Displays the history contents of the active session history.
DBA_HIST_BASELINE - Displays baseline information.
DBA_HIST_DATABASE_INSTANCE - Displays database environment information.
DBA_HIST_SNAPSHOT - Displays snapshot information.
DBA_HIST_SQL_PLAN - Displays SQL execution plans.
DBA_HIST_WR_CONTROL - Displays AWR settings.
=========================================================================
Oracle 11g Mail Sending
SELECT host, acl,
DECODE(
DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE_ACLID(aclid, 'ETL', 'resolve'),
1, 'GRANTED', 0, 'DENIED', NULL) privilege
FROM dba_network_acls
;
Example1
Grant the connect and resolve privileges for host www.us.oracle.com to SCOTT.
BEGIN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'www.xml',
description => 'WWW ACL',
principal => 'SCOTT',
is_grant => true,
privilege => 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'www.xml',
principal => 'SCOTT',
is_grant => true,
privilege => 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'www.xml',
host => 'www.us.oracle.com');
END;
/
COMMIT;
Example 2
Grant the resolve privilege for www.us.oracle.com to ADAMS. Since an ACL for www.us.oracle.com exists already, just add the privilege for ADAMS.
BEGIN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'www.xml',
principal => 'ADAMS',
is_grant => true,
privilege => 'resolve');
END;
/
COMMIT;
Example 3
Assign the ACL www.xml to www-proxy.us.oracle.com so that SCOTT and ADAMS can access www-proxy.us.oracle.com also.
BEGIN
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'www.xml',
host => 'www-proxy.us.oracle.com');
END;
/
COMMIT;
Example 4
Unassign the ACL from www.us.oracle.com so that no access to www.us.oracle.com is allowed.
BEGIN
DBMS_NETWORK_ACL_ADMIN.UNASSIGN_ACL(host => 'www.us.oracle.com');
END;
/
COMMIT;
BEGIN
DBMS_NETWORK_ACL_ADMIN.DELETE_PRIVILEGE(
acl => 'us-oracle-com-permissions.xml',
principal => 'ST_USERS')
END;
BEGIN
DBMS_NETWORK_ACL_ADMIN.DROP_ACL(
acl => 'us-oracle-com-permissions.xml');
END;
==============================================
Advantage of ASM :
Flexible --> Without shutting down database , can add new Disk / Space in ASM.
Fault Tolerance --> ASM handles the mirroring of data, Once datas Inserted in the datafiles it never / hardly gets lost.
Productivity increases --> Space management is taken care of by ASM.
In Oracle 10g Multiple ASM instance is possible so that if 1 ASM Instance needs to be stopped, others are not affected.
If I drop a tablespace, ASM will figure out which datafile(s) are no longer required and will then automatically remove the physical files without any intervention on my part.
=======
ed lock
select sid, user#, username, command, lockwait, status from gv$session
WHERE LOCKWAIT is not null
======
@edplan
set pages 0
set lines 10000
set long 10000
select plan_table_output from table(dbms_xplan.display_cursor('&sqlid'));
======
ed plan2
select plan_table_output from table(dbms_xplan.display_awr('&sqlid'));
======
@cpuutiliztion
set pages 400
set lines 300
col user_process for a14
col user_nm for a11
col machine_nm for a5
col program for a22
col event for a30
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
--SS.SQL_ID,
substr(ss.program,1,17) program,
event,
value, ss.sql_hash_value,ss.sql_id,
substr(ss.osuser,1,23) USER_NM,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),
substr(ss.machine,1,23) MACHINE_NM
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%CPU used by this session%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('ACTIVE')
-- and ss.username not in ('SYS','SYSTEM')
and value >=10000
order by substr(name,1,25), value desc;
col COLUMN_NAME for a30
select table_name,column_name,index_name from dba_ind_columns where table_name='MST_MSG_STOR_TBL' order by 3;
alter system kill session '378,12759' immediate;
519,6797
514,30636
513,20883
set pages 400
set lines 300
col user_process for a20
col user_nm for a20
col machine_nm for a20
col program for a30
col event for a40
col sidd for a55
select substr (ss.username||'('||se.sid||')',1,15) user_process, to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'), ss.program,
'alter system kill session ''' || ss.sid || ',' || ss.serial# || ''' immediate;' SIDD
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%CPU used by this session%'
and se.sid = ss.sid
and ss.username is not null
-- and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >=10000
and ss.logon_time not like sysdate
order by ss.logon_time;
order by substr(name,1,25), value asc;
======
set serverout on size 999999
declare
begin
dbms_output.put_line(’ ‘);
dbms_output.put_line(’************* Start report for WAITING sessions with current SQL ***************’);
for x in (select vs.inst_id, vs.sid || ‘,’ || vs.serial# sidser, vs.sql_address, vs.sql_hash_value,
vs.last_call_et, vsw.seconds_in_wait, vsw.event, vsw.state
from gv$session_wait vsw, gv$session vs
where vsw.sid = vs.sid
and vsw.inst_id = vs.inst_id
and vs.type <> ‘BACKGROUND’
and vsw.event NOT IN (’rdbms ipc message’
,’smon timer’
,’pmon timer’
,’SQL*Net message from client’
,’lock manager wait for remote message’
,’ges remote message’
,’gcs remote message’
,’gcs for action’
,’client message’
,’pipe get’
,’Null event’
,’PX Idle Wait’
,’single-task message’
,’PX Deq: Execution Msg’
,’KXFQ: kxfqdeq - normal deqeue’
,’listen endpoint status’
,’slave wait’
,’wakeup time manager’))
loop
begin
dbms_output.put_line(’Event WaitState InstID SidSerial LastCallEt SecondsInWait’);
dbms_output.put_line(’************************* ******************** ****** *********** ********** *************’);
dbms_output.put_line(rpad(x.event,25) ||’ ‘|| rpad(x.state,20) ||’ ‘|| lpad(x.inst_id,6) ||’ ‘|| lpad(x.sidser,11) ||’
‘|| lpad(x.last_call_et,10) ||’ ‘|| lpad(x.seconds_in_wait,13));
dbms_output.put_line(’ SQLText ‘);
dbms_output.put_line(’****************************************************************’);
for y in (select sql_text
from gv$sqltext
where address = x.sql_address
and hash_value = x.sql_hash_value
and inst_id = x.inst_id
order by piece)
loop
dbms_output.put_line(y.sql_text);
end loop;
end;
end loop;
dbms_output.put_line(’************** End report for sessions waiting with current SQL ****************’);
dbms_output.put_line(’ ‘);
end;
/
======
ed UTLMEMORY
set pages 400
set lines 300
col user_process for a12
col program for a30
col event for a30
col USER_NM for a14
col LOGON_TIME for a20
select ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.program,1,17) program,event,
value,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LOGON_TIME,
substr(ss.osuser,1,23) USER_NM
,substr(ss.machine,1,23) MACHINE_NM,ss.terminal
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%session pga memory%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('ACTIVE')
-- and ss.username not in ('SYS','SYSTEM')
and value >= 10339
and ss.logon_time not like sysdate
order by value;
set pages 400
set lines 300
col user_process for a15
col program for a21
col event for a30
col USER_NM for a14
col LOGON_TIME for a20
col machine_nm for a14
select ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.program,1,17) program,event,
value,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LOGON_TIME,
substr(ss.osuser,1,23) USER_NM
,substr(ss.machine,1,23) MACHINE_NM
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%session pga memory%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('ACTIVE')
and ss.username not in ('SYS','SYSTEM')
and value >= 10339
and ss.logon_time not like sysdate
order by value;
==================
ed POOLUsages, SHARED_POOL, LARGE_POOL
SELECT pool,name,bytes/1024/1024 FROM V$SGASTAT where name like 'free memory';
==================
ed UTLPROCESS
set pages 400
set lines 300
col user_process for a20
col program for a30
col event for a40
col USER_NM for a10
col schemaname for a15
col LOGON_TIME for a20
select distinct ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.program,1,17) program,event,
value,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LOGON_TIME,
substr(ss.osuser,1,23) USER_NM, schemaname
-- substr(ss.machine,1,23) MACHINE_NM
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%process%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('INACTIVE')
and ss.username not in ('SYS','SYSTEM')
-- and value >= 10339
and ss.logon_time not like sysdate
order by value;
=======================
ed UTLpool
set pages 400
set lines 300
col user_process for a20
col program for a30
col event for a40
col USER_NM for a10
col schemaname for a15
col LOGON_TIME for a20
select distinct ss.inst_id,ss.sid,ss.serial#,
substr (ss.username||'('||se.sid||')',1,15) user_process,
substr(ss.program,1,17) program,event,
value,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LOGON_TIME,
substr(ss.osuser,1,23) USER_NM, schemaname
-- substr(ss.machine,1,23) MACHINE_NM
from gv$session ss, gv$sesstat se, gv$statname sn
where se.statistic# = sn.statistic#
and name like '%pool%'
and se.sid = ss.sid
-- and ss.username is not null
-- and ss.status in ('INACTIVE')
and ss.username not in ('SYS','SYSTEM')
-- and value >= 10339
and ss.logon_time not like sysdate
order by value;
======
select program,to_char(logon_time,'dd-mon-yyyy'),count(*) from gv$session where schemaname not like 'SYS%' group by program,to_char(logon_time,'dd-mon-yyyy') order by to_char(logon_time,'dd-mon-yyyy');
col logon_time for a25
select program,to_char(logon_time,'dd-mon-yyyy'),count(*) from gv$session where schemaname not like 'SYS%' group by program,to_char(logon_time,'dd-mon-yyyy') order by to_char(logon_time,'dd-mon-yyyy');
=================
ed usingtemp
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mi:ss'),a.program,a.event,(sum(b.extents)* 1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser, c.spid Process,
a.status --,'alter system kill session ''' || a.sid || ',' || a.serial# || ''' immediate;' "sids"
FROM gv$session a,gv$sort_usage b, gv$process c, dba_tablespaces d
WHERE a.saddr = b.session_addr
AND a.paddr = c.addr
AND b.tablespace=d.tablespace_name
-- and schemaname not like '%SYS%'
and b.extents*1024*1024 > 1000
group by a.username, a.osuser, a.sid||','||a.serial#,c.spid,
b.tablespace, a.status,a.program,a.event, a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mi:ss'),a.program,a.event,(sum(b.extents)* 1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser, c.spid Process,
a.status
FROM gv$session a,gv$sort_usage b, gv$process c, dba_tablespaces d
WHERE a.saddr = b.session_addr
AND a.paddr = c.addr
AND b.tablespace=d.tablespace_name
and schemaname not like '%SYS%'
-- and b.extents*1024*1024 > 10000
group by a.username, a.osuser, a.sid||','||a.serial#,c.spid,
b.tablespace, a.status,a.program,a.event, a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
For 8i
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mi:ss'),a.program,(sum(b.extents)* 1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser, c.spid Process,
a.status, 'alter system kill session ''' || a.sid || ',' || a.serial# || ''' immediate;' "sids"
FROM gv$session a,gv$sort_usage b, gv$process c, dba_tablespaces d
WHERE a.saddr = b.session_addr
AND a.paddr = c.addr
AND b.tablespace=d.tablespace_name
and schemaname not like '%SYS%'
and b.extents*1024*1024 > 1000
group by a.username, a.osuser, a.sid||','||a.serial#,c.spid,
b.tablespace, a.status,a.program,a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mi:ss'),a.program,(sum(b.extents)* 1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser,
a.status, 'alter system kill session ''' || a.sid || ',' || a.serial# || ''' immediate;' "sids"
FROM gv$session a,gv$sort_usage b
WHERE a.saddr = b.session_addr
and schemaname not like '%SYS%'
and b.extents*1024*1024 > 1000
group by a.username, a.osuser, a.sid||','||a.serial#,
b.tablespace, a.status,a.program,a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
=======
ed usingundo
col osuser for a15
col user for a10
col undo_tbs for a12
col SEGMENT_NM for a15
col command for a30
set pages 9999
set lines 200
SELECT ds.TABLESPACE_NAME "UNDO_TBS",ds.RELATIVE_FNO "File Nos",r.name "SEGMENT_NM", s.sid, s.serial#,s.osuser, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,substr(s.program, 1, 78) "COMMAND", c.sql_text
FROM sys.v_$session s, sys.v_$transaction t, sys.v_$rollname r,dba_segments ds,v$sql c
WHERE t.addr = s.taddr
and t.xidusn = r.usn
and s.sql_hash_value = c.hash_value
and ds.segment_name = r.name(+)
--and s.program not like 'ORACLE.EXE%'
ORDER BY t.cr_get, t.phy_io;
========
ed sofar
set time on
set lines 300
set pages 9999
col program for a30
col event for a35
col inst_id for 99
col context for 99999
col Wait_Secs for a10
col LT for a20
SELECT l.inst_id,l.sid, l.serial#, l.context, l.sofar, l.totalwork, l.sofar/l.totalwork*100 "% Complete",
s.program,s.event, s.seconds_in_wait || ' ' Wait_Secs,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT
-- ,s.blocking_session, s.client_info
--, s.p1, s.p2, s.p3,, s.client_info, s.module,l.opname
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND upper(l.opname) LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
--AND s.sid = 1566
--AND s.program like 'ORACLE.EXE (J0%'
--AND s.program like 'oracle@usclvwuca002 (D%'
--AND s.program like '%JDBC%'
--AND upper(l.opname) like '%EXP%'
--and logon_time not like sysdate
AND l.totalwork != 0
--AND l.totalwork <> l.sofar
ORDER BY logon_time desc;
09819741718
===
set time on
set lines 300
set pages 9999
col program for a50
col event for a35
col inst_id for 99
col context for 99999
col Wait_Secs for a10
col LT for a20
col CST for a20
SELECT l.inst_id,l.sid, l.serial#, l.context, l.sofar, l.totalwork, l.sofar/l.totalwork*100 "% Complete",
s.program,s.event, s.seconds_in_wait || ' ' Wait_Secs,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss') LT,to_char(logon_time-1/24,'dd-mm-yyyy hh24:mi:ss') CST
--, s.p1, s.p2, s.p3,, s.client_info, s.module
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND l.opname LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
--AND s.sid = 1045
--AND s.program like 'ORACLE.EXE (J0%'
AND l.totalwork != 0
ORDER BY 7 desc,logon_time;
select sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),osuser from gv$session where osuser='oracle' and program like 'rman%' order by logon_time;
select schemaname,username,sid,serial#,program,event,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss'),osuser from gv$session where sid=&sid order by logon_time;
Check rman TAPE backup
COLUMN EVENT FORMAT a40
COLUMN SECONDS_IN_WAIT FORMAT 999
COLUMN STATE FORMAT a20
COLUMN CLIENT_INFO FORMAT a20
COLUMN state FORMAT a10
SELECT p.SPID, s.sid, s.serial#,s.program,s.event, sw.SECONDS_IN_WAIT AS SEC_WAIT, sw.STATE, s.CLIENT_INFO
FROM V$SESSION_WAIT sw, V$SESSION s, V$PROCESS p
WHERE sw.EVENT LIKE '%sbt%'
AND s.SID=sw.SID
AND s.PADDR=p.ADDR;
select decode(backup_type||controlfile_included||incremental_level,'LNO','ARC', 'DYES', 'CTL', 'DNO', 'DBF_FULL', 'DNO0','DBF_LVL_0','INO1','DBF_LVL_1'),
round(sum(original_input_bytes)/1024/1024,2) "MB in",round(sum(output_bytes)/1024/1024,2) "MB out",status,min(start_time),max(completion_time),
round((sum(output_bytes)/1024/1024)/((max(completion_time)-min(start_time))*86400), 1) "MB/s"
from v$backup_set_details
group by backup_type, controlfile_included, incremental_level, status, session_key, session_recid, session_stamp
order by 5;
--ORDER BY inst_id,sid,serial#;
SELECT l.sid, l.serial#, l.sofar, l.totalwork, l.sofar/l.totalwork*100 "% Complete",s.program,s.event,s.p1, s.p2, s.p3
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND l.opname LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
--AND s.sid = 1632
--AND s.program like 'ORACLE.EXE (J0%'
AND l.totalwork != 0
ORDER BY 7 desc,logon_time;
SELECT l.sid, l.serial#, l.sofar, l.totalwork, l.sofar/l.totalwork*100 "% Complete",s.program,s.event,s.p1, s.p2, s.p3
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND l.opname LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
AND s.sid = 1166
--AND s.program like 'ORACLE.EXE (J0%'
AND l.totalwork != 0
ORDER BY 7 desc,logon_time;
================
select * from dba_jobs_running;
select * from dba_scheduler_running_jobs;
set lines 300
set pages 9999
col program for a30
col event for a35
col inst_id for 99
col context for 99999
col Wait_Secs for a10
SELECT l.inst_id,l.sid, l.serial#, l.context, l.sofar, l.totalwork,
s.program,s.event, s.seconds_in_wait || ' ' Wait_Secs,to_char(logon_time,'dd-mm-yyyy hh24:mi:ss')
--, s.p1, s.p2, s.p3,, s.client_info, s.module
FROM gv$session_longops l, gv$session s
WHERE l.sid=s.sid
AND l.serial# = s.serial#
--AND l.opname LIKE 'RMAN%'
--AND l.sid in (select session_id from gv$locked_object)
--AND l.opname NOT LIKE '%aggregate%'
--AND s.logon_time not like sysdate
AND s.sid = 1613
--AND s.program like 'ORACLE.EXE (J0%'
--AND l.totalwork != 0
ORDER BY logon_time;
--ORDER BY inst_id,sid,serial#;
=============
ed checkarchivelogstatus
set lines 200
set pages 9999
col r.sequence# for 999,999,999
col handle for a80
select r.sequence# sequence, p.handle handle, to_char(l.first_time,'DD-MON-YYYY HH24:MI:SS')
from v$backup_piece p, v$backup_redolog r, v$log_history l
where r.set_stamp = p.set_stamp
and r.set_count = p.set_count
and l.sequence# = r.sequence#
and r.sequence# = (select max(r.sequence#) from v$backup_redolog r)
order by 1;
--and r.sequence# = 63
set lines 200
set pages 9999
col r.sequence# for 999,999,999
col handle for a80
select r.sequence# sequence, p.handle handle, to_char(l.first_time,'DD-MON-YYYY HH24:MI:SS')
from v$backup_piece p, v$backup_redolog r, v$log_history l
where r.set_stamp = p.set_stamp
and r.set_count = p.set_count
and l.sequence# = r.sequence#
and l.sequence# = 140581
order by 1;
===============
ed open_Cursor_Check
col hwm_open_cur format 99,999
col max_open_cur format 99,999
select
max(a.value) as hwm_open_cur,
p.value as max_open_cur
from
v$sesstat a,
v$statname b,
v$parameter p
where
a.statistic# = b.statistic#
and
b.name = 'opened cursors current'
and
p.name= 'open_cursors'
group by p.value;
===============
ed logswitch
set linesize 112
set pagesize 100
column day format a15 heading ' Day'
column d_0 format a3 heading ' 00'
column d_1 format a3 heading ' 01'
column d_2 format a3 heading ' 02'
column d_3 format a3 heading ' 03'
column d_4 format a3 heading ' 04'
column d_5 format a3 heading ' 05'
column d_6 format a3 heading ' 06'
column d_7 format a3 heading ' 07'
column d_8 format a3 heading ' 08'
column d_9 format a3 heading ' 09'
column d_10 format a3 heading ' 10'
column d_11 format a3 heading ' 11'
column d_12 format a3 heading ' 12'
column d_13 format a3 heading ' 13'
column d_14 format a3 heading ' 14'
column d_15 format a3 heading ' 15'
column d_16 format a3 heading ' 16'
column d_17 format a3 heading ' 17'
column d_18 format a3 heading ' 18'
column d_19 format a3 heading ' 19'
column d_20 format a3 heading ' 20'
column d_21 format a3 heading ' 21'
column d_22 format a3 heading ' 22'
column d_23 format a3 heading ' 23'
select
substr(to_char(FIRST_TIME,'YYYY/MM/DD, DY'),1,15) day,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'00',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'00',1,0))) d_0,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'01',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'01',1,0))) d_1,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'02',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'02',1,0))) d_2,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'03',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'03',1,0))) d_3,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'04',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'04',1,0))) d_4,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'05',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'05',1,0))) d_5,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'06',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'06',1,0))) d_6,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'07',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'07',1,0))) d_7,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'08',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'08',1,0))) d_8,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'09',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'09',1,0))) d_9,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'10',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'10',1,0))) d_10,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'11',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'11',1,0))) d_11,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'12',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'12',1,0))) d_12,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'13',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'13',1,0))) d_13,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'14',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'14',1,0))) d_14,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'15',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'15',1,0))) d_15,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'16',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'16',1,0))) d_16,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'17',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'17',1,0))) d_17,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'18',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'18',1,0))) d_18,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'19',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'19',1,0))) d_19,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'20',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'20',1,0))) d_20,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'21',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'21',1,0))) d_21,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'22',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'22',1,0))) d_22,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'23',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'23',1,0))) d_23
from
gv$log_history
where
FIRST_TIME >= sysdate - 15
group by
substr(to_char(FIRST_TIME,'YYYY/MM/DD, DY'),1,15)
order by
substr(to_char(FIRST_TIME,'YYYY/MM/DD, DY'),1,15) desc;
set linesize 150
set pagesize 9999
clear columns
OI@4c3ss.13
W3lc0m3.oi@13
=========
ed rmanbackup
set lines 999
set pages 200
column START_TIME format a30;
column END_TIME format a30;
column INPUT_BYTES for 999999999999
select *
from (select to_char(START_TIME,'DD-MON-YYYY:HH24:MI:SS') START_TIME,to_char(END_TIME,'DD-MON-YYYY:HH24:MI:SS') END_TIME,
ELAPSED_SECONDS/60 ELAPSED_MINS,INPUT_TYPE,OUTPUT_DEVICE_TYPE,STATUS,TRUNC(START_TIME) BKP_DATE, INPUT_BYTES/1024/1024 I_MB , OUTPUT_BYTES/1024/1024 O_MB
from V$RMAN_BACKUP_JOB_DETAILS order by BKP_DATE desc)
where rownum <25 --0 and INPUT_TYPE like '%INCR%'
order by BKP_DATE desc;
set lines 999
column START_TIME format a30;
column END_TIME format a30;
column INPUT_BYTES for 999999999999
select *
from (select to_char(START_TIME,'DD-MON-YYYY:HH24:MI:SS') START_TIME,to_char(END_TIME,'DD-MON-YYYY:HH24:MI:SS') END_TIME,
ELAPSED_SECONDS/60 ELAPSED_MINS,INPUT_TYPE,OUTPUT_DEVICE_TYPE,STATUS,TRUNC(START_TIME) BKP_DATE, INPUT_BYTES/1024/1024 I_MB , OUTPUT_BYTES/1024/1024 O_MB
from V$RMAN_BACKUP_JOB_DETAILS where start_time like sysdate order by BKP_DATE desc)
where rownum <25
order by 1 desc;
set lines 999
column START_TIME format a30;
column END_TIME format a30;
column INPUT_BYTES for 999999999999
select *
from (select to_char(START_TIME,'DD-MON-YYYY:HH24:MI:SS') START_TIME,to_char(END_TIME,'DD-MON-YYYY:HH24:MI:SS') END_TIME,
ELAPSED_SECONDS/60 ELAPSED_MINS,INPUT_TYPE,OUTPUT_DEVICE_TYPE,STATUS,TRUNC(START_TIME) BKP_DATE, INPUT_BYTES/1024/1024 I_MB , OUTPUT_BYTES/1024/1024 O_MB
from V$RMAN_BACKUP_JOB_DETAILS order by BKP_DATE desc)
where rownum <= 25
order by BKP_DATE;
Darpan - ITO DBA:
SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo01.log'' TO ''?/oradata/test/redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo02.log'' TO ''?/oradata/test/redo02.log'' ";
Darpan - ITO DBA: https://www.rooms.hp.com/attend/default.aspx?key=RPQ9YJJMDF
----- 1/16/14 12:17 AM -----
Darpan - ITO DBA: SQL> col media for a15
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YY HH24:MI';
Session altered.
select b.media, b.db_key,' ', b.tag, b.start_time,' ', b.completion_time
from bp b, rc_database r
where start_time > '11-JAN-14 23:30' and completion_time < '12-JAN-14 2:00'
and b.db_key=r.db_key
--and r.dbid=2724273581
order by 1;
=========
ed rmantape ----- PERFECT rr
set lines 200
set pages 9999
col PKEY for 9999999
col BACKUP_TYPE for a20
col STATUS for a10
col FNAME for a45
col TAG for a30
Col MEDIA for a15
col Complete for a20
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME,OBSOLETE, TAG, MEDIA,to_char(COMPLETION_TIME,'dd-mm-yyyy hh24:mi:ss') Complete FROM V$BACKUP_FILES
WHERE COMPLETION_TIME between sysdate - 60 and sysdate
AND BACKUP_TYPE <> 'COPY'
--and FNAME like '%lvl%'
order by completion_time;
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME,OBSOLETE, TAG, MEDIA,to_char(COMPLETION_TIME,'dd-mm-yyyy hh24:mi:ss') Complete FROM V$BACKUP_FILES
WHERE COMPLETION_TIME between sysdate - 30 and sysdate
AND BACKUP_TYPE <> 'COPY'
--and FNAME like '%lvl%'
order by completion_time;
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME,OBSOLETE, TAG, MEDIA,to_char(COMPLETION_TIME,'dd-mm-yyyy hh24:mi:ss') Complete FROM V$BACKUP_FILES
WHERE COMPLETION_TIME like (sysdate - 4)
order by completion_time;
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME, TAG, MEDIA,to_char(COMPLETION_TIME,'dd-mm-yyyy hh24:mi:ss') Complete FROM V$BACKUP_FILES
WHERE TO_CHAR(COMPLETION_TIME,'YYYY-MM-DD') = '2014-01-12'
and FNAME like '%arch%'
order by completion_time;
SELECT PKEY, BACKUP_TYPE, STATUS, FNAME FNAME, TAG, MEDIA FROM V$BACKUP_FILES
WHERE TO_CHAR(COMPLETION_TIME,'YYYY-MM-DD') = '2014-01-12'
and FNAME like '%arch%'
order by media;
143260 BACKUP SET AVAILABLE P44_ustlsoi010_arch_<P44_al_ncat_t836692211_s190946_p1>.bak TAG20140112T223011 70553
===695147
=========
ed lockholder
set lines 1000
SELECT /*+ rule */
DECODE(request,
0,
'Holder: ',
'Waiter: ')||sid sess,
type,
INST_ID,
id1,
id2,
lmode,
request,
ctime,
block
FROM
gv$lock
WHERE
(id1, id2, type) IN
(SELECT id1, id2, type FROM gv$lock WHERE request >0)
and lmode=6
ORDER BY id1, request
/
=======
ed rmanstatus
set line 300
SELECT SID, SERIAL#, CONTEXT,opname, SOFAR, TOTALWORK,
ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE"
FROM V$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%'
AND OPNAME NOT LIKE '%rman%'
AND TOTALWORK != 0
AND SOFAR <> TOTALWORK;
========
ed order
set serveroutput on size 50000
set echo off feed off veri off
accept SID prompt 'Enter Oracle SID: '
DECLARE
v_sid number;
s sys.v_$session%ROWTYPE;
p sys.v_$process%ROWTYPE;
BEGIN
begin
select sid into v_sid
from sys.v_$session s
where sid = &&SID;
exception
when no_data_found then
dbms_output.put_line('Unable to find SID &&SID!!!');
return;
when others then
dbms_output.put_line(sqlerrm||'naaaaaaaaaaaaaaaaaaaaa');
return;
end;
select * into s from sys.v_$session where sid = v_sid;
select * into p from sys.v_$process where addr = s.paddr;
dbms_output.put_line('=====================================================================');
dbms_output.put_line('SID/Serial : '|| s.sid||','||s.serial#);
dbms_output.put_line('Foreground : '|| 'PID: '||s.process||' - '||s.program);
dbms_output.put_line('Shadow : '|| 'PID: '||p.spid||' - '||p.program);
dbms_output.put_line('Terminal : '|| s.terminal || '/ ' || p.terminal);
dbms_output.put_line('OS User : '|| s.osuser||' on '||s.machine);
dbms_output.put_line('Ora User : '|| s.username);
dbms_output.put_line('Status Flags: '|| s.status||' '||s.server||' '||s.type);
dbms_output.put_line('Tran Active : '|| nvl(s.taddr, 'NONE'));
dbms_output.put_line('Login Time : '|| to_char(s.logon_time, 'Dy HH24:MI:SS'));
dbms_output.put_line('Last Call : '|| to_char(sysdate-(s.last_call_et/60/60/24), 'Dy HH24:MI:SS') || ' - ' || to_char(s.last_call_et/60, '9999999999.0') || ' min');
dbms_output.put_line('Lock/ Latch : '|| nvl(s.lockwait, 'NONE')||'/ '||nvl(p.latchwait, 'NONE'));
dbms_output.put_line('Latch Spin : '|| nvl(p.latchspin, 'NONE'));
dbms_output.put_line('Current SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.sql_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Previous SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.prev_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Session Waits:');
for c1 in ( select * from sys.v_$session_wait where sid = s.sid) loop
dbms_output.put_line(chr(9)||c1.state||': '||c1.event);
end loop;
dbms_output.put_line('Connect Info:');
for c1 in ( select * from sys.v_$session_connect_info where sid = s.sid) loop
dbms_output.put_line(chr(9)||': '||c1.network_service_banner);
end loop;
dbms_output.put_line('Locks:');
for c1 in ( select
decode(l.type,
-- Long locks
'TM', 'DML/DATA ENQ', 'TX', 'TRANSAC ENQ',
'UL', 'PLS USR LOCK',
-- Short locks
'BL', 'BUF HASH TBL', 'CF', 'CONTROL FILE',
'CI', 'CROSS INST F', 'DF', 'DATA FILE ',
'CU', 'CURSOR BIND ',
'DL', 'DIRECT LOAD ', 'DM', 'MOUNT/STRTUP',
'DR', 'RECO LOCK ', 'DX', 'DISTRIB TRAN',
'FS', 'FILE SET ', 'IN', 'INSTANCE NUM',
'FI', 'SGA OPN FILE',
'IR', 'INSTCE RECVR', 'IS', 'GET STATE ',
'IV', 'LIBCACHE INV', 'KK', 'LOG SW KICK ',
'LS', 'LOG SWITCH ',
'MM', 'MOUNT DEF ', 'MR', 'MEDIA RECVRY',
'PF', 'PWFILE ENQ ', 'PR', 'PROCESS STRT',
'RT', 'REDO THREAD ', 'SC', 'SCN ENQ ',
'RW', 'ROW WAIT ',
'SM', 'SMON LOCK ', 'SN', 'SEQNO INSTCE',
'SQ', 'SEQNO ENQ ', 'ST', 'SPACE TRANSC',
'SV', 'SEQNO VALUE ', 'TA', 'GENERIC ENQ ',
'TD', 'DLL ENQ ', 'TE', 'EXTEND SEG ',
'TS', 'TEMP SEGMENT', 'TT', 'TEMP TABLE ',
'UN', 'USER NAME ', 'WL', 'WRITE REDO ',
'TYPE='||l.type) type,
decode(l.lmode, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
4, 'S', 5, 'RSX', 6, 'X',
to_char(l.lmode) ) lmode,
decode(l.request, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
4, 'S', 5, 'RSX', 6, 'X',
to_char(l.request) ) lrequest,
decode(l.type, 'MR', o.object_name,
'TD', o.object_name,
'TM', o.object_name,
'RW', 'FILE#='||substr(l.id1,1,3)||
' BLOCK#='||substr(l.id1,4,5)||' ROW='||l.id2,
'TX', 'RS+SLOT#'||l.id1||' WRP#'||l.id2,
'WL', 'REDO LOG FILE#='||l.id1,
'RT', 'THREAD='||l.id1,
'TS', decode(l.id2, 0, 'ENQUEUE', 'NEW BLOCK ALLOCATION'),
'ID1='||l.id1||' ID2='||l.id2) objname
from sys.v_$lock l, dba_objects o
where sid = s.sid
and l.id1 = o.object_id(+) ) loop
dbms_output.put_line(chr(9)||c1.type||' H: '||c1.lmode||' R: '||c1.lrequest||' - '||c1.objname);
end loop;
dbms_output.put_line('=====================================================================');
END;
/
undef SID
===========
====== MPHASIS 19/09/2013 ======
Create HP_DBSPI User for DBMON DB Monitoring
set verify off;
whenever sqlerror CONTINUE
create user hp_dbspi. identified by "hp_dbspi"
default tablespace temp
temporary tablespace temp;
grant create session to hp_dbspi;
grant select on DBA_2PC_NEIGHBORS to hp_dbspi;
grant select on DBA_2PC_PENDING to hp_dbspi;
grant select on DBA_ANALYZE_OBJECTS to hp_dbspi;
grant select on DBA_AUDIT_EXISTS to hp_dbspi;
grant select on DBA_AUDIT_OBJECT to hp_dbspi;
grant select on DBA_AUDIT_SESSION to hp_dbspi;
grant select on DBA_AUDIT_STATEMENT to hp_dbspi;
grant select on DBA_AUDIT_TRAIL to hp_dbspi;
grant select on DBA_CATALOG to hp_dbspi;
grant select on DBA_CLU_COLUMNS to hp_dbspi;
grant select on DBA_CLUSTER_HASH_EXPRESSIONS to hp_dbspi;
grant select on DBA_CLUSTERS to hp_dbspi;
grant select on DBA_COL_COMMENTS to hp_dbspi;
grant select on DBA_COL_PRIVS to hp_dbspi;
grant select on DBA_COLL_TYPES to hp_dbspi;
grant select on DBA_CONS_COLUMNS to hp_dbspi;
grant select on DBA_CONSTRAINTS to hp_dbspi;
grant select on DBA_DATA_FILES to hp_dbspi;
grant select on DBA_DB_LINKS to hp_dbspi;
grant select on DBA_DEPENDENCIES to hp_dbspi;
grant select on DBA_DIRECTORIES to hp_dbspi;
grant select on DBA_ERRORS to hp_dbspi;
grant select on DBA_EXP_FILES to hp_dbspi;
grant select on DBA_EXP_OBJECTS to hp_dbspi;
grant select on DBA_EXP_VERSION to hp_dbspi;
grant select on DBA_EXTENTS to hp_dbspi;
grant select on DBA_FREE_SPACE to hp_dbspi;
grant select on DBA_FREE_SPACE_COALESCED to hp_dbspi;
grant select on DBA_FREE_SPACE_COALESCED_TMP1 to hp_dbspi;
grant select on DBA_FREE_SPACE_COALESCED_TMP2 to hp_dbspi;
grant select on DBA_HISTOGRAMS to hp_dbspi;
grant select on DBA_IND_COLUMNS to hp_dbspi;
grant select on DBA_IND_PARTITIONS to hp_dbspi;
grant select on DBA_INDEXES to hp_dbspi;
grant select on DBA_JOBS to hp_dbspi;
grant select on DBA_JOBS_RUNNING to hp_dbspi;
grant select on DBA_LIBRARIES to hp_dbspi;
grant select on DBA_LOBS to hp_dbspi;
grant select on DBA_METHOD_PARAMS to hp_dbspi;
grant select on DBA_METHOD_RESULTS to hp_dbspi;
grant select on DBA_MVIEWS to hp_dbspi;
grant select on DBA_NESTED_TABLES to hp_dbspi;
grant select on DBA_OBJ_AUDIT_OPTS to hp_dbspi;
grant select on DBA_OBJECT_SIZE to hp_dbspi;
grant select on DBA_OBJECT_TABLES to hp_dbspi;
grant select on DBA_OBJECTS to hp_dbspi;
grant select on DBA_PART_COL_STATISTICS to hp_dbspi;
grant select on DBA_PART_HISTOGRAMS to hp_dbspi;
grant select on DBA_PART_INDEXES to hp_dbspi;
grant select on DBA_PART_KEY_COLUMNS to hp_dbspi;
grant select on DBA_PART_TABLES to hp_dbspi;
grant select on DBA_PENDING_TRANSACTIONS to hp_dbspi;
grant select on DBA_PRIV_AUDIT_OPTS to hp_dbspi;
grant select on DBA_PROFILES to hp_dbspi;
grant select on DBA_QUEUE_SCHEDULES to hp_dbspi;
grant select on DBA_QUEUE_TABLES to hp_dbspi;
grant select on DBA_QUEUES to hp_dbspi;
grant select on DBA_RCHILD to hp_dbspi;
grant select on DBA_REFRESH to hp_dbspi;
grant select on DBA_REFRESH_CHILDREN to hp_dbspi;
grant select on DBA_REFS to hp_dbspi;
grant select on DBA_REGISTERED_SNAPSHOTS to hp_dbspi;
grant select on DBA_REPCATLOG to hp_dbspi;
grant select on DBA_RESUMABLE to hp_dbspi;
grant select on DBA_RGROUP to hp_dbspi;
grant select on DBA_ROLE_PRIVS to hp_dbspi;
grant select on DBA_ROLES to hp_dbspi;
grant select on DBA_ROLLBACK_SEGS to hp_dbspi;
grant select on DBA_SEGMENTS to hp_dbspi;
grant select on DBA_SEQUENCES to hp_dbspi;
grant select on DBA_SNAPSHOT_LOG_FILTER_COLS to hp_dbspi;
grant select on DBA_SNAPSHOT_LOGS to hp_dbspi;
grant select on DBA_SNAPSHOT_REFRESH_TIMES to hp_dbspi;
grant select on DBA_SNAPSHOTS to hp_dbspi;
grant select on DBA_SOURCE to hp_dbspi;
grant select on DBA_STMT_AUDIT_OPTS to hp_dbspi;
grant select on DBA_SYNONYMS to hp_dbspi;
grant select on DBA_SYS_PRIVS to hp_dbspi;
grant select on DBA_TAB_COL_STATISTICS to hp_dbspi;
grant select on DBA_TAB_COLUMNS to hp_dbspi;
grant select on DBA_TAB_COMMENTS to hp_dbspi;
grant select on DBA_TAB_HISTOGRAMS to hp_dbspi;
grant select on DBA_TAB_PARTITIONS to hp_dbspi;
grant select on DBA_TAB_PRIVS to hp_dbspi;
grant select on DBA_TABLES to hp_dbspi;
grant select on DBA_TABLESPACES to hp_dbspi;
grant select on DBA_TRIGGER_COLS to hp_dbspi;
grant select on DBA_TRIGGERS to hp_dbspi;
grant select on DBA_TS_QUOTAS to hp_dbspi;
grant select on DBA_TYPE_ATTRS to hp_dbspi;
grant select on DBA_TYPE_METHODS to hp_dbspi;
grant select on DBA_TYPES to hp_dbspi;
grant select on DBA_UPDATABLE_COLUMNS to hp_dbspi;
grant select on DBA_USERS to hp_dbspi;
grant select on DBA_VIEWS to hp_dbspi;
grant select on FILEXT$ to hp_dbspi;
grant select on SYS.DEFTRAN to hp_dbspi;
grant select on SYS.DEFERROR to hp_dbspi;
grant select on SYS.FET$ to hp_dbspi;
grant select on SYS.FILE$ to hp_dbspi;
grant select on SYS.FILEXT$ to hp_dbspi;
grant select on SYS.OBJ$ to hp_dbspi;
grant select on SYS.SEG$ to hp_dbspi;
grant select on SYS.SYS_DBA_SEGS to hp_dbspi;
grant select on SYS.SYS_OBJECTS to hp_dbspi;
grant select on SYS.TS$ to hp_dbspi;
grant select on SYS.UNDO$ to hp_dbspi;
grant select on SYS.USER$ to hp_dbspi;
grant execute on SYS.DBMS_SPACE_ADMIN to hp_dbspi;
grant select on V_$_LOCK to hp_dbspi;
grant select on V_$ACCESS to hp_dbspi;
grant select on V_$ACTIVE_INSTANCES to hp_dbspi;
grant select on V_$AQ1 to hp_dbspi;
grant select on V_$ARCHIVE to hp_dbspi;
grant select on V_$ARCHIVE_DEST to hp_dbspi;
grant select on V_$ARCHIVED_LOG to hp_dbspi;
grant select on V_$BACKUP to hp_dbspi;
grant select on V_$BACKUP_CORRUPTION to hp_dbspi;
grant select on V_$BACKUP_DATAFILE to hp_dbspi;
grant select on V_$BACKUP_DEVICE to hp_dbspi;
grant select on V_$BACKUP_PIECE to hp_dbspi;
grant select on V_$BACKUP_REDOLOG to hp_dbspi;
grant select on V_$BACKUP_SET to hp_dbspi;
grant select on V_$BGPROCESS to hp_dbspi;
grant select on V_$BH to hp_dbspi;
grant select on V_$BUFFER_POOL to hp_dbspi;
grant select on V_$CIRCUIT to hp_dbspi;
grant select on V_$CLASS_PING to hp_dbspi;
grant select on V_$COMPATIBILITY to hp_dbspi;
grant select on V_$COMPATSEG to hp_dbspi;
grant select on V_$CONTROLFILE to hp_dbspi;
grant select on V_$CONTROLFILE_RECORD_SECTION to hp_dbspi;
grant select on V_$COPY_CORRUPTION to hp_dbspi;
grant select on V_$CURRENT_BUCKET to hp_dbspi;
grant select on V_$DATABASE to hp_dbspi;
grant select on V_$DATAFILE to hp_dbspi;
grant select on V_$DATAFILE_COPY to hp_dbspi;
grant select on V_$DATAFILE_HEADER to hp_dbspi;
grant select on V_$DB_OBJECT_CACHE to hp_dbspi;
grant select on V_$DB_PIPES to hp_dbspi;
grant select on V_$DBFILE to hp_dbspi;
grant select on V_$DBLINK to hp_dbspi;
grant select on V_$DELETED_OBJECT to hp_dbspi;
grant select on V_$DISPATCHER to hp_dbspi;
grant select on V_$DISPATCHER_RATE to hp_dbspi;
grant select on V_$DLM_CONVERT_LOCAL to hp_dbspi;
grant select on V_$DLM_CONVERT_REMOTE to hp_dbspi;
grant select on V_$DLM_LATCH to hp_dbspi;
grant select on V_$DLM_LOCKS to hp_dbspi;
grant select on V_$DLM_MISC to hp_dbspi;
grant select on V_$ENABLEDPRIVS to hp_dbspi;
grant select on V_$ENQUEUE_LOCK to hp_dbspi;
grant select on V_$EVENT_NAME to hp_dbspi;
grant select on V_$EXECUTION to hp_dbspi;
grant select on V_$FILE_PING to hp_dbspi;
grant select on V_$FILESTAT to hp_dbspi;
grant select on V_$FIXED_TABLE to hp_dbspi;
grant select on V_$FIXED_VIEW_DEFINITION to hp_dbspi;
grant select on V_$GLOBAL_TRANSACTION to hp_dbspi;
grant select on V_$INDEXED_FIXED_COLUMN to hp_dbspi;
grant select on V_$INSTANCE to hp_dbspi;
grant select on V_$LATCH to hp_dbspi;
grant select on V_$LATCH_CHILDREN to hp_dbspi;
grant select on V_$LATCH_MISSES to hp_dbspi;
grant select on V_$LATCH_PARENT to hp_dbspi;
grant select on V_$LATCHHOLDER to hp_dbspi;
grant select on V_$LATCHNAME to hp_dbspi;
grant select on V_$LIBRARYCACHE to hp_dbspi;
grant select on V_$LICENSE to hp_dbspi;
grant select on V_$LOADCSTAT to hp_dbspi;
grant select on V_$LOADPSTAT to hp_dbspi;
grant select on V_$LOADTSTAT to hp_dbspi;
grant select on V_$LOCK to hp_dbspi;
grant select on V_$LOCK_ACTIVITY to hp_dbspi;
grant select on V_$LOCK_ELEMENT to hp_dbspi;
grant select on V_$LOCKED_OBJECT to hp_dbspi;
grant select on V_$LOCKS_WITH_COLLISIONS to hp_dbspi;
grant select on V_$LOG to hp_dbspi;
grant select on V_$LOG_HISTORY to hp_dbspi;
grant select on V_$LOGFILE to hp_dbspi;
grant select on V_$LOGHIST to hp_dbspi;
grant select on V_$MTS to hp_dbspi;
grant select on V_$SHARED_SERVER_MONITOR to hp_dbspi;
grant select on V_$MYSTAT to hp_dbspi;
grant select on V_$NLS_PARAMETERS to hp_dbspi;
grant select on V_$NLS_VALID_VALUES to hp_dbspi;
grant select on V_$OBJECT_DEPENDENCY to hp_dbspi;
grant select on V_$OFFLINE_RANGE to hp_dbspi;
grant select on V_$OPEN_CURSOR to hp_dbspi;
grant select on V_$OPTION to hp_dbspi;
grant select on V_$PARAMETER to hp_dbspi;
grant select on V_$PQ_SESSTAT to hp_dbspi;
grant select on V_$PQ_SLAVE to hp_dbspi;
grant select on V_$PQ_SYSSTAT to hp_dbspi;
grant select on V_$PQ_TQSTAT to hp_dbspi;
grant select on V_$PROCESS to hp_dbspi;
grant select on V_$PWFILE_USERS to hp_dbspi;
grant select on V_$QUEUE to hp_dbspi;
grant select on V_$RECENT_BUCKET to hp_dbspi;
grant select on V_$RECOVER_FILE to hp_dbspi;
grant select on V_$RECOVERY_FILE_STATUS to hp_dbspi;
grant select on V_$RECOVERY_LOG to hp_dbspi;
grant select on V_$RECOVERY_PROGRESS to hp_dbspi;
grant select on V_$RECOVERY_STATUS to hp_dbspi;
grant select on V_$REQDIST to hp_dbspi;
grant select on V_$RESOURCE to hp_dbspi;
grant select on V_$RESOURCE_LIMIT to hp_dbspi;
grant select on V_$ROLLSTAT to hp_dbspi;
grant select on V_$ROWCACHE to hp_dbspi;
grant select on V_$ROWCACHE_PARENT to hp_dbspi;
grant select on V_$ROWCACHE_SUBORDINATE to hp_dbspi;
grant select on V_$SESS_IO to hp_dbspi;
grant select on V_$SESSION to hp_dbspi;
grant select on V_$SESSION_CONNECT_INFO to hp_dbspi;
grant select on V_$SESSION_CURSOR_CACHE to hp_dbspi;
grant select on V_$SESSION_EVENT to hp_dbspi;
grant select on V_$SESSION_LONGOPS to hp_dbspi;
grant select on V_$SESSION_OBJECT_CACHE to hp_dbspi;
grant select on V_$SESSION_WAIT to hp_dbspi;
grant select on V_$SESSTAT to hp_dbspi;
grant select on V_$SGA to hp_dbspi;
grant select on V_$SGASTAT to hp_dbspi;
grant select on V_$SGA_DYNAMIC_COMPONENTS to hp_dbspi;
grant select on V_$SHARED_POOL_RESERVED to hp_dbspi;
grant select on V_$SHARED_SERVER to hp_dbspi;
grant select on V_$SORT_SEGMENT to hp_dbspi;
grant select on V_$SORT_USAGE to hp_dbspi;
grant select on V_$SQL to hp_dbspi;
grant select on V_$SQL_BIND_DATA to hp_dbspi;
grant select on V_$SQL_BIND_METADATA to hp_dbspi;
grant select on V_$SQL_CURSOR to hp_dbspi;
grant select on V_$SQL_SHARED_MEMORY to hp_dbspi;
grant select on V_$SQLAREA to hp_dbspi;
grant select on V_$SQL_PLAN to hp_dbspi;
grant select on V_$SQLTEXT to hp_dbspi;
grant select on V_$SQLTEXT_WITH_NEWLINES to hp_dbspi;
grant select on V_$STATNAME to hp_dbspi;
grant select on V_$SUBCACHE to hp_dbspi;
grant select on V_$SYSSTAT to hp_dbspi;
grant select on V_$SYSTEM_CURSOR_CACHE to hp_dbspi;
grant select on V_$SYSTEM_EVENT to hp_dbspi;
grant select on V_$SYSTEM_PARAMETER to hp_dbspi;
grant select on V_$TABLESPACE to hp_dbspi;
grant select on V_$THREAD to hp_dbspi;
grant select on V_$TIMER to hp_dbspi;
grant select on V_$TRANSACTION to hp_dbspi;
grant select on V_$TRANSACTION_ENQUEUE to hp_dbspi;
grant select on V_$TYPE_SIZE to hp_dbspi;
grant select on V_$VERSION to hp_dbspi;
grant select on V_$WAITSTAT to hp_dbspi;
grant select on V$ROLLNAME to hp_dbspi;
grant select on GV_$INSTANCE to hp_dbspi;
grant select on V_$ROLLNAME to hp_dbspi;
grant select on V_$TEMPFILE to hp_dbspi;
grant select on GV_$SYSSTAT to hp_dbspi;
grant select on V_$FILE_CACHE_TRANSFER to hp_dbspi;
grant select on GV_$ARCHIVED_LOG to hp_dbspi;
grant select on V_$ARCHIVED_LOG to hp_dbspi;
grant select on GV_$ARCHIVE_DEST to hp_dbspi;
grant select on V_$ARCHIVE_DEST to hp_dbspi;
grant select on DBA_LOGSTDBY_PROGRESS to hp_dbspi;
grant select on DBA_LOGSTDBY_LOG to hp_dbspi;
grant select on V_$DATABASE to hp_dbspi;
grant select on V_$ARCHIVE_DEST_STATUS to hp_dbspi;
grant select on V_$RECOVERY_FILE_DEST to hp_dbspi;
grant select on SYS.DEFTRAN to hp_dbspi;
grant select on SYS.DEFERROR to hp_dbspi;
grant select on SYS.DBA_REPCATLOG to hp_dbspi;
grant select on V_$STREAMS_POOL_ADVICE to hp_dbspi;
grant select on DBA_CAPTURE to hp_dbspi;
grant select on DBA_PROPAGATION to hp_dbspi;
grant select on DBA_APPLY to hp_dbspi;
grant select on DBA_APPLY_ERROR to hp_dbspi;
grant select on DBA_APPLY_PROGRESS to hp_dbspi;
exit;
HomeOracle 11gR2RAC ScenariosVirtualBoxAbout MeB.N.A.I.R 's Oracle blog
Stay updated via RSS
--------------------------------------------------------------------------------
Recent PostsOracle APPS Patching
Oracle APPLICATIONS R12 Installation
RMAN – Tablespace Point-In-Time Recovery
Managing 11gR1 Grid Control – Commands, Log files & Directory Structure
Oracle 11gR1 Enterprise Manager Grid Control (OEM) Installation – Part 3
Oracle 11gR1 Enterprise Manager Grid Control (OEM) Installation – Part 2
Oracle 11gR1 Enterprise Manager Grid Control (OEM) Installation – Part 1
DNS Configuration for 11gR2 SCAN & VIP
crsctl start crs Vs start cluster
11gR2 Modify / Add Scan IP & Listeners
Clusterware Startup Sequence
Replace / Migrate OCR
Create shared disks in Virtualbox
Replace / Migrate Voting Disk
Oracle 11gR2 RAC on VirtualBox with Role Seperation (grid & oracle)
11gR2 DataGuard Build on Oracle Restart [With data guard Broker setup]
Install 11gR2 Oracle Restart (Grid Infrastructure for Standalone) on Centos 5.5 with role seperation
CategoriesOracle 11gR2
Oracle Apps DBA
RAC Scenarios
RMAN
VirtualBox
February 2011 M T W T F S S
« Jan Mar »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28
11gR2 Modify / Add Scan IP & ListenersPosted: Saturday in Oracle 11gR2
011gR2
The current configuration of SCAN is 1 IP address (192.168.2.201) defined in /etc/hosts file.
Aim is to re-configure SCAN using the 3 new IP addresses defined through DNS. New IPs addresses are 192.168.2.121, 192.168.2.122 and 192.168.2.123
The current SCAN name, ‘rac-scan’ will not be changed and the three new IPs are in the same subnet as before.However, if your changes include SCAN name change and/or new IPs in different subnet, procedure to tackle these are mentioned towards the end of this post.
Configuring DNS is not explained here. That’ll be posted as a separate topic.
Step 1: Current Configuration
From Node 1
[grid@rac1 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac2
[grid@rac1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac2
[grid@rac1 ~]$ srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.2.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /rac-scan.localdomain/192.168.2.201
[grid@rac1 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
[grid@rac1 ~]$ more /etc/hosts
# Public
192.168.2.101 rac1.localdomain rac1
192.168.2.102 rac2.localdomain rac2
# Private
192.168.0.101 rac1-priv.localdomain rac1-priv
192.168.0.102 rac2-priv.localdomain rac2-priv
# Virtual
192.168.2.111 rac1-vip.localdomain rac1-vip
192.168.2.112 rac2-vip.localdomain rac2-vip
# SCAN
192.168.2.201 rac-scan.localdomain rac-scan
[grid@rac1 ~]$
Validating SCAN on second Node
[grid@rac2 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac2
[grid@rac2 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac2
[grid@rac2 ~]$ srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.2.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /rac-scan.localdomain/192.168.2.201
[grid@rac2 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
Step 2: Stop SCAN and SCAN_LISTENER
As Root
[grid@rac1 ~]$ srvctl stop scan_listener
[grid@rac1 ~]$ srvctl stop scan
[grid@rac1 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is not running
[grid@rac1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
[grid@rac1 ~]$ srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.2.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /rac-scan.localdomain/192.168.2.201
[grid@rac1 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
[grid@rac1 ~]$
Step 3: Update /etc/hosts and enable DNS
At this point, I removed the entries for VIP and SCAN from /etc/hosts file. Then I started DNS service and verified using nslookup that the 2 IPs for VIP and 3 new IPs for SCAN are working properly.
Step 4: Modify / Change SCAN
As ROOT
[root@rac1 ~]# srvctl modify scan -n rac-scan
[root@rac1 ~]# srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.2.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /rac-scan.localdomain/192.168.2.121
SCAN VIP name: scan2, IP: /rac-scan.localdomain/192.168.2.122
SCAN VIP name: scan3, IP: /rac-scan.localdomain/192.168.2.123
[root@rac1 ~]# srvctl modify scan_listener –u
[root@rac1 ~]# srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521
Step 5: Restarting SCAN and SCAN_LISTENER
As ROOT
[root@rac1 ~]# srvctl start scan
[root@rac1 ~]# srvctl start scan_listener
Step 6: Validate
[root@rac1 ~]# srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac2
SCAN VIP scan2 is enabled
SCAN VIP scan2 is running on node rac1
SCAN VIP scan3 is enabled
SCAN VIP scan3 is running on node rac1
[root@rac1 ~]# srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac2
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node rac1
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node rac1
Listener.ora
Instance 1
[root@rac1 admin]# more $GRID_HOME/network/admin/listener.ora
LISTENER_SCAN3=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN3)))) # line added by Agent
LISTENER_SCAN2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN2)))) # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN2=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN3=ON # line added by Agent
Instance 2
[root@rac2 admin]# more $GRID_HOME/network/admin/listener.ora
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
----------------------------------------------------------------------------
Change SCAN name or new IPs on different subnet?
If you intend to change SCAN name, for 11.2.0.1 as root execute:
# $GRID_HOME/bin/crsctl modify type ora.scan_vip.type -attr "ATTRIBUTE=SCAN_NAME,DEFAULT_VALUE=<new SCAN name>"
Example:
# $GRID_HOME/bin/crsctl modify type ora.scan_vip.type -attr "ATTRIBUTE=SCAN_NAME,DEFAULT_VALUE=rac-scan"
Note: if you modified SCAN name, make sure to update database init.ora parameter remote_listener as well.
If new SCAN IPs are in a different subnet, as root execute:
# $GRID_HOME/bin/crsctl modify resource ora.net1.network -attr "USR_ORA_SUBNET=<new subnet id>"
# $GRID_HOME/bin/crsctl modify resource ora.net1.network -attr "USR_ORA_NETMASK=<new subnet mask>"
Example:
# $GRID_HOME/bin/crsctl modify resource ora.net1.network -attr "USR_ORA_SUBNET=10.2.1.0"
# $GRID_HOME/bin/crsctl modify resource ora.net1.network -attr "USR_ORA_NETMASK=255.255.255.0"
Then Update and start
$ $GRID_HOME/bin/srvctl modify scan_listener -u
$ $GRID_HOME/bin/srvctl start scan_listener
About these ads
Like this:
Like Loading...RelatedDNS Configuration for 11gR2 SCAN & VIP
In "Oracle 11gR2"
Replace / Migrate OCR
In "Oracle 11gR2"
crsctl start crs Vs start cluster
In "Oracle 11gR2"
Leave a Reply Cancel reply
Enter your comment here...
Fill in your details below or click an icon to log in:
Email (required) (Address never made public) Name (required) Website You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
CancelConnecting to %s
Notify me of follow-up comments via email.
.Clusterware Startup Sequencecrsctl start crs Vs start cluster
--------------------------------------------------------------------------------
Blog at WordPress.com. | The Greyzed Theme. Follow
Follow “B.N.A.I.R 's Oracle blog”
Get every new post delivered to your Inbox.
Powered by WordPress.com%d bloggers like this:
===== ISSUES Worked on:
1. ASYNC Descriptor , for RMAN Backup Slowness : We changed ASYNC_IO Parameter to true so that it wil not check the blocks, It Will keep on taking backup
2. High CPU Utilizaion , Foud with My Query on QUERY Utilizing high CPU & done the needfull
2. NODE 2 was down, So Copied BIN Folder from NODE 1 & CReated scripts to change the hostname in all the readable files & NODE came UP
3. RAC Installation time, resolv.conf file was missing, UNIX Team added & Put DNS Entry in the File & RAC Installation started
4.
3. WHile IMPDP TABLE_EXIST_ACTION was used automatically & Tables Structure was Skipped, Data Updated & Object CReated Timings updated in Database in DBA_OBJECTS Table, SO Used TABLE_EXIST_ACTION=REPLACE & DOne with it at that time, & Created Oracle SR for this Unusall behaviour
4. ORA-07445 for Media Failure, & Transfered the Ticket to BUR (TAPE Drive team)
5. lsnrctl start : SYSTEM/6000 Error 29 Illegal SEEK : SOLUTION : Asked UNIX Team to check & Added LOCAL Entry in /etc/hosts by UNIX Team ,file 127.0.0.1 (LOOPBACK) Entry was missing #Changed /etc/hosts Perission to 666 from 664 , & Asked restart TCPIP by UNIX Team
6. Solved Many INVALID Objects Issues, By Checking Proc. , Etc..
7.
================================================
IF STANDBY DATAFILE RECOVERY to be done
IF PROD DATAFILE RECOVERY to be done
IF SYSTEM DATAFILE RECOVERY to be done
RAC CACHE FUSION :- Cache Fusion is transfering Datas from 1 Node to another by Interconnect (Private IP Address)
http://www.dba-oracle.com/t_gupta_oracle_rac_cache_fusion.htm
We know that every instance of the RAC database has its own local buffer cache which performs the usual cache functionality for that instance. Now there could be occasions when a transaction/user on instance A needs to access a data block which is being owned/locked by the other instance B. In such cases, the instance A will request instance B for that data block and hence accesses the block through the interconnect mechanism. This concept is known as CACHE FUSION where one instance can work on or access a data block in other instance?s cache via the high speed interconnect.
Cache Fusion architecture helps resolve each possible type of contentions that could be thought of in a multi-node RAC setup. We will look at them in detail in coming sections but first let us understand few very important terms/concepts which will be useful in understanding the contentions which we are going to discuss in later sections.
Global Cache Service
Global Cache Service (GCS) is the heart of Cache Fusion concept. It is through GCS that data integrity in RAC is maintained when more than one instance need a particular data block. Instances look up to the GCS for fulfilling their data block needs.
RAC BACKGROUND PROCESS
LMS , LMD , LMON , LCK0 ,
ASM ATTRIBUTES
DATAGAURD Concepts
ANS :- Datagaurd is Applying Online redo logs from Prod to Standby
Datagaurd Types:
ACTIVE DATAGAURD :- When Archives Applying is happening , when DB is in READ ONLY Mode. Applications Peoples can Use it for Report Purpose.
PASSiVE DATAGAURD :- When Archives Applying is happening , when DB is in MOUNT Mode . Applications Peoples cannot Use it for Report Purpose.
DATAGAURD CONFIGURING
Example 3-1 Primary Database: Primary Role Initialization Parameters
DB_NAME=chicago
DB_UNIQUE_NAME=chicago
LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)'
CONTROL_FILES='/arch1/chicago/control1.ctl', '/arch2/chicago/control2.ctl'
LOG_ARCHIVE_DEST_1=
'LOCATION=/arch1/chicago/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=chicago'
LOG_ARCHIVE_DEST_2=
'SERVICE=boston ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=boston'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
Example 3-2 Primary Database: Standby Role Initialization Parameters
FAL_SERVER=boston
DB_FILE_NAME_CONVERT='boston','chicago'
LOG_FILE_NAME_CONVERT=
'/arch1/boston/','/arch1/chicago/','/arch2/boston/','/arch2/chicago/'
STANDBY_FILE_MANAGEMENT=AUTO
Example 3-3 Modifying Initialization Parameters for a Physical Standby Database
DB_NAME=chicago
DB_UNIQUE_NAME=boston
LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)'
CONTROL_FILES='/arch1/boston/control1.ctl', '/arch2/boston/control2.ctl'
DB_FILE_NAME_CONVERT='chicago','boston'
LOG_FILE_NAME_CONVERT=
'/arch1/chicago/','/arch1/boston/','/arch2/chicago/','/arch2/boston/'
LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
LOG_ARCHIVE_DEST_1=
'LOCATION=/arch1/boston/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=boston'
LOG_ARCHIVE_DEST_2=
'SERVICE=chicago ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=chicago'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=chicago
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
==========================================
C:\ >dbv file=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\MANA_DATA01.DBF blocksize=8192
DBVERIFY: Release 10.2.0.2.0 - Production on Mon Sep 13 14:29:22 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\MANA_DATA01.DBF
DBV-00200: Block, dba 17268885, already marked corrupted
DBVERIFY - Verification complete
Total Pages Examined : 1685504
Total Pages Processed (Data) : 1295633
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 84554
Total Pages Failing (Index): 0
Total Pages Processed (Other): 29475 Total Pages Processed (Other): 29475
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 275842
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Highest block SCN : 100371677 (0.100371677)
RMAN> connect target sys/****
connected to target database: TAXPROD (DBID=3492187718)
RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE FILESPERSET=10;
Starting backup at 13-SEP-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=485 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\MANA_DATA01.DBF
input datafile fno=00005 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\MANA_NDX01.DBF
input datafile fno=00002 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\UNDOTBS01.DBF
input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\SYSTEM01.DBF
input datafile fno=00003 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\SYSAUX01.DBF
input datafile fno=00006 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TAXPROD\USERS01.DBF
channel ORA_DISK_1: backup set complete, elapsed time: 00:05:55
Finished backup at 13-SEP-10
RMAN>
SQL> select * from V$DATABASE_BLOCK_CORRUPTION;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
4 491669 1 0 CORRUPT
select
dbms_utility.data_block_address_file(17268885) RFN,
dbms_utility.data_block_address_block(17268885) BL
from dual;
RFN BL
---------- ----------
4 491669
select /*+ RULE CURSOR_SHARING_EXACT */
substrb(dbe.owner,1,15) DB_OWNER,
substrb(dbe.segment_name,1,30 ) OBJ_NAME,
substrb(dbe.partition_name,1,20 ) PART_NAME,
substrb(dbe.segment_type,1,3) TYP,
substrb(dbe.tablespace_name,1,10) TS_NAME
from dba_extents dbe
where dbe.file_id = 4
and 491669 between dbe.block_id and dbe.block_id+dbe.blocks-1
/
DB_OWNER OBJ_NAME PART_NAME TYP TS_NAME
--------------- ------------------------------ -------------------- --- ----------
MANA TAXINQUIRY_LOG TAB MANA_DATA
SQL> analyze table APEX_040000.WWV_FLOW_ACTIVITY_LOG1$ validate structure;
analyze table APEX_040000.WWV_FLOW_ACTIVITY_LOG1$ validate structure
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 2595)
ORA-01110: data file 7: '/u01/app/oracle/admin/refat/db/apex_tbs_01.dbf'
SELECT SEGMENT_TYPE,OWNER||'.'||SEGMENT_NAME
FROM DBA_EXTENTS
WHERE FILE_ID = *<FILE_ID>* AND *<BLOCK_NR*> BETWEEN BLOCK_ID
AND BLOCK_ID+BLOCKS -1;
====== RAC
Short answer:
1. private IP address is used only for internal clustering processing (Cache Fusion) (aka as interconnect)
2. VIP is used by database applications to enable fail over when one cluster node fails
http://www.dbametrix.com/oracle-rac-vip.html
3. public IP adress is the normal IP address typically used by DBA and SA to manage storage, system and database.
4. SCAN Name : SCAN Name is Single Client Access Name which has Single name with 3 Virtual IP Address, SCAN Names was Introduced in 11.2 Oracle Version,
ADV: Can Put single NAME in TNS ENTRY , either then adding 2 for 2 & 4 for 4 Node RAC.
No need for any changes in TNS Entry in Application / Client side, incase of NODE Add / Del.
We want to use Oracle ASM but not RAC on our 11gR2 (Oracle 11.2.0.3) Linux server. We have downloaded 7 zip files for complete software (database, RAC, ASM) package.
p10404530_112030_Linux-x86-64_1of7.zip
p10404530_112030_Linux-x86-64_2of7.zip
p10404530_112030_Linux-x86-64_3of7.zip
p10404530_112030_Linux-x86-64_4of7.zip
p10404530_112030_Linux-x86-64_5of7.zip
p10404530_112030_Linux-x86-64_6of7.zip
p10404530_112030_Linux-x86-64_7of7.zip
What is the detailed procedure of install ASM only without the clusterware? Thanks!
1. unzip
p10404530_112030_Linux-x86-64_1of7.zip
p10404530_112030_Linux-x86-64_2of7.zip
p10404530_112030_Linux-x86-64_3of7.zip
2. Install Asmlib packages and configure asm disks:
in http://docs.oracle.com/cd/E11882_01/install.112/e22489/typinstl.htm#BABDDFIJ
go to "1.3.6 Prepare Storage for Oracle Automatic Storage Management"
3. Install Grid infractructure from grid unzipped folder and choose "GI for Standalone Server"
this will configure ASM
4. Install database software from database unzipped folder, when creating database choose ASM for datafiles
Report Abuse
========================================
saikrishna.loya@hp.com
Computer@1234
MBFS CSI :- 18421215
select count(*),MODULE from v$active_session_history where sample_time between to_date('06-JUL-14 07:30','DD-MON-YY HH24:MI') and to_date('06-JUL-14 08:00','DD-MON-YY HH24:MI') group by MODULE;
select count(*),MODULE from v$active_session_history where sample_time like '%JUL%' group by MODULE;
select u.name USERNAME,ss.program,ss.event,ss.cnt SESSION_Count,ss.Sample_time
from user$ u, (select s.user_id,count(*) cnt,to_char(s.sample_time,'dd-mon-yyyy') Sample_time,s.event,s.program
from v$active_session_history s
where s.sample_time like '15-JUL%'
group by to_char(s.sample_time,'dd-mon-yyyy'),s.user_id,s.event,s.program) ss
where u.user# = ss.user_id
order by 3;
select program,count(*) cnt,to_char(sample_time,'dd-mon-yyyy') Sample_time
from v$active_session_history
where sample_time like '15-JUL%'
group by to_char(sample_time,'dd-mon-yyyy'),program
order by 2;
select user_id,event,count(*) cnt,to_char(sample_time,'dd-mon-yyyy') Sample_time
from v$active_session_history
where sample_time like '15-JUL%'
group by to_char(sample_time,'dd-mon-yyyy'),event,user_id
order by 3;
select count(*) from v$active_session_history where sample_time like '06-JUL%';
@usersession:
http://www.oracle.com/technetwork/issue-archive/2013/13-jan/o13dba-1871177.html
select user_id
from dba_users
where username = '&SAMPLE';
select sample_time, session_state, event, consumer_group_id
from v$active_session_history
where user_id = 92
and sample_time between
to_date('29-SEP-12 04.55.02 PM','dd-MON-yy hh:mi:ss PM')
and
to_date('29-SEP-12 05.05.02 PM','dd-MON-yy hh:mi:ss PM')
and session_id = 44
order by 1;
-------------------------
select event, count(1)
from v$active_session_history
where machine = 'prolaps01'
and sample_time between
to_date('29-SEP-12 04.55.00 PM','dd-MON-yy hh:mi:ss PM')
and
to_date('29-SEP-12 05.05.00 PM','dd-MON-yy hh:mi:ss PM')
group by event
order by event;
========================================
7506736591
Ronak Darji - 9820144324
Chetan Mundhe - 9820263732
ManojKumar Lakkakula - 9029705243
drop table alert_lg1;
CREATE TABLE alert_lg1
(
Alert_Text varchar2(3000)
)
ORGANIZATION EXTERNAL
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ALERT_LG
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
FIELDS
(
Alert_Text CHAR(3000)
)
)
LOCATION ('alert_SFMS.log')
);
col ALERT_TEXT for a180
col rownum for a10
SELECT *
FROM (SELECT rownum, alert_text FROM alert_lg1 order by 1 desc)
WHERE rownum <= 20
order by 1;
SELECT * FROM (SELECT * FROM alert_lg1 ORDER BY ROWID DESC) WHERE ROWnum<30 order by rowid;
select count(*) from alert_lg1 where ;
select count(*) from alert_lg1
where rownum > 111900;
between 111800 and 111956;
<= 111956 and rownum >= 111900;
delete archivelog all backed up 2 times to device type sbt_tape;
==============================
http://satya-dba.blogspot.in/2010/04/rman-commands.html
NECS DB Configurations:
RMAN> show all;
RMAN configuration parameters for database with db_unique_name ORCLKHAR are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\APP\TCSORACLESUPPORT\PRODUCT\11.2.0\DBHOME_1\DATABASE\SNCFORCL.ORA'; # default
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters are successfully stored
RMAN>
##################################################################
patch:
-------
Take the OH backup before applying this patch.
$cd $ORACLE_HOME
$tar –cvf /u01/oracle/ora_bin_bkup/11.1_b4psu112.tar 11.1.0
Note: If oracle home size is very huge, you can cleanup some old patch details from OH.
select owner,object_name,object_type from dba_objects where status='INVALID'
Ask application team to bring down all the applications belongs to the database.
Stop the LISTENER
$lsnrctl stop LISTENER
Shutdown the database
Apply the PSU Patch
$opatch apply
Start the database and run the below statements.
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL@?/rdbms/admin/catbundle.sql psu apply
Compile the invalid objects
SQL>@?/rdbms/admin/utlrp.sql
SELECT * FROM registry$history where ID = '6452863'; IF returns no rows, we can recompile the views, otherwise no need
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP UPGRADE
SQL>@?/cpu/view_recompile/view_recompile_jan2008cpu.sql
SQL> SHUTDOWN;
SQL> STARTUP;
Check the invalid objects list and compare the existing taken report.
Start the listener
Check and monitor the alert logs for next few hours.
Ask Application team to bring up their application.
########################################################################################################################################################
ALTER TABLESPACE TSCBSDATA ADD DATAFILE '+DATA' size 5G AUTOEXTEND ON MAXSIZE 30G;
BREAK ON tablespace_name SKIP 2
COMPUTE SUM OF allocated_bytes, free_bytes ON tablespace_name
COLUMN allocated_bytes FORMAT 9,999,999,999
COLUMN free_bytes FORMAT 9,999,999,999
SELECT a.tablespace_name, a.file_name, a.bytes allocated_bytes,
b.free_bytes
FROM dba_data_files a,
(SELECT file_id, SUM(bytes) free_bytes
FROM dba_free_space b GROUP BY file_id) b
WHERE a.file_id=b.file_id
ORDER BY a.tablespace_name;
=================================
@rtbs:
-----
set lines 132
set pages 105
set pause off
set echo off
set feedb on
column "TOTAL ALLOC (GB)" format 9,999,990.00
column "TOTAL PHYS ALLOC (GB)" format 9,999,990.00
column "USED (GB)" format 9,999,990.00
column "FREE (GB)" format 9,999,990.00
column "% USED" format 990.00
select
a.tablespace_name,
a.bytes_alloc/(1024*1024*1024) "TOTAL ALLOC (GB)",
a.physical_bytes/(1024*1024*1024) "TOTAL PHYS ALLOC (GB)",
nvl(b.tot_used,0)/(1024*1024*1024) "USED (GB)",
(nvl(b.tot_used,0)/a.bytes_alloc)*100 "% USED"
from
(select
tablespace_name,
sum(bytes) physical_bytes,
sum(decode(autoextensible,'NO',bytes,'YES',maxbytes)) bytes_alloc
from
dba_data_files
group by
tablespace_name ) a,
(select
tablespace_name,
sum(bytes) tot_used
from
dba_segments
group by
tablespace_name ) b
where
a.tablespace_name = b.tablespace_name (+)
and
a.tablespace_name not in
(select distinct
tablespace_name
from
dba_temp_files)
--and
-- a.tablespace_name not like 'UNDO%'
order by 1;
TABLESPACE_NAME TOTAL ALLOC (GB) TOTAL PHYS ALLOC (GB) USED (GB) % USED
------------------------------ ---------------- --------------------- ------------- -------
SYSAUX 2.00 1.56 1.48 74.17
SYSTEM 2.00 0.83 0.78 38.84
TSCBSDATA 90.00 40.68 9.73 10.81
TSCBSIDX 30.00 12.91 3.00 9.99
USERS 0.00 0.00 0.00 0.00
set line 180
col file_name for a55
col TABLESPACE_NAME for a25
set pages 100
set verify off
select df.FILE_ID,df.FILE_NAME,df.TABLESPACE_NAME,round(df.BYTES/1024/1024) Allocated,
round(nvl(dfs.BYTES/1024/1024,0)) FREE_SPACE, round(((df.BYTES/1024/1024)-nvl((dfs.BYTES/1024/1024),0))) USED_SPACE
from dba_data_files df,
(select file_id,tablespace_name,sum(bytes) bytes
from dba_free_space
group by file_id,tablespace_name) dfs
where df.FILE_ID=dfs.FILE_ID (+)
--AND df.TABLESPACE_NAME in('TABLESPACE_NAME')
order by df.FILE_ID;
============================
col name for a10
SELECT
NAME,
TO_CHAR( (SPACE_LIMIT)/1024/1024/1024, '9999999999999') AS "SPACE_LIMIT in GB",
TO_CHAR((SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE)/1024/1024/1024, '9999999999999')
AS "SPACE_AVAILABLE in GB",
To_CHAR((SPACE_USED)/1024/1024/1024, '9999999999999') AS "SPACE_USED in GB" ,
ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1)
AS PERCENT_FULL
FROM V$RECOVERY_FILE_DEST ;
NAME SPACE_LIMIT in SPACE_AVAILABL SPACE_USED in PERCENT_FULL
---------- -------------- -------------- -------------- ------------
+FRA 200 189 11 5.3
=====
column Name format a17
SELECT Name, (SPACE_LIMIT/1024/1024/1024) Space_Limit_GB, SPACE_USED/1024/1024/1024 Space_Used_GB, SPACE_RECLAIMABLE, NUMBER_OF_FILES
FROM V$RECOVERY_FILE_DEST;
NAME SPACE_LIMIT_GB SPACE_USED_GB SPACE_RECLAIMABLE NUMBER_OF_FILES
----------------- -------------- ------------- ----------------- ---------------
+FRA 200 10.6416016 0 105
==
set linesize 100
select * from V$RECOVERY_AREA_USAGE;
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
-------------------- ------------------ ------------------------- ---------------
CONTROL FILE 0 0 0
REDO LOG 0 0 0
ARCHIVED LOG 5.2 0 94
BACKUP PIECE .13 0 11
IMAGE COPY 0 0 0
FLASHBACK LOG 0 0 0
FOREIGN ARCHIVED LOG 0 0 0
=======================================================
select file_name, bytes, maxbytes,
increment_by*(bytes/blocks) "INCREMENT",
maxbytes-bytes remaining,
(maxbytes-bytes)/(increment_by*(bytes/blocks)) EXTENSIONS
from dba_data_files
where autoextensible = 'YES' ;
=================================
FNSONLS.INVM
column "Percent of Total Disk Usage" justify right format 999.99
column "Space Used (MB)" justify right format 9,999,999.99
column "Total Object Size (MB)" justify right format 9,999,999.99
set linesize 150
set pages 80
set feedback off
select * from (select to_char(end_interval_time, ‘MM/DD/YY’) mydate, sum(space_used_delta) / 1024 / 1024 "Space used (MB)", avg(c.bytes) / 1024 / 1024 "Total Object Size (MB)",
round(sum(space_used_delta) / sum(c.bytes) * 100, 2) "Percent of Total Disk Usage"
from
dba_hist_snapshot sn,
dba_hist_seg_stat a,
dba_objects b,
dba_segments c
where begin_interval_time > trunc(sysdate) – &days_back
and sn.snap_id = a.snap_id
and b.object_id = a.obj#
and b.owner = c.owner
and b.object_name = c.segment_name
and c.segment_name = ‘segment_name’
group by to_char(end_interval_time, ‘MM/DD/YY’))
order by to_date(mydate, ‘MM/DD/YY’);
=========================
UNDO space check
column file_name format a55
column tablepsace_name format a22
set pages 200
set lines 200
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where tablespace_name like '%&UNDO%' ;
set time on
column host_name format a25
select name,open_mode from gv$database;
select host_name,status,logins from gv$instance;
set pages 500
set lines 120
set heading on
column tablespace_name for a30
column tbsize for 999999999.999
column tbfree for 999999999.999
column Largest for 99999.999
column ratio for 9999.99
column Required for 99999.999
select
a.tablespace_name ,
tbsize ,
tbfree ,
b.tbfree/a.tbsize*100 "% Free TBS" ,
b.Largest "Largest space"
from
( select tablespace_name,sum(bytes)/1024/1024 tbsize
from dba_data_files
group by tablespace_name) a,
( select tablespace_name,nvl(sum(bytes)/1024/1024,0) tbfree,
nvl(max(bytes)/1024/1024,0) Largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name(+)
TABLESPACE_NAME TBSIZE TBFREE % Free TBS Largest space
------------------------------ -------------- -------------- ---------- -------------
SFMS_BR_ARCH_NDX 12288.000 11751.625 95.6349691 3968
UNDOTBS1 20480.000 19190.438 93.7033081 3968
SFMS_BR_ARCH_DATA 168759.000 147594.125 87.4585207 3968
USERS 800.000 686.625 85.828125 499
UNDOTBS2 66881.000 43030.063 64.3382463 3968
SYSTEM 2500.000 1547.438 61.8975 1547
SYSAUX 6144.000 1815.375 29.5471191 750
SFMS_BR_NDX 19732.000 5308.063 26.900783 1605
SFMS_BR_DATA 197295.000 24109.125 12.2198358 3968
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;
select file_id,tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_data_files where tablespace_name=
============================================
undo usage query by session :=
col osuser for a15
col user for a10
col undo_tbs for a12
col SEGMENT_NM for a15
col command for a30
set pages 9999
set lines 200
SELECT ds.TABLESPACE_NAME "UNDO_TBS",ds.RELATIVE_FNO "File Nos",r.name "SEGMENT_NM", s.sid, s.serial#,s.osuser, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,substr(s.program, 1, 78) "COMMAND", c.sql_text
FROM sys.v_$session s, sys.v_$transaction t, sys.v_$rollname r,dba_segments ds,v$sql c
WHERE t.addr = s.taddr
and t.xidusn = r.usn
and s.sql_hash_value = c.hash_value
and ds.segment_name = r.name(+)
--and s.program not like 'ORACLE.EXE%'
ORDER BY t.cr_get, t.phy_io;
UNDO_TBS File Nos SEGMENT_NM SID SERIAL# OSUSER USER STATUS CR_GET PHY_IO USED_UBLK NOU COMMAND
------------ ---------- --------------- ---------- ---------- --------------- ---------- ---------------- ---------- ---------- ---------- --- ------------------------------
SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
UNDOTBS2 5 _SYSSMU401_2783 61 29 oracle SFMSBR ACTIVE 56371674 1970139 42916 NO sqlplus@P25O.localdomain (TNS
765022$ V1-V3)
DELETE FROM SMD_SYS_MSG_DTLS WHERE TO_DATE(SMD_CRTN_DATE) = :B1
======== For UsingTemp
set lines 400
set pages 9999
col sid_serial for a12
col program for a30
col event for a40
col username for a15
col tablespace for a15
col status for a10
SELECT a.inst_id,a.sid||','||a.serial# SID_SERIAL, to_char(a.logon_time,'dd-mm-yyyy hh24:mis'),a.program,a.event,(sum(b.extents)*1024*1024)/1024/1024 MB_space,
b.tablespace tablespace,a.sql_hash_value,a.username, a.osuser, c.spid Process,
a.status --,'alter system kill session ''' || a.sid || ',' || a.serial# || ''' immediate;' "sids"
FROM gv$session a,gv$sort_usage b, gv$process c, dba_tablespaces d
WHERE a.saddr = b.session_addr
AND a.paddr = c.addr
AND b.tablespace=d.tablespace_name
-- and schemaname not like '%SYS%'
and b.extents*1024*1024 > 1000
group by a.username, a.osuser, a.sid||','||a.serial#,c.spid,
b.tablespace, a.status,a.program,a.event, a.inst_id,a.logon_time,a.sid,a.serial#,a.sql_hash_value
order by MB_space asc,a.logon_time asc;
@changeawr:
----------
Then, execute the following command to create a manual snapshot.
EXECUTE dbms_workload_repository.create_snapshot();
Then wait for 30 min ( or required time period ) and create another manual snapshot by following command.
EXECUTE dbms_workload_repository.create_snapshot();
execute dbms_workload_repository.modify_snapshot_settings(interval => 60,
retention => 20160);
========PARTION===========
@part
select PARTITION_NAME,TABLESPACE_NAME,HIGH_VALUE from DBA_TAB_PARTITIONS where TABLE_NAME='&MHB_MSG_HDR_BR_AR';
=====
ls -lrt 1_10[5-8]*
=========================************************************************************=========================================
find . -type f -name "*.aud" -mtime +15 -exec rm -rf {} \;
========================================
http://select-star-from.blogspot.in/search/label/ISSUE
ORA-16191: Primary log shipping client not logged on standby
==============
pdc backup
run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup as compressed backupset database format 'E:\RMANCOLDBKP\db_%d_%D_%M_%Y_%s.bkp';
backup current controlfile format 'E:\RMANCOLDBKP\ctl_%d_%D_%M_%Y_%s.bkp';
release channel c1;
release channel c2;
release channel c3;
}
===================https://sites.google.com/site/oraclerac009/rac-q-a=============================
ls -ltr *0402* | awk '{print $5,$NF}'
select PARTITION_NAME,TABLESPACE_NAME,HIGH_VALUE from DBA_TAB_PARTITIONS where TABLE_NAME='MST_MSG_STOR_TBL_AR';
======================
hashval
SELECT sql_text
FROM V$SQLTEXT
WHERE hash_value = 228801498
ORDER BY piece;
################################################################################################################################################################################################################
dlp:
===
*************Script to get objects info of an owner***********************************
select object_type,count(*) from dba_objects where owner='ENFOS' group by object_type;
select owner,object_type,count(*) from dba_objects group by object_type,owner order by owner;
set linesize 100 pages 100
col owner for a10
col object_name for a20
col object_type for a15
select owner,object_name,object_type,status from dba_objects where object_name='TEST';
[Query to find object count,object type]
set pages 4999 linesize 300
col owner for a20
col object_name for a25
col object_type for a25
select owner,count(*),object_type from dba_objects group by owner,object_type order by 1;
[Query to find object/schema size]
select owner,sum(bytes)/(1024*1024) "BYTES IN MB" from dba_segments group by owner;
===========================================================================================================================
******************************Script to get the DDL to create objects in Database******************
set heading off;
set echo off;
Set pages 999;
set long 90000;
select dbms_metadata.get_ddl('TABLESPACE','AV78H1IS_1996') from dual;
===========================================================================================================================
*****************************Freespace Scripts****************************************************
Datafiles in Tablespace:
-------------------------
select distinct status from v$backup;
col file_name for a55
set pages 100
select file_name,bytes/1024/1024 from dba_data_files where tablespace_name='&tablespace_name';
Freespace For a tablespace only:
-------------------------------
COL TS_NAME FOR A20
COL AVAILABLE FOR A15
COL USED FOR A15
COL FREE FOR A15
set linesize 300
select
a.tablespace_name TS_NAME,
a.bytes/1024/1024||' MB' AVAILABLE,
b.bytes/1024/1024||' MB' USED,
c.bytes/1024/1024||' MB' FREE
from
sm$ts_avail a,
sm$ts_used b,
sm$ts_free c
where a.tablespace_name=b.tablespace_name
and b.tablespace_name=c.tablespace_name
and a.tablespace_name='REFIND1';
---------------------------------------------------------------------------------------------------------------------------
Freespace in tablespace with Datafiles:
--------------------------------------
SET LINESIZE 300
SET PAGESIZE 60
COL TABLESPACE_NAME FOR A28
COL FILE_NAME FOR A55
COL TOTAL FOR A10
COL FREE FOR A10
SELECT dd.tablespace_name TABLESPACE_NAME,
dd.file_name FILE_NAME,
dd.bytes/1024/1024||' MB' TOTAL,
SUM(fs.bytes)/1024/1024||' MB' FREE
FROM sys.dba_free_space fs, sys.dba_data_files dd
WHERE dd.tablespace_name = fs.tablespace_name
AND dd.file_id = fs.file_id
GROUP BY dd.tablespace_name, dd.file_name, dd.bytes/1024
ORDER BY dd.tablespace_name, dd.file_name;
---------------------------------------------------------------------------------------------------------------------------
Freespace in Temporary tablespace:
---------------------------------
select TABLESPACE_NAME,
sum(BYTES_USED)/1024/1024,
sum(BYTES_FREE)/1024/1024 from v$temp_space_header group by tablespace_name;
col tablespace_name for a20
col USED_MB for 99999999
col FREE_MB for 99999999
set linesize 300
select tablespace_name,sum(bytes_used)/1024/1024 used_mb,sum(bytes_free)/1024/1024 free_mb from v$temp_space_header group by tablespace_name;
select name from v$tempfile;
select file_name,bytes/1024/1024 from dba_temp_files where tablespace_name='TEMP';
---------------------------------------------------------------------------------------------------------------------------
Freespace in all the tablespaces:
--------------------------------
COLUMN pct_free FORMAT 999.99 HEADING "% Free"
COLUMN name FORMAT A16 HEADING "Tablespace Name"
COLUMN mbytes FORMAT 99,999,999 HEADING "Total MBytes"
COLUMN used FORMAT 99,999,999 HEADING "Used Mbytes"
COLUMN free FORMAT 99,999,999 HEADING "Free Mbytes"
BREAK ON REPORT
COMPUTE SUM OF mbytes ON REPORT
COMPUTE SUM OF free ON REPORT
COMPUTE SUM OF used ON REPORT
SELECT fs.tablespace_name name, df.totalspace mbytes, (df.totalspace - fs.freespace) used,
fs.freespace free, 100 * (fs.freespace / df.totalspace) pct_free
FROM (SELECT tablespace_name, ROUND(SUM(bytes) / 1048576) TotalSpace FROM dba_data_files GROUP BY tablespace_name ) df,
(SELECT tablespace_name, ROUND(SUM(bytes) / 1048576) FreeSpace FROM dba_free_space GROUP BY tablespace_name ) fs
WHERE df.tablespace_name = fs.tablespace_name(+);
set pages 49999 linesize 200
select nvl(b.tablespace_name,
nvl(a.tablespace_name,'UNKOWN')) "TablespaceName",
kbytes_alloc "AllocatedSpace(MB)",
kbytes_alloc-nvl(kbytes_free,0) "UsedSpace(MB)",
nvl(kbytes_free,0) "FreeSpace(MB)",
((kbytes_alloc-nvl(kbytes_free,0))/kbytes_alloc)*100 " %Used "
from ( select sum(bytes)/1024/1024 Kbytes_free,max(bytes)/1024/1024 largest,tablespace_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024/1024 Kbytes_alloc,tablespace_name
from sys.dba_data_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
and a.tablespace_name='AV78C1TS';
----------------------------------------------------------------------------------------------------------------------------
Add Datafile Check:
------------------
select name from v$datafile where name like '%ops_stg_tab_36%';
ls -ltr /dba*/DBF/cseblpr2/eim_im06*
---------------------------------------------------------------------------------------------------------------------------
Tablespaces Freespace Report:
--------------------------------
set linesize 1000
set trimspool on
set pagesize 32000
set verify off
set feedback off
SELECT df.tablespace_name tsname
, sum(df.bytes)/1024/1024 tbs_size_mb
, nvl(sum(e.used_bytes)/1024/1024,0) used
, nvl(sum(f.free_bytes)/1024/1024,0) avail
, rpad(' '||rpad('X',round(sum(e.used_bytes)
*10/sum(df.bytes),0), 'X'),11,'-') used_visual
, nvl((sum(e.used_bytes)*100)/sum(df.bytes),0) pct_used
FROM sys.dba_data_files df
, (SELECT file_id
, sum(nvl(bytes,0)) used_bytes
FROM sys.dba_extents
GROUP BY file_id) e
, (SELECT max(bytes) free_bytes
, file_id
FROM dba_free_space
GROUP BY file_id) f
WHERE e.file_id(+) = df.file_id
AND df.file_id = f.file_id(+)
GROUP BY df.tablespace_name
ORDER BY 6
/
---------------------------------------------------------------------------------------------------------------------------
Freespace in Datafiles in a Database:
--------------------------------------
set linesize 1000
set trimspool on
set pagesize 32000
set verify off
set feedback off
column tsname format a20 heading 'Tablespace Name'
column flname format a50 heading 'Filename'
column siz format 999,999,990 heading 'File Size|(MB)'
column maxsiz format 999,999,990 heading 'Max Size|(MB)'
column pctmax format 990 heading 'Pct|Max'
select file_name flname
, tablespace_name tsname
, bytes/1024/1024 siz
, decode(maxbytes,0,0,maxbytes/1024/1024) maxsiz
, decode(maxbytes,0,0,bytes/maxbytes*100) pctmax
from dba_data_files
/
==========================================================================================================================================
******************Database Startup time***********************************
select instance_name,status,to_char(startup_time,'DD/MM/YYYY HH24:MM:SS') from v$instance;
select to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual;
==========================================================================================================================================
********************************Script Execution***************************************************
vi stats.sql
conn ra/p8rick;
set timing on
set verify on
set feedback on head on
set echo on
spool stats.log
select name from v$database;
show user;
exec dbms_stats.gather_schema_stats('WCADMIN');
spool off;
exit;
==========================================================================================================================================
***********************************User Account Scripts************************************************
set lines 200
set pages 1000
select USERNAME,PASSWORD,ACCOUNT_STATUS,EXPIRY_DATE from dba_users where username in ('CSHEKA','RPEDDI','PCHAKR','ASHAST,'RMAHAL');
select username,account_status from dba_users where username like '******';
select TEMPORARY_TABLESPACE,count(1) from dba_users group by TEMPORARY_TABLESPACE;
select DEFAULT_TABLESPACE,count(1) from dba_users group by DEFAULT_TABLESPACE;
select count(*) from dba_users;
CREATE USER CSHEKA IDENTIFIED BY nike123
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP;
===========================================================================================================================================
**********************************Max Extents for Table/Index**********************************************
select owner,table_name,MAX_EXTENTS from dba_tables where table_name='MLOG$_CMFP';
alter table NIKE.NICLRTX storage(maxextents 500);
select OWNER,INDEX_NAME,MAX_EXTENTS from dba_indexes where index_name='*******';
alter index KORODS.LCUSTPX0 storage(maxextents 200);
===========================================================================================================================================
*********************************Gather Statistics/Stats****************************************************
Tables:
SELECT DISTINCT(TRUNC(LAST_ANALYZED)),COUNT(1) from dba_tables where owner='SYSADM' GROUP BY TRUNC(LAST_ANALYZED);
select owner,table_name, LAST_ANALYZED from dba_tables where LAST_ANALYZED<=sysdate-7;
EXEC DBMS_STATS.gather_schema_stats(ownname => 'SYSADM', estimate_percent => 10);
EXEC DBMS_STATS.gather_schema_stats('SYSADM');
analyze table SYSADM."PSAPMSGPUBDATA" compute statistics;
Indexes:
SELECT DISTINCT(TRUNC(LAST_ANALYZED)),COUNT(1) from dba_indexes where owner='SYSADM' GROUP BY TRUNC(LAST_ANALYZED);
select owner,index_name from dba_indexes where last_analyzed<=sysdate-7;
analyze index sysadm."PS_PSAPMSGPUBDATA" compute statistics;
spool stats_gather.log
select name from v$database;
show user;
set timing on;
EXEC DBMS_UTILITY.analyze_schema('SYSADM','ESTIMATE', estimate_percent => 10);
spool off;
set timing off;
exit;
==========================================================================================================================================
*****************************Schema Analyze********************************
EXEC DBMS_UTILITY.analyze_schema('TEST','COMPUTE');
EXEC DBMS_UTILITY.analyze_schema('TEST','ESTIMATE', estimate_percent => 10);
=============================================================================================================================================
******************************Kill Sesion{gadmp}********************************************************************
To get Server Process Id(SPID) using the oracle session id (sid):
@getpid:
------
select spid
from v$process
where background is null
and addr in (select paddr
from v$session
where sid=&session_id);
@getsid:
------
select sid
from v$session
where paddr in (select addr
from v$process
where spid=&sp_id);
select sid,serial# from v$session where sid=***;
ps -ef|grep spid
alter system kill session 'sid,serial#';
Eg: alter system kill session '815,4221';
select sid,serial#,status from v$session where sid=***;
ps -ef|grep spid
kill -9 spid
select sid,serial#,status from v$session where sid=***;
=============================================================================================================================================
********************To View all the views************************************************************
select tname from tab where tname like '%JOB%';
=============================================================================================================================================
********************************Session Monitoring Scripts*******************************************
Session Monitoring Scripts--All the Sessions
--------------------------------------------
SET LINESIZE 500
SET PAGESIZE 1000
COLUMN username FORMAT A10
COLUMN osuser FORMAT A10
COLUMN SID for 99999
COLUMN SERIAL# for 99999
COLUMN SPID for 99999
COLUMN lockwait FORMAT A18
COLUMN status FORMAT A10
COLUMN module FORMAT A15
COLUMN machine FORMAT A15
COLUMN program FORMAT A15
SELECT NVL(s.username, '(oracle)') AS username,s.osuser,s.sid,s.serial#,p.spid,s.lockwait,s.status,s.module,s.machine,s.program,
TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time FROM v$session s,v$process p WHERE s.paddr = p.addr;
Session Monitoring Scripts--Active Sessions
-------------------------------------------
set linesize 500 pages 49999
col username for a15
col status for a10
col schemaname for a15
col osuser for a10
col process for 99999
col program for a35
SELECT SID,SERIAL#,USERNAME,STATUS,SCHEMANAME,OSUSER,PROCESS,PROGRAM,
PQ_STATUS "PARALLEL",TO_CHAR(LOGON_TIME,'DD-MM-YYYY HH24:MI:SS')
FROM V$SESSION ;
WHERE TYPE <>'BACKGROUND'
AND STATUS='ACTIVE';
Details os SQL executed currently by an SID
-------------------------------------------
SELECT b.sid,b.username,a.SQL_TEXT,a.ROWS_PROCESSED
FROM V$SQL a, v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value
AND b.sid in ('1421');
=============================================================================================================================================
***************************************Privileges to a user**********************************
---------------------------------------------------------------------------------------------
GRANTEE
User to whom access was granted
OWNER
Owner of the object
TABLE_NAME
Name of the object
GRANTOR
Name of the user who performed the grant
PRIVILEGE
Table Privilege
GRANTABLE
Privilege is grantable
HIERARCHY
Privilege is with hierarchy option
--------------------------------------------------------------------------------------------
set linesize 500 pages 49999
col grantee for a20
col owner for a20
select * from dba_tab_privs where GRANTEE='******';
=============================================================================================================================================
***********************************Segment Information for a Tablespace*******************************
set linesize 500 pages 49999
col owner a25
col segment_name for a30
select owner,segment_name,segment_type from dba_segments where tablespace_name='******';
=============================================================================================================================================
************************************List of Invalid Objects in the Database*****************************
SET LINESIZE 145
SET PAGESIZE 9999
clear columns
clear breaks
clear computes
column owner format a25 heading 'Owner'
column object_name format a30 heading 'Object Name'
column object_type format a20 heading 'Object Type'
column status format a10 heading 'Status'
break on owner skip 2 on report
compute count label "" of object_name on owner
compute count label "Grand Total: " of object_name on report
SELECT
owner
, object_name
, object_type
, status
FROM dba_objects
WHERE status <> 'VALID'
and owner not in ('SYS','SYSTEM','DBSNMP')
ORDER BY owner, object_name
/
=============================================================================================================================================
************************************Online Backup status of Datafiles*****************************
column "File No" format 9999 wrapped
column "File Name" format a50 wrapped
column "Size (bytes)" format 99999999999 wrapped
column "Backup Status" format a10 wrapped heading "Backup|Status"
column "Start Time" format a18 wrapped
set linesize 1000
set pagesize 32000
set trimspool on
select b.file# "File No"
, d.name "File Name"
, d.bytes "Size (bytes)"
, b.status "Backup Status"
, to_char(b.time,'DD-MON-YY HH24:MI:SS') "Start Time"
from v$backup b
, v$datafile d
where b.file# = d.file#
order by b.time
/
column "File No" clear
column "File Name" clear
column "Size (bytes)" clear
column "Backup Status" clear
column "Start Time" clear
=============================================================================================================================================
************************************Growth of Database*****************************
#Provides a report on physical database growth with respect to the date that data files have been added.
@monthlygrowth
----------------
SET LINESIZE 145
SET PAGESIZE 9999
SET VERIFY OFF
COLUMN month FORMAT a7 HEADING 'Month'
COLUMN growth FORMAT 999,999,999,999,999 HEADING 'Growth (MB)'
BREAK ON report
COMPUTE SUM OF growth ON report
SELECT
TO_CHAR(creation_time, 'RRRR-MM') month
, SUM(bytes)/1024/1024 growth
FROM sys.v_$datafile
GROUP BY TO_CHAR(creation_time, 'RRRR-MM')
ORDER BY TO_CHAR(creation_time, 'RRRR-MM');
=============================================================================================================================================
************************************Query all the tables within a Schema*****************************
SET LINESIZE 145
SET PAGESIZE 9999
COLUMN owner FORMAT A15 HEADING "Owner"
COLUMN table_name FORMAT A30 HEADING "Table Name"
COLUMN tablespace_name FORMAT A28 HEADING "Tablespace"
COLUMN last_analyzed FORMAT A20 HEADING "Last Analyzed"
COLUMN num_rows FORMAT 999,999,999 HEADING "# of Rows"
SELECT
owner
, table_name
, tablespace_name
, TO_CHAR(last_analyzed, 'DD-MON-YYYY HH24:MI:SS') last_analyzed
, num_rows
FROM all_tables
WHERE owner = UPPER('&owner')
ORDER BY owner, table_name
/
=============================================================================================================================================
@archgen
************************************Query to find out number of arch files generated every hour*****************************
set lines 120;
set pages 999;
SELECT
to_char(first_time,'YYYY-MON-DD') day,
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'99') "00",
to_char(sum(decode(to_char(first_time,'HH24'),'01',1,0)),'99') "01",
to_char(sum(decode(to_char(first_time,'HH24'),'02',1,0)),'99') "02",
to_char(sum(decode(to_char(first_time,'HH24'),'03',1,0)),'99') "03",
to_char(sum(decode(to_char(first_time,'HH24'),'04',1,0)),'99') "04",
to_char(sum(decode(to_char(first_time,'HH24'),'05',1,0)),'99') "05",
to_char(sum(decode(to_char(first_time,'HH24'),'06',1,0)),'99') "06",
to_char(sum(decode(to_char(first_time,'HH24'),'07',1,0)),'99') "07",
to_char(sum(decode(to_char(first_time,'HH24'),'08',1,0)),'99') "08",
to_char(sum(decode(to_char(first_time,'HH24'),'09',1,0)),'99') "09",
to_char(sum(decode(to_char(first_time,'HH24'),'10',1,0)),'99') "10",
to_char(sum(decode(to_char(first_time,'HH24'),'11',1,0)),'99') "11",
to_char(sum(decode(to_char(first_time,'HH24'),'12',1,0)),'99') "12",
to_char(sum(decode(to_char(first_time,'HH24'),'13',1,0)),'99') "13",
to_char(sum(decode(to_char(first_time,'HH24'),'14',1,0)),'99') "14",
to_char(sum(decode(to_char(first_time,'HH24'),'15',1,0)),'99') "15",
to_char(sum(decode(to_char(first_time,'HH24'),'16',1,0)),'99') "16",
to_char(sum(decode(to_char(first_time,'HH24'),'17',1,0)),'99') "17",
to_char(sum(decode(to_char(first_time,'HH24'),'18',1,0)),'99') "18",
to_char(sum(decode(to_char(first_time,'HH24'),'19',1,0)),'99') "19",
to_char(sum(decode(to_char(first_time,'HH24'),'20',1,0)),'99') "20",
to_char(sum(decode(to_char(first_time,'HH24'),'21',1,0)),'99') "21",
to_char(sum(decode(to_char(first_time,'HH24'),'22',1,0)),'99') "22",
to_char(sum(decode(to_char(first_time,'HH24'),'23',1,0)),'99') "23"
from
v$log_history
GROUP by
to_char(first_time,'YYYY-MON-DD') order by day asc;
============================================================================================================================================
2nd
---
alter session set NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS';
select trunc(first_time, 'HH') , count(*)
from v$loghist
group by trunc(first_time, 'HH')
order by trunc(first_time, 'HH');
=============================================================================================================================================
************************************Query to find out number of DBLINKS*****************************
set pages 100
set linesize 800
col owner for a20
col db_link for a30
col username for a20
col host for a20
select * from dba_db_links where db_link='SWFTW_DDL';
=============================================================================================================================================
************************************Crontab entries in UNIX*****************************
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
=============================================================================================================================================
***********************************EXTENTS***********************************
SQL> select owner,table_name,MAX_EXTENTS from dba_tables where table_name='NICLRTX';
OWNER TABLE_NAME MAX_EXTENTS
------------------------------ ------------------------------ -----------
NIKE NICLRTX 249
SQL> alter table NIKE.NICLRTX storage(maxextents 500);
Table altered.
=============================================================================================================================================
***********************************Sapreorg/Saparch***********************************
bdf|grep %|grep arch
ls -ltr /oracle/BIP/sapreorg/ARCH_SPLIT/sap*
ls -altr /oracle/PTA/sapreorg/seb*/*.new
ls -altr /oracle/PTA/sapreorg/seb*/*.old
nohup compress /oracle/PTA/sapreorg/seb*/*.new &
nohup compress /oracle/PTA/sapreorg/seb*/*.old &
=============================================================================================================================================
***********************************High Water Mark(HVM)***********************************
@watermark
set verify off
column file_name format a50 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings format 999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report
column value new_val blksize
select value from v$parameter where name = 'db_block_size';
select file_name, hwm, bytes/1024/1024,blocks total_blocks, ((blocks-hwm+1)*(&&blksize) )/1024/1024 shrinkage_possible_MB
from dba_data_files a,
( select file_id, max(block_id+blocks) hwm
from dba_extents group by file_id ) b
where a.file_id = b.file_id
and a.tablespace_name='&tbs';
SIZE TO BE SHRINKED IS shrinkage_possible*db_block_size ( in bytes)
=============================================================================================================================================
**********************************Tuning Queries******************************************
SELECT distinct b.sid,b.username,a.SQL_TEXT,a.ROWS_PROCESSED--,a.SQL_ID
FROM V$SQL a, v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value;
set linesize 500 pages 49999
col username for a15
col status for a10
col schemaname for a15
col osuser for a12
col process for 99999
col program for a35
SELECT SID,SERIAL#,USERNAME,STATUS,SCHEMANAME,OSUSER,PROCESS,PROGRAM,
PQ_STATUS "PARALLEL",TO_CHAR(LOGON_TIME,'DD-MM-YYYY HH24:MI:SS')
FROM V$SESSION where SID in (165);
;
WHERE TYPE <>'BACKGROUND'
AND USERNAME='BRIOSVR_BATCH';
--where sid ='1009';
set linesize 800 pages 49999
set lines 1000
col USERNAME for a14
col status for a10
col schemaname for a15
col OSUSER for a15
col process for 99999
col program for a12
SELECT SID,SERIAL#,USERNAME,STATUS,SCHEMANAME,OSUSER,PROCESS,PROGRAM,
TO_CHAR(LOGON_TIME,'DD-MM-YYYY HH24:MI:SS')
FROM V$SESSION
WHERE SID=93;
WHERE TYPE <>'BACKGROUND'
AND USERNAME='BRIOSVR_BATCH';
select * from v$sess_io where sid ='57';
COLUMN sid FORMAT 999,99999
COLUMN serial# FORMAT 9999999
COLUMN machine FORMAT A15
COLUMN OPNAME FOR A45
COLUMN progress_pct FORMAT 99999999.00
COLUMN elapsed FORMAT A10
COLUMN remaining FORMAT A20
COLUMN REM_MIN FOR A10
set linesize 300
SELECT distinct s.username,
s.sid,
s.serial#,
sl.opname,
s.machine,
sl.SOFAR,
sl.TOTALWORK,
TRUNC(sl.elapsed_seconds/60) || ':' || MOD(sl.elapsed_seconds,60) elapsed,
TRUNC(sl.time_remaining/60) || ':' || MOD(sl.time_remaining,60) REM_MIN
--ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct
FROM v$session s,v$session_longops sl
WHERE s.sid = sl.sid
AND s.serial# = sl.serial#
and s.username='OPS$ORACLE'
and sl.sofar<>sl.totalwork;
SET LINESIZE 200
SET PAGESIZE 1000
COLUMN username FORMAT A20
COLUMN event FORMAT A30
COLUMN wait_class FORMAT A15
SELECT NVL(s.username, '(oracle)') AS username,
s.sid,
s.serial#,
sw.event,
--sw.wait_class,
sw.wait_time,
sw.seconds_in_wait,
sw.state
FROM v$session_wait sw,
v$session s
WHERE s.sid = sw.sid
and s.TYPE<>'BACKGROUND'
--and s.SID ='11'
---and sw.event!='SQL*Net message from client'
---and s.sid in (select sid from v$px_session where qcsid ='1357')
ORDER BY s.sid,sw.seconds_in_wait DESC;
@which blocking
select l1.sid, ' IS BLOCKING ', l2.sid from v$lock l1, v$lock l2 where l1.block =1 and l2.request > 0 and l1.id1=l2.id1 and l1.id2=l2.id2;
SET LINESIZE 500
SET PAGESIZE 1000
SET VERIFY OFF
COLUMN owner FORMAT A20
COLUMN username FORMAT A20
COLUMN object_owner FORMAT A20
COLUMN object_name FORMAT A30
COLUMN locked_mode FORMAT A15
SELECT distinct b.session_id AS sid, NVL(b.oracle_username, '(oracle)') AS username, a.owner AS object_owner,a.object_name,
Decode(b.locked_mode, 0, 'None',
1, 'Null (NULL)',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share (S)',
5, 'S/Row-X (SSX)',
6, 'Exclusive (X)',
b.locked_mode) locked_mode, b.os_user_name
FROM dba_objects a, v$locked_object b
WHERE a.object_id = b.object_id
ORDER BY 1, 2, 3, 4;
set pages 4999 linesize 300
col owner for a20
col segment_name for a25
col segment_type for a25
select owner,segment_name,segment_type from dba_segments where segment_name ='PLAN_TABLE';
SET PAGESIZE 100
SET LINESIZE 200
SET VERIFY OFF
COLUMN plan FORMAT A50
COLUMN object_name FORMAT A30
COLUMN object_type FORMAT A15
COLUMN bytes FORMAT 9999999999
COLUMN cost FORMAT 9999999
COLUMN partition_start FORMAT A20
COLUMN partition_stop FORMAT A20
SELECT LPAD(' ', 2 * (level - 1)) ||
DECODE (level,1,NULL,level-1 || '.' || pt.position || ' ') ||
INITCAP(pt.operation) ||
DECODE(pt.options,NULL,'',' (' || INITCAP(pt.options) || ')') plan,
pt.object_name,
pt.object_type,
pt.bytes,
pt.cost,
pt.partition_start,
pt.partition_stop
FROM plan_table pt
START WITH pt.id = 0
AND pt.statement_id = '&1'
CONNECT BY PRIOR pt.id = pt.parent_id
AND pt.statement_id = '&1';
=============================================================================================================================================
---------------------------------------------------Session_Info-------------------------------------------------------
set pages 300
set lines 300
col sid for 9999
col serial# for 999999
col USERNAME for a15
col OSUSER for a10
col LOGON_TIME for a20
col PROGRAM for a27
col MACHINE for a10
col status for a20
select sid,serial#,username,osuser,TO_CHAR(logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,program,machine,status from v$session where sid in (651,1259);
select sid,serial#,username,osuser,TO_CHAR(logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,program,machine,status from v$session where sid in (1503,1642,1682);
---------------------------------------------------Long_run_Info--------------------------------------------------------------
COLUMN sid FORMAT 999,99999
COLUMN serial# FORMAT 9999999
COLUMN machine FORMAT A20
COL USERNAME for a15
COLUMN OPNAME FOR A20
COLUMN progress_pct FORMAT 99999999.00
COLUMN elapsed FORMAT A10
COLUMN remaining FORMAT A20
COLUMN REM_MIN FOR A10
set linesize 300
SELECT distinct s.username,
s.sid,
s.serial#,
sl.opname,
s.machine,
sl.SOFAR,
sl.TOTALWORK,
TRUNC(sl.elapsed_seconds/60) || ':' || MOD(sl.elapsed_seconds,60) elapsed,
TRUNC(sl.time_remaining/60) || ':' || MOD(sl.time_remaining,60) REM_MIN
--ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct
FROM v$session s,v$session_longops sl
WHERE s.sid = sl.sid
AND s.serial# = sl.serial#
--and s.sid in ('403','432','291','190','462','56','507','476','1305')
--AND s.sid in (select sid from v$px_session where qcsid ='1723')
and sl.sofar<>sl.totalwork;
SQL Info
SELECT distinct b.sid,b.username,a.SQL_TEXT,a.ROWS_PROCESSED--,a.SQL_ID
FROM V$SQL a, v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value
and b.sid ='386'
---and b.sid in (select sid from v$px_session where qcsid='1081')
---------------------------------------------------Locked_object_Info--------------------------------------------------------------
SET LINESIZE 500
SET PAGESIZE 1000
SET VERIFY OFF
COLUMN owner FORMAT A20
COLUMN username FORMAT A20
COLUMN object_owner FORMAT A20
COLUMN object_name FORMAT A30
COLUMN locked_mode FORMAT A15
SELECT b.session_id AS sid,NVL(b.oracle_username, '(oracle)') AS username,a.owner AS object_owner,a.object_name,
Decode(b.locked_mode, 0, 'None',
1, 'Null (NULL)',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share (S)',
5, 'S/Row-X (SSX)',
6, 'Exclusive (X)',
b.locked_mode) locked_mode,
b.os_user_name
FROM dba_objects a,
v$locked_object b
WHERE a.object_id = b.object_id and b.session_id=3047
ORDER BY 1, 2, 3, 4;
SET PAGESIZE 14
SET VERIFY ON
=================LOCKED OBJECTS=======================
select c.owner,c.object_name,c.object_type,
b.sid,b.serial#,b.status,b.osuser,b.machine
from v$locked_objects a,v$session b,dba_objects c
where b.sid=a.session_id and a.object_id=s.object_id
==
select sid,serial#,username from v$session where sid=140;
alter system kill session 'sid,serial#';
------------------------------------------I/O-------------------------------------------------------------------------
--if physicalgets changes then some select statement is running
--if block_change and consistentgets changing then some update or delete statement is going on.
col SID for 99999
col BLOCK_GETS for 9999999999
col CONSISTENT_GETS for 9999999999
col PHYSICAL_READS for 9999999999
col BLOCK_CHANGES for 9999999999
col CONSISTENT_CHANGES for 9999999999
select SID,BLOCK_GETS,CONSISTENT_GETS,PHYSICAL_READS,BLOCK_CHANGES,CONSISTENT_CHANGES from v$sess_io where sid in (514,492,487,466,458,611,533,627):;
select * from v$sess_io where sid in (select sid from v$px_session where qcsid=1305);
select SID,BLOCK_GETS,CONSISTENT_GETS,PHYSICAL_READS,BLOCK_CHANGES,CONSISTENT_CHANGES from v$sess_io where sid in (949);
---------------------------SQL_TEXT_BASED_ON_SQL_ID------------------------------------------------------------------------------
set pages 300
set lines 300
col sid for 9999
col user_opening for 9999
col users_executing for 9999
col elapsed_time for 99999999999999
col loads for 99999999
col rows_processed 9999999
col last_Active_time for a30
set long 99999999999999
select
se.sid,
s.SQL_FULLTEXT,
s.USERS_OPENING,
s.USERS_EXECUTING,
s.ELAPSED_TIME,
s.LOADS,ROWS_PROCESSED,
to_char(s.LAST_ACTIVE_TIME,'DD:MM:YYYY HH24:MI:SS') LAST_ACTIVE_TIME
from v$sql s,
v$session se
where s.sql_id=se.sql_id
and se.sid in ( );
---------------Query to find out the session info including the SQL TEXT and the amount of time elapsed since the SID is running.-------------------
set pages 10000
col username form a20
col machine form a30
col osuser form a10
col gets_per_exec form 99999999999
select s.username,s.sid,s.serial#,s.osuser,p.spid,s.machine,
sql_text,v$sqlarea.hash_value,
to_char(logon_time, 'mm/dd/yyyy hh24:mi:ss') "LOGON TIME",
to_char(trunc(last_call_et/3600,0))||' '||' HRS '||
to_char(trunc((last_call_et - trunc(last_call_et/3600,0)*3600) /
60,0))|| ' MINS' "Running Time"
from v$sqlarea , v$session s,v$process p
where s.sql_address = address
and s.status = 'ACTIVE'
and s.paddr = p.addr
and s.username is not null
and last_call_et > 60*&minutes and s.sid=625;
-- Pass the minutes value as an input and 0 will display everything
order by last_call_et
/
---------------Query to find out the SID from Process ID-------------------
SET LINESIZE 500
SET PAGESIZE 1000
COLUMN username FORMAT A10
COLUMN osuser FORMAT A10
COLUMN SID for 99999
COLUMN SERIAL# for 99999
COLUMN SPID for 99999
COLUMN lockwait FORMAT A18
COLUMN status FORMAT A10
COLUMN module FORMAT A15
COLUMN machine FORMAT A15
COLUMN program FORMAT A15
select * from v$session,v$process where addr=paddr and process='13091';
==========================================================================================================================================
From process id-find SID
select sid
from v$session
where paddr in (select addr
from v$process
where spid=&sp_id);
From SID using v$px_session find qcsid(parent sid);
select SID,SERIAL#,QCSID from v$px_session where SID=610;
Using qcsid we can find all child process of qcsid
SQL> select SID,SERIAL#,QCSID from v$px_session where qcsid=587;
SID SERIAL# QCSID
---------- ---------- ----------
482 15737 587
610 45962 587
614 39150 587
618 38354 587
587 30314 587
From SID-Find ProcessID
select spid
from v$process
where addr in (select paddr
from v$session
where sid=&sid);
==========================================================================================================================================
***UNDO MONITORING****
set linesize 450 pages 99999
col sid_serial format a20
col orauser format a20
col program format a30
col undoseg format a20
col Undo format a20
col undoseg format a10
col undoseg format a20
SELECT distinct TO_CHAR(s.sid)||','||TO_CHAR(s.serial#) sid_serial, NVL(s.username, 'None') orauser, s.program,
r.name undoseg,t.used_ublk * TO_NUMBER(x.value)/1024||'K' "Undo(KB)"
FROM sys.v_$rollname r, sys.v_$session s, sys.v_$transaction t,sys.v_$parameter x
WHERE s.taddr = t.addr
AND r.usn = t.xidusn(+)
AND x.name = 'db_block_size';
undoneeded:
===========
SELECT
ROUND(d.undo_size/(1024*1024),2) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
ROUND((TO_NUMBER(e.value)*TO_NUMBER(f.value)*g.undo_block_per_sec)/(1024*1024),2) "NEEDED UNDO SIZE [MByte]"
FROM
(
SELECT
SUM(a.bytes) undo_size
FROM
v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE
c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.TS# = b.TS#
) d,
v$parameter e,
v$parameter f,
(
SELECT
MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
FROM
v$undostat
) g
WHERE
e.name = 'undo_retention'
AND f.name = 'db_block_size'
;
============
undoretention(optimal):
============
SELECT d.undo_size/(1024*1024) "ACTUAL UNDO SIZE [MByte]",
SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
ROUND((d.undo_size / (to_number(f.value) *
g.undo_block_per_sec))) "OPTIMAL UNDO RETENTION [Sec]"
FROM (
SELECT SUM(a.bytes) undo_size
FROM v$datafile a,
v$tablespace b,
dba_tablespaces c
WHERE c.contents = 'UNDO'
AND c.status = 'ONLINE'
AND b.name = c.tablespace_name
AND a.ts# = b.ts#
) d,
v$parameter e,
v$parameter f,
(
SELECT MAX(undoblks/((end_time-begin_time)*3600*24))
undo_block_per_sec
FROM v$undostat
) g
WHERE e.name = 'undo_retention'
AND f.name = 'db_block_size'
/
=========================================================================================================================================
***Roles/Privileges****
***General***
SELECT grantee "User",
granted_role "Role",
admin_option "Adm"
FROM dba_role_privs a
WHERE grantee='DM_COMMON';
SELECT grantee "User",
privilege "Privilege",
admin_option "Adm"
FROM dba_sys_privs where grantee='DM_COMMON';
***User Specified***
SET SERVEROUTPUT ON
SET VERIFY OFF
SELECT a.granted_role "Role",
a.admin_option "Adm"
FROM user_role_privs a;
SELECT a.privilege "Privilege",
a.admin_option "Adm"
FROM user_sys_privs a;
SET VERIFY ON
==========================================================================================================================================
-----------------------------High water mark in datafile -------------------------------------------
set verify off
column file_name format a50 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings format 999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report
column value new_val blksize
select value from v$parameter where name = 'db_block_size'
/
select file_name,
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest,
ceil( blocks*&&blksize/1024/1024) currsize,
ceil( blocks*&&blksize/1024/1024) -
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savings
from dba_data_files a,
( select file_id, max(block_id+blocks-1) hwm
from dba_extents
group by file_id ) b
where a.file_id = b.file_id(+)
and a.tablespace_name='&Tablespace_Name';
######################################################################################################################
currenttab:
----------
select table_name,round((blocks*8),2)||'kb' "size" from user_tables where table_name = 'BIG1';
actualtab:
---------
select table_name,round((num_rows*avg_row_len/1024),2)||'kb' "size" from user_tables where table_name = 'BIG1';
==========================================================================================================================================
---------------------------------------------dba_directories-------------------------------------------
set lines 100
set linesize 500
col owner for a10
col DIRECTORY_NAME for a20
col DIRECTORY_PATH for a70
select * from dba_directories;
==========================================================================================================================================
---------------------------------------------reorg_checks-------------------------------------------
cl scr
set verify off feed off
undef 1
column SEGMENT_NAME format a25
column tablespace_name format a20
set line 200
set pages 1000
select a.segment_name,c.tablespace_name,a.bytes/1024/1024,a.extents,b.last_analyzed
from dba_segments a,dba_tables b,dba_tablespaces c
where a.segment_name = '&&1'
and a.segment_name = b.table_name and a.tablespace_name = c.tablespace_name;
set pages 0
select a.segment_name,c.tablespace_name,a.bytes/1024/1024,a.extents,b.last_analyzed
from dba_segments a,dba_indexes b,dba_tablespaces c
where a.segment_name in
(select index_name from dba_indexes
where table_name = '&&1')
and a.segment_name = b.index_name and a.tablespace_name = c.tablespace_name
order by a.segment_name;
set pages 0
set echo off
col DATA_TYPE for a15
select DATA_TYPE ||' Type YES' from dba_Tab_columns where table_name='&&1'
and data_type like ('%RAW');
==========================================================================================================================================
----------------Most fragmented tables---------------
select table_name,round((blocks*8),2) "size (kb)" ,
round((num_rows*avg_row_len/1024),2) "actual_data (kb)",
(round((blocks*8),2) - round((num_rows*avg_row_len/1024),2)) "wasted_space (kb)"
from dba_tables
where (round((blocks*8),2) > round((num_rows*avg_row_len/1024),2))
order by 4 desc
===========================================================================================================================================
-----------------Long running queries---------------
SELECT s.SID,
s.serial#,
s.machine,
ROUND(sl.elapsed_seconds/60) || ':' ||
MOD(sl.elapsed_seconds,60) elapsed,
ROUND(sl.time_remaining/60) || ':' ||
MOD(sl.time_remaining,60) remaining,
ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct
FROM v$session s,
v$session_longops sl
WHERE s.SID = sl.SID
AND s.serial# = sl.serial#
ORDER BY 4 DESC
And then run the following query
SELECT a.sql_text
FROM v$sqltext a,
v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value
AND b.sid = &1 --> From above sql
ORDER BY a.piece;
BASH_PROFILE:
============
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
PATH=$PXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>TRUE);
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>FALSE);
================
@metatbs:
-------
declare c clob;
begin
for t in( select tablespace_name from dba_tablespaces)
loop
select dbms_metadata.get_ddl('TABLESPACE', t.tablespace_name) into c from dual;
dbms_output.put_line(c);
dbms_output.put(';');
end loop;
end;
=========================
https://www.scribd.com/doc/187559341/How-to-Change-Dbname-Dbid-and-Instance-Name
=======IMP===ASM========
https://www.youtube.com/watch?v=ll_orkRC3ro
=================== TRASPORTABLE TABLESPACE============
@transportable tbs
http://dba-expert.blogspot.in/2012/02/cross-platform-migration-using-rman.html
SQL> COLUMN PLATFORM_NAME FORMAT A36
SQL> SELECT * FROM V$TRANSPORTABLE_PLATFORM ORDER BY PLATFORM_NAME;
SQL> select * from v$transportable_platform order by 3,1;
#######################################################################################################################################
cms:
----
create table ACC_ER_UR_PREMIUM_HIST as select * from ACC_ER_UR_PREMIUM where 1=2;
create table ACC_ER_UR_PREMIUM_TEMP as select * from ACC_ER_UR_PREMIUM where 1=2;
/
insert /*+ APPEND */ FIRST
WHEN DAT_CALCULATION_DATE <= to_date('31/03/2014','dd/mm/yyyy')
THEN INTO ACC_ER_UR_PREMIUM_HIST
ELSE INTO ACC_ER_UR_PREMIUM_TEMP
SELECT /*+ FULL */ * from ACC_ER_UR_PREMIUM;
JOB_SCHEDULE_DTLS to check batchjob
select * from dba_scheduler_running_jobs;
select * from gv$session_longops where time_remaining>1;
select count(1) from v$session where status='ACTIVE' and username is not null ;
select sql_id,value_string from DBA_HIST_SQLBIND where sql_id = '98kn006gbj438'
select * from table(dbms_xplan.display_awr('6gurz7cb0jgbt'));
select userid,acfunc_decoder(upassword) from cnfgtr_user_mstr where UPPER(userid) like 'APPSUP%';
https://www.rediffmail.com/cgi-bin/login.cgi
1)cd /home/ias/IasHome/opmn/bin
2)./opmnctl startproc process-type=cms
or
3)./opmnctl startproc ias-component=dcm-daemon
//////////////////////////////////////////////////////////////////////////
--Execute the procedure with payment id & cheque date.
DECLARE
L_NUM_INSTRUMENT_ID NUMBER;
L_CHANGED_TO_DATE DATE;
BEGIN
L_NUM_INSTRUMENT_ID := 1001052070;
L_CHANGED_TO_DATE := to_date('','dd/mm/rrrr');
INS.ACC_CHQ_DATE_CHANGE ( L_NUM_INSTRUMENT_ID, L_CHANGED_TO_DATE );
COMMIT;
END;
/
--After execution please run the below select query to verify the modification of cheque date.
--------------------------------------------------------------------------
/
SELECT num_instrument_id, dat_instrument_date original_chq_date,
dat_changed_to_date changed_chq_date, txt_proc_run,
num_r_u_ape "Rows in Payment_entry", num_r_u_acd "Rows in Collection",
num_r_u_agl "Rows in Ledger", dat_log_date "RUN DATE"
FROM chq_date_change_log
WHERE num_instrument_id = 1000945370;
/
appsupport@universalsompo.com
C789fHLT
absalkar@in.ibm.com
asif.ahmed@in.ibm.com
customer.first@indiafirstlife.com
SELECT username U_NAME, owner OBJ_OWNER,
object_name, object_type, s.osuser,
DECODE(l.block,
0, 'Not Blocking',
1, 'Blocking',
2, 'Global') STATUS,
DECODE(v.locked_mode,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive', TO_CHAR(lmode)
) MODE_HELD
FROM gv$locked_object v, dba_objects d,
gv$lock l, gv$session s
WHERE v.object_id = d.object_id
AND (v.object_id = l.id1)
AND v.session_id = s.sid
ORDER BY username, session_id;
//////////////////////// blocked sessions//////////////////////////////
Select blocking_session, sid, serial#, wait_class,seconds_in_wait From v$session where blocking_session is not NULL
order by blocking_session;
SELECT BLOCKS
FROM DBA_SEGMENTS
WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
ANALYZE TABLE owner.table ESTIMATE STATISTICS;
SELECT EMPTY_BLOCKS
FROM DBA_TABLES
WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
select a.sid,a.program,b.sql_text from v$session a, v$sqltext b where a.sql_hash_value = b.hash_value
--and a.sid=485 order by a.sid,hash_value,piece;
Select wait_class, sum(time_waited), sum(time_waited)/sum(total_waits) Sum_Waits From v$system_wait_class
Group by wait_class
Order by 3 Asc;
select a.sid, a.event, a.total_waits, a.time_waited, a.average_wait from v$session_event a, v$session b where time_waited > 0
and a.sid=b.sid and b.username is not NULL and a.event='enq: TX - row lock contention';
Select blocking_session, sid, serial#, wait_class, seconds_in_wait From v$session where blocking_session is not NULL
order by blocking_session;
select sid, serial#, username, osuser, machine from v$session where username is not NULL;
SELECT
wait_class,NAME,ROUND (time_secs, 2) time_secs,ROUND (time_secs * 100 / SUM (time_secs) OVER (), 2) pct FROM
(SELECT n.wait_class,e.event NAME,e.time_waited / 100 time_secs FROM v$system_event e, v$event_name n WHERE
n.NAME = e.event AND n.wait_class <> 'Idle' AND time_waited > 0 UNION SELECT 'CPU',
'server CPU',SUM (VALUE / 1000000) time_secs FROM v$sys_time_model WHERE
stat_name IN ('background cpu time', 'DB CPU')) ORDER BY time_secs DESC;
grep -H -r "srvconfig" /home/ias/
////////////// LOCKED OBJECTS /////////////////////////////
select count(*) cnt,
session_id sid,
substr(event,1,30) event,
mod(p1,16) as lm,
sql_id,
CURRENT_OBJ# || ' ' || object_name obj
, o.object_type type
, CURRENT_FILE# file#
, CURRENT_BLOCK# block#
, blocking_session bsid
from dba_hist_active_sess_history ash,
all_objects o
where
event like 'enq: T%'
and o.object_id (+)= ash.current_obj#
and ash.snap_id between 44559 and 44560
group by event,session_id,p1,sql_ID,CURRENT_OBJ#,OBJECT_NAME,OBJECT_TYPE,CURRENT_FILE#, CURRENT_BLOCK#, BLOCKING_SESSION
order by count(*) desc
/u01/app/oracle/admin/configdb/bdump prod DB
/testdb/configdb/admin/udump //configdv
/testdb/configdev/dump/udump //dev
/oradata6/uattest/admin/udump // uattest
Ultimatix.Helpdesk@cmcltd.com
///////// after opmn/bin/......................////////////////////
bin]$./opmnctl start ias-component=performance_server
for uattest-refresh: cd /orasan2/uattest_refresh/expdump
POLICY_DOC_MNGMT_DTL
/home/ias/IasHome/Apache/Apache/logs/httpd.pid
/home/ias/IasHome/Apache/Apache/conf
http://172.16.8.19:1811/emd/console/ias/clusters/farm$farm=IasHome.reportserver.sompo
http://172.16.4.11:1810/emd/console/ias/clusters/farm$farm=IasHome.srvconfigrp1
proposal num 2311108805842
SELECT l.session_id||','||v.serial# sid_serial,
l.ORACLE_USERNAME ora_user,
o.object_name,
o.object_type,
DECODE(l.locked_mode,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive',
TO_CHAR(l.locked_mode)
) lock_mode,
o.status,
to_char(o.last_ddl_time,'dd.mm.yy') last_ddl
FROM dba_objects o, gv$locked_object l, v$session v
WHERE o.object_id = l.object_id
and l.SESSION_ID=v.sid
--AND object_name in ('CLAIM_GENERAL_DETAILS')
order by 2,3;
appsupport@universalsompo.com
C789fHLT
User ID - APPSUP03
Password - YU7808N37O
User ID - APPSUP04
Password - UH8059R73X
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_name,b.object_type,a.locked_mode from
(select object_id, SESSION_ID, ORACLE_USERNAME, OS_USER_NAME, LOCKED_MODE from v$locked_object) a,
(select object_id, owner, object_name,object_type from dba_objects) b
where a.object_id=b.object_id
select *
from CLAIM_TPA_LOG
where TXT_XML_ID in (
select TXT_XML_ID
from CLAIM_TPA_LOG
where DAT_INSERT_DATE = to_date('12/02/2013','dd/mm/yyyy') --Change Date here
and NUM_TPA_CLAIM_NO = 'USGI016153' -- change tpa claim number here
AND TXT_XML_TYPE = 'INTIMATION') --Change type
select object_name,object_type from dba_objects where owner = '&user'
order by object_type, object_name
////////////////////////////////////////////////////
select * from user_objects where OBJECT_TYPE = 'PACKAGE' and OBJECT_NAME like
'%HLTH_PROCESSING%'
select * from v$archive_gap;
for DR: cd /rmanbackup/archive
for prod: cd /archive
select username, count(*) from V$SESSION group by username ;
select username,osuser,terminal, from v$session where username is not null order by username,osuser;
select * from v$session where program='w3wp.exe'
select * from v$session where program='w3wp.exe' and OSUSER='IUSR_SRVCONFIGAS2';
select * from (
select
ash.SQL_ID ,
sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
sum(decode(ash.session_state,'WAITING',1,0)) "All_Waits",
sum(decode(ash.session_state,'WAITING', decode(wait_class, 'Cluster',1,0),0)) "Cluster" ,
sum(decode(ash.session_state,'WAITING', decode(wait_class, 'User I/O',1,0),0)) "User_I/O" ,
sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"
from dba_hist_active_sess_history ash
where SQL_ID is not NULL
and snap_id between 25814 and 25816
group by sql_id
order by sum(decode(session_state,'ON CPU',1,1)) desc
)
where rownum <=5
alter system kill session '105,23597';
{{ CMS PEOPLE )
SELECT txt_user_id, cms.cms_decode_str (txt_password, TO_DATE (dat_creation_date, 'dd/mm/yyyy')) FROM cms.cms_user_mst
select * from table(dbms_xplan.display_cursor('6gurz7cb0jgbt'));
select userid,acfunc_decoder(upassword) from cnfgtr_user_mstr where UPPER(userid) like 'PRAGOP%';
(((( PSW INF for cms
SELECT CNFGTR_DECODER('pK< //qq ') FROM CNFGTR_USER_MSTR WHERE USERID = 'CONCON80';
))
SQL> create index indb_transaction_id_old on cnfgtr_tran_stat_hist(transaction_id_old) tablespace indx nologging;
Index created.
TKPROF
go to bdump or udump or adump
$tkprof filename.trc filename.txt sys=no sort=fchela
tkprof mydb_ora_29951_ORDERS_QUERY.trc ORDERS_QUERY.tkp waits=yes
sys=no sort=fchela,exeela,prsela
explain plan for select * from emp:
SQL> select * from table(dbms_xplan.display);
////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\///////////////////
Trace the file.....................................................
set heading on
set timing on
alter session set tracefile_identifier = 'SUMAN_21092012';
alter session set events '10046 trace name context forever,level 8';
execute script (select statment)
//////////////////////////////////////////////////////////////////////////////////////////
select to_date(LOGON_TIME,'dd/mm/yyyy') LOGON_TIME,status,TYPE,STATE,count(*)
from v$session
group by to_date(LOGON_TIME,'dd/mm/yyyy'),status,TYPE,STATE
order by 1,2
Select -- s.username, s.LOGON_TIME,
'alter system kill session '''||s.sid||','||s.serial#||''';' "Kill Statement"
FROM V$SESSION s , V$PROCESS p
WHERE s.paddr = p.addr
AND s.username IS NOT NULL
AND s.username = 'INS'
AND s.last_call_et > 900
and s.status='INACTIVE';
rem session.sql - displays all connected sessions
set echo off;
set termout on;
set linesize 80;
set pagesize 60;
set newpage 0;
/////\\\\\\\\\\\\\\\/////////////////\\\\\\\\\\\\\\\////////////////\\\\\\\\\\\\\
select rpad(c.name||':',11)||rpad(' current logons='|| (to_number(b.sessions_current)),20)||'cumulative logons='||
rpad(substr(a.value,1,10),10)||'highwater mark='||
b.sessions_highwater Information
from
v$sysstat a,
v$license b,
v$database c
where
a.name = 'logons cumulative'
;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
select a.USERNAME,substr(a.spid,1,9) pid, substr(b.sid,1,5) sid,substr(b.serial#,1,5) ser#,
substr(b.machine,1,6) box,substr(b.username,1,10) username,substr(b.osuser,1,8) os_user,
substr(b.program,1,30) program from v$session b,
v$process a
where b.paddr = a.addr and type='USER'
AND a.USERNAME IS NOT NULL order by spid
;
ttitle off;
set heading off;
select 'To kill, enter SQLPLUS> ALTER SYSTEM KILL SESSION',
''''||'SID, SER#'||''''||';' from dual;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
select‘alter system kill session ‘’’|| sess.sid||’, ‘||sess.serial#||’;’
from v$locked_object lo, dba_objects ao, v$session sess where ao.object_id = lo.object_id
and lo.session_id = sess.sid;
select count(*) from v$session where status='INACTIVE' and username is not null ;
select username,osuser,terminal from v$session where username is not null order by username,osuser;
select * from v$session where program='w3wp.exe';
select * from v$session where program='w3wp.exe' and OSUSER='IUSR_SRVCONFIGAS2';
select * from v$session where status='ACTIVE' and username is not null ;
select count(1) from v$session where username is not null ;
select count(*) from v$session where status='ACTIVE' and username is not null ;
///////////////////////////////
CMC Limited
C-18, Bandra Kurla Complex
Bandra (E), Mumbai - 400051
Mobile: +91 9619992270
Direct Line: +91 22 67811780
BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB
(
job_name => 'PSP_GANESH_01'
,start_date => TO_TIMESTAMP_TZ('2009/09/02 15:30:00.000000 +05:30','yyyy/mm/dd hh24:mi:ss.ff tzh:tzm')
,repeat_interval => 'freq=daily;byhour=00;byminute=30;'
,end_date => NULL
,job_class => 'DEFAULT_JOB_CLASS'
,job_type => 'PLSQL_BLOCK'
,job_action => 'declare
I_RUN_DATE DATE;
BEGIN
I_RUN_DATE := to_date(sysdate,''dd/mm/rrrr'')-1;
PSP.PROC_FETCH_POLICY_DATA_g1 ( I_RUN_DATE );
COMMIT;
end;'
,comments => 'Job scheduler for ganesh Request'
);
END;
/
NUM_POL_PREMIUM -- Policy Data
TXT_OCC_SRL_NO_OCCUPANCY -- occupancy data filter by code 1
NUM_OCC_PREMIUM -- replace with NUM_POL_PREMIUM -- Policy Data
TXT_OCC_SRL_NUMBER_OCCUPANCY -- Perils
NUM_COVER_PERIL_PREMIUM - replace with NUM_POL_PREMIUM -- Policy Data
9830866750 surajit mallik
emd_web_site.xml
AGENT_HOME/bin/emctl start agent
$ORACLE_HOME/bin/emctl start iasconsole
emctl resetTZ agent
emctl istop agent
emctl stop oms
/////////////////////////////////// Bulk patch log Script//////////////////////////
select
*
from
confsys.CNFGTR_PATCH_LOG
where
to_date(RUN_DATE,'dd/mm/yyyy') = to_date('15/07/2013','dd/mm/yyyy')
General Manager (Personnel), The Singareni Collieries Co. Ltd., Recruitment
Cell, Kothagudem 507 101, Khammam Dist. (AP) only by POST / COURIER to
reach on or before 19/08/2013, super scribing the application registration
ACC_PAYMENT_ENTRY
ACC_MAP_INSTRPROPOSAL
CHQ_DATE_CHANGE_LOG
ACC_RTGS_REVERSE_FILE
Z:\Mumbai\CommonShare\Daily_Reports\Accounts\DailyPaymentDetails\FY-2012\SEP 2013
X:\CommonShare\Claims_Report\Claim Intimation Register\SEP 2013
X:\CommonShare\Claims_Report\Claim_Mis_New\SEP 2013
Z:\Mumbai\CommonShare\Daily_Report\Cash_collection_BRS\SEP 2013
X:\CommonShare\Claims_Report\F&A Claim Paid & OS\SEP 2013
policy loading issue
1.take reference no.
2.check in CNFGTR_POLICY_LD_DTLS table.
3.check LD_CALC_AMT field in above table.
4. if two record found then delete one record having LD_CALC_AMT value = 0.
5. Commit.
C:\WINDOWS\system32\inetsrv
del_execute.bat
del_pdf_execute.bat
execute.bat
merge_execute.bat
Location of JSPs:
./resources/jsp/reinsurance
Location of XML:
./WEB-INF/reinsurance
Location of JAVA and CLASSes:
./WEB-INF/classes/geni/reinsurance
swapneel 9819615585
Mahesh D Mahadik
Human Resources - WR
CMC Limited
C-18, Bandra Kurla Complex
Bandra (E), Mumbai - 400051
Mobile: +91 9967919798
Direct Line: +91 22 67811779
Website: www.cmcltd.com
http://tata.mymeetingroom.com
user id: 5077321
pass: u220t0
http://docs.oracle.com/cd/E23104_01/download_readme_cr2/download_readme_cr2.htm
In this URL please select
Task 3: Select an Oracle Forms and Reports Software Download Site then
download the installer for RHEL 5 linux 64-bit version.
Note: file name may be like ofm_pfrd_linux_11.1.1.2.0_32_disk1_1of1.zip in
http://edelivery.oracle.com/
http://www.oracle.com/technetwork/developer-tools/forms/downloads/index.html
////////////////////////////////////////
CLAIM_MOTO_SCHEDULER
if u not got record then go for genisyss
Select record for claim number.
Create insert statement
update insert key from 1 to 0
upate update no from 1 to 0
execute the insert statement.
JOB_SCHEDULE_DTLS to check batchjob
////////////////////////////////////////////////////
Patch url
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=964676135662004&id=1618213.1&_afrWindowMode=0&_adf.ctrl-state=bjnr004kr_4#BABBCHHD
30 0 * * * root find /tmp -type f -empty -delete
####################################################################################################################################################################################################################]
lmk:
shrinkdatafile:
--------------
set linesize 1000 pagesize 0 feedback off trimspool on
with
hwm as (
-- get highest block id from each datafiles ( from x$ktfbue as we don't need all joins from dba_extents )
select /*+ materialize */ ktfbuesegtsn ts#,ktfbuefno relative_fno,max(ktfbuebno+ktfbueblks-1) hwm_blocks
from sys.x$ktfbue group by ktfbuefno,ktfbuesegtsn
),
hwmts as (
-- join ts# with tablespace_name
select name tablespace_name,relative_fno,hwm_blocks
from hwm join v$tablespace using(ts#)
),
hwmdf as (
-- join with datafiles, put 5M minimum for datafiles with no extents
select file_name,nvl(hwm_blocks*(bytes/blocks),5*1024*1024) hwm_bytes,bytes,autoextensible,maxbytes
from hwmts right join dba_data_files using(tablespace_name,relative_fno)
)
select
case when autoextensible='YES' and maxbytes>=bytes
then -- we generate resize statements only if autoextensible can grow back to current size
'/* reclaim '||to_char(ceil((bytes-hwm_bytes)/1024/1024),999999)
||'M from '||to_char(ceil(bytes/1024/1024),999999)||'M */ '
||'alter database datafile '''||file_name||''' resize '||ceil(hwm_bytes/1024/1024)||'M;'
else -- generate only a comment when autoextensible is off
'/* reclaim '||to_char(ceil((bytes-hwm_bytes)/1024/1024),999999)
||'M from '||to_char(ceil(bytes/1024/1024),999999)
||'M after setting autoextensible maxsize higher than current size for file '
|| file_name||' */'
end SQL
from hwmdf
where
bytes-hwm_bytes>1024*1024 -- resize only if at least 1MB can be reclaimed
order by bytes-hwm_bytes desc
/
burleson shir:
------------
select 'alter database '||a.name||' datafile '''||b.file_name||'''' ||
' resize '||(bytes_total-bytes_free)
from v$database a
,dba_data_files b
,(Select tablespace_name,sum(bytes) bytes_full
From dba_extents
Group by tablespace_name) c
,(Select tablespace_name,sum(bytes) bytes_total
From dba_data_files
Group by tablespace_name) d
,(Select a.tablespace_name,a.file_id,b.bytes bytes_free
From (select tablespace_name,file_id
,max(block_id) max_data_block_id
from dba_extents
group by tablespace_name,file_id) a
,dba_free_space b
where a.tablespace_name = b.tablespace_name
and a.file_id = b.file_id
and b.block_id > a.max_data_block_id) e
Where b.tablespace_name = c.tablespace_name
And b.tablespace_name = d.tablespace_name;
##################################################################################################################################################################################################
mostoftensql:
-------------
SELECT
sql_text,
executions
FROM
(
SELECT
sql_text,
executions,
rank() over ( order by executions DESC) exec_rank
FROM
v$sql
)
WHERE
exec_rank >10;
/
################################
mostiosql:
----------
SELECT
disk_reads,
sql_text
FROM
(
SELECT
sql_text,
disk_reads,
dense_rank() over ( order by disk_reads DESC) disk_reads_rank
FROM
v$sql
)
WHERE
disk_reads <=10;
##################################################
mostlogcalsql:
-------------
SELECT
buffer_gets,
sql_text
FROM
(
SELECT
sql_text,
buffer_gets,
dense_rank() over (order by buffer_gets DESC) buffer_gets_rank
FROM
v$sql
)
WHERE
buffer_gets <=10;
#########################################################################################
Find the SQL for the expensive query
Here the expensive means either physical io or logical io large than 10000, the number could be differ depends on the environment.
Get the hash code first
select hash_value,executions, buffer_gets,disk_reads, parse_calls
from v$SQLAREA
where buffer_gets > 10000 or disk_reads > 10000
orderby buffer_gets + 100 * disk_reads desc
Get the SQL
select address,hash_value,piece,sql_text
from V$sqltext
where hash_value = '487379649'
orderby piece;
Find the query plan
selectoperation,options, object_name, cost
from v$sql_plan
where address = '58861A18'and hash_value='487379649'
Find the query plan for the current active user session
Find the active session
select username,terminal,program,sql_hash_value,sql_address,type
from v$session
where type notlike'BACKGROUND'
select operation,options, object_name, cost
from v$sql_plan
where address = '5F9F10F8'and hash_value='3509024188'
#################################################################################################
@unnamedg:
---------
Check for the files needs to be recovered.
SQL> select * from v$recover_file where error like ‘%FILE%’;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
—— ——- ——- ——————– ———- ——————–
33 ONLINE ONLINE FILE MISSING 0
SQL>
Identify on primary of data file 33(Primary Database)
SQL> select file#,name from v$datafile where file#=33;
FILE# NAME
—— ———————————————————————-
33 M:\UNDO\UNDOTBS02.DBF
SQL>
Identify dummy file name created in (Standby)
SQL> select file#,name from v$datafile where file#=33;
FILE# NAME
—— ———————————————————————-
33 E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00033
SQL>
Crosscheck that no MRP is running and STANDBY_FILE_MANAGEMENT can be enabled once after creating file on standby
SQL> alter database create datafile ‘E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00033’ as ‘M:\UNDO\UNDOTBS02.DBF;
Database altered.
SQL>
If you are managing File system ASM with OMF, you are not allowed to create data file, because it will file system names and format maintained by ASM. If you try to create datafile as above with ASM File, You will pass with below error.
SQL> alter database create datafile ‘ E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE \UNNAMED00033’ as ‘+DATA3\UNDO\UNDOTBS02.DBF
*
ERROR at line 1:
ORA-01276: Cannot add file
+DATA3\UNDO\UNDOTBS02. File has an Oracle Managed Files file name.
Then Run above command as shown below
SQL> alter database create datafile ‘E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\UNNAMED00033’ as new;
Database altered.
SQL>
Enable STANDBY_FILE_MANAGEMENT to AUTO & Start MRP.
SQL> show parameter standby_file_management
NAME TYPE VALUE
———————————— ———– ————————-
standby_file_management string MANUAL
SQL> alter system set standby_file_management=AUTO scope=both;
system altered.
SQL> show parameter standby_file_management
NAME TYPE VALUE
———————————— ———– ————————–
standby_file_management string AUTO
SQL> alter database recover managed standby database disconnect from session;
Database altered.
#################################################################################################################################
@manualsync:
---------
increamental sync
================
1. [Standby] Stop the managed standby apply process:
SQL> alter database recover managed standby database cancel;
Database altered.
2. [Standby] Shutdown the standby database
3. [Primary] On the primary, take an incremental backup from the SCN number where the standby has been stuck:
run
{
allocate channel c1 type disk format '/u01/rman_backup/inctl_%U.bkp';
backup incremental from scn 67 database;
}
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=139 devtype=DISK
Starting backup at 18-DEC-09
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/oradata/DEL1/datafile/o1_mf_system_5bhbh59c_.dbf
… …
piece handle=/u01/oraback/06l16u1q_1_1.rmb tag=TAG20091218T083619 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:06
Finished backup at 18-DEC-09
released channel: c1
4. [Primary] On the primary, create a new standby controlfile:
SQL> alter database create standby controlfile as '/u01/rman_backup/inctl_%U.ctl';
Database altered.
5. [Primary] Copy these files to standby host:
oracle@oradba1 /u01/oraback# scp *.rmb *.ctl oracle@oradba2:/u01/oraback
oracle@oradba2's password:
06l16u1q_1_1.rmb 100% 43MB 10.7MB/s 00:04
DEL1_standby.ctl 100% 43MB 10.7MB/s 00:04
6. [Standby] Bring up the instance in nomount mode:
SQL> startup nomount
7. [Standby] Check the location of the controlfile:
SQL> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/oradata/standby_cntfile.ctl
8. [Standby] Replace the controlfile with the one you just created in primary.
9. $ cp /u01/oraback/DEL1_standby.ctl /u01/oradata/standby_cntfile.ctl
10.[Standby] Mount the standby database:
SQL> alter database mount standby database;
11.[Standby] RMAN does not know about these files yet; so you must let it know – by a process called cataloging. Catalog these files:
$ rman target=/
Recovery Manager: Release 10.2.0.4.0 - Production on Fri Dec 18 06:44:25 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: DEL1 (DBID=846390698, not open)
RMAN> catalog start with '/u01/oraback';
using target database control file instead of recovery catalog
searching for all files that match the pattern /u01/oraback
List of Files Unknown to the Database
=====================================
File Name: /u01/oraback/DEL1_standby.ctl
File Name: /u01/oraback/06l16u1q_1_1.rmb
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/oraback/DEL1_standby.ctl
File Name: /u01/oraback/06l16u1q_1_1.rmb
12.Recover these files:
RMAN> recover database;
######################################################################################################################3
@gridconf:
---------
groupadd -g 1000 oinstall
groupadd -g 1020 asmadmin
groupadd -g 1021 asmdba
groupadd -g 1031 dba
groupadd -g 1022 asmoper
groupadd -g 1023 oper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,dba,asmoper grid
useradd -u 1101 -g oinstall -G dba,asmdba,oper oracle
passwd oracle
passwd grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oraInventory
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/oracle
chown -R grid:oinstall /u01/app/11.2.0/grid
chown -R grid:oinstall /u01/app/grid
chown -R oracle:oinstall /u01/app/oracle
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
chmod -R 775 /u01/app/grid
fdisk /dev/sdb
echo "- - -" > /sys/class/scsi_host/host0/scan
/etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
/etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
/etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
chown grid:asmadmin /dev/sdb1
chmod 660 /dev/sdb1
chown grid:asmadmin /dev/sdc1
chmod 660 /dev/sdc1
chown grid:asmadmin /dev/sdd1
chmod 660 /dev/sdd1
#################################################################################
/sbin/ifconfig
netstat -l
#################################################################################
librarycacheinfo:
-----------------
SELECT NAMESPACE, GETS, PINS, GETHITRATIO FROM V$LIBRARYCACHE;
SELECT S.NAME, V.VALUE FROM V$STATNAME S, V$MYSTAT V WHERE S.STATISTIC# = V.STATISTIC# AND S.NAME LIKE 'parse%';
########################################################################################
@whentorebuild:
--------------
If the index has height greater than four, rebuild the index
The deleted leaf rows should be less than 20%.
SELECT name, height, lf_rows, del_lf_rows, (del_lf_rows/lf_rows)*100 as ratio FROM INDEX_STATS;
ANALYZE INDEX <IDX_GAM_FID> VALIDATE STRUCTURE;
ALTER INDEX <> REBULD REBUILD ONLINE;
###################################################################################################
sqltuningadvisor:
-----------------
CONNECT / AS SYSDBA
GRANT ADVISOR TO SH;
1.CONNECT sh@TESTDB/sh
2.Define an SQL Tuning Task for a single query:
DECLARE
l_task VARCHAR2(30);
l_sql CLOB;
BEGIN
l_sql := 'SELECT AMOUNT_SOLD FROM sh.SALES S ' ||
'WHERE S.CUST_ID IN ( '||
'SELECT C.CUST_ID FROM sh.CUSTOMERS C ' ||
'WHERE C.CUST_CREDIT_LIMIT IN (:l1, :l2, :l3))';
l_task := DBMS_SQLTUNE.CREATE_TUNING_TASK(
sql_text => l_sql,
bind_list => sql_binds(anydata.ConvertNumber(10000),
anydata.ConvertNumber(11000),
anydata.ConvertNumber(15000)),
user_name => 'SH',
scope => 'COMPREHENSIVE',
time_limit => 120,
task_name => 'test_tuning_task',
description => 'Specific SQL tuning');
END;
/
3. Execute the SQL Tuning Task just defined:
BEGIN
DBMS_SQLTUNE.EXECUTE_TUNING_TASK(task_name => 'test_tuning_task');
END;
/
4. View the results of the tuning process:
SET LINESIZE 120
SET LONG 1000
SET LONGCHUNKSIZE 1000
SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK('test_tuning_task')
FROM DUAL;
5. Drop the SQL Tuning Task and revoke grants from user SH:
EXEC DBMS_SQLTUNE.DROP_TUNING_TASK('test_tuning_task');
CONNECT / AS SYSDBA
REVOKE ADVISOR FROM SH;
################################################################################################################################3
@cachetable:
----------
ALTER TABLE SH.CUSTOMERS STORAGE (BUFFER_POOL KEEP);
@objinbuffer:
------------
COL OBJECT_NAME FOR A30
COL OBJECT_TYPE FOR A20
SELECT OBJECT_NAME, OBJECT_TYPE, COUNT(*) AS "buffers"
FROM SYS.X$BH XBH, SYS.DBA_OBJECTS OBJ
WHERE XBH.OBJ = OBJ.OBJECT_ID
AND OWNER = 'SH'
GROUP BY OBJECT_TYPE, OBJECT_NAME
ORDER BY OBJECT_TYPE, OBJECT_NAME;
v$db_object_cache:
select owner,name,type,sharable_mem from v$db_object_cache where kept='YES';
#############################################################################################################################
bufferbusyavoid:
---------------
User Action
Look at v$waitstat (or the buffer busy drill down page) and determine the block type with the highest waits.
Block Type and Action:
Undo Header - Use Automatic Undo Management (AUM) or add more RBS segments)
Undo Block - Use AUM (or increase RBS sizes)
Data Block - First determine if it is an I/O problem. The Buffer Busy Waits drill-down page should provide this information. Otherwise, sample from v$session_wait
SELECT p3, count(*) FROM v$session_wait WHERE event='buffer busy wait' group by p3;
If p3 is less than 200 then it is an I/O problem. Either improve I/O performance or change application. Applications running concurrent batch jobs that do full table scans on the same large tables run into this problem.
Free List - Use ASSM (or freelists groups)
http://www.oracledba.in/Articles/display_article.aspx?article_id=53
http://www.dba-oracle.com/art_builder_bbw.htm
#################################################################
indpartition:
-------------
select index_name from dba_indexes where table_name='MTC_MSG_TXT_CBS';
select INDEX_OWNER,INDEX_NAME,PARTITION_NAME,STATUS,TABLESPACE_NAME from dba_ind_partitions where INDEX_NAME='MTC_MSG_TXT_CBS_IDX';
sys@RTGSSFMS2> select INDEX_OWNER,INDEX_NAME,PARTITION_NAME,STATUS,TABLESPACE_NAME from dba_ind_partitions where INDEX_NAME='MTC_MSG_TXT_CBS_IDX';
INDEX_OWNER INDEX_NAME PARTITION_NAME STATUS TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------ -------- ------------------------------
SFMSBR MTC_MSG_TXT_CBS_IDX P1 USABLE SFMS_BR_NDX
SFMSBR MTC_MSG_TXT_CBS_IDX P2 USABLE SFMS_BR_NDX
SFMSBR MTC_MSG_TXT_CBS_IDX P3 USABLE SFMS_BR_NDX
alter index SFMSBR.MTC_MSG_TXT_CBS_IDX rebuild partition p1 online;
alter index SFMSBR.MTC_MSG_TXT_CBS_IDX rebuild partition p2 online;
alter index SFMSBR.MTC_MSG_TXT_CBS_IDX rebuild partition p3 online;
ALTER INDEX indexName MONITORING USAGE;
V$OBJECT_USAGE
#################################################################################################################
@pointintimerecovery:
--------------
RMAN> recover tablespace "TEST" until SCN 4515327 auxiliary destination '+DATA';
select timestamp_to_scn(sysdate) from dual;
#########################################################################
@optredo:
-------------
The default size of the redo log buffer is calculated as follows:
MAX(0.5M, (128K * number of cpus))
#####################################################################################################################
ourskil:
select sql_id,hash_value,plan_hash_value from v$sql where sql_text='select * from scott.dept where deptno=40';
#################################################################################################################
@oskill:
$ kill -9 `ps -ef | grep LOCAL=YES | grep -v grep | awk '{print $2}'`
##################################################################################################################3
shrink:
set linesize 1000 pagesize 0 feedback off trimspool on
with
hwm as (
-- get highest block id from each datafiles ( from x$ktfbue as we don't need all joins from dba_extents )
select /*+ materialize */ ktfbuesegtsn ts#,ktfbuefno relative_fno,max(ktfbuebno+ktfbueblks-1) hwm_blocks
from sys.x$ktfbue group by ktfbuefno,ktfbuesegtsn
),
hwmts as (
-- join ts# with tablespace_name
select name tablespace_name,relative_fno,hwm_blocks
from hwm join v$tablespace using(ts#)
),
hwmdf as (
-- join with datafiles, put 5M minimum for datafiles with no extents
select file_name,nvl(hwm_blocks*(bytes/blocks),5*1024*1024) hwm_bytes,bytes,autoextensible,maxbytes
from hwmts right join dba_data_files using(tablespace_name,relative_fno)
)
select
case when autoextensible='YES' and maxbytes>=bytes
then -- we generate resize statements only if autoextensible can grow back to current size
'/* reclaim '||to_char(ceil((bytes-hwm_bytes)/1024/1024),999999)
||'M from '||to_char(ceil(bytes/1024/1024),999999)||'M */ '
||'alter database datafile '''||file_name||''' resize '||ceil(hwm_bytes/1024/1024)||'M;'
else -- generate only a comment when autoextensible is off
'/* reclaim '||to_char(ceil((bytes-hwm_bytes)/1024/1024),999999)
||'M from '||to_char(ceil(bytes/1024/1024),999999)
||'M after setting autoextensible maxsize higher than current size for file '
|| file_name||' */'
end SQL
from hwmdf
where
bytes-hwm_bytes>1024*1024 -- resize only if at least 1MB can be reclaimed
order by bytes-hwm_bytes desc
/
###############################################
cloneraj:
--------
1 Take backup of source database
2. Copy backup pieces to target host machine.
3. Create pfile from spfile (source machine)
create pfile='<path/init<service>.ora' from spfile;
4. Copy pfile to target machine ($ORACLE_HOME/dbs/)
5. Remove all entries related to instance 2
6. Change cluster_database=false
*.cluster_database=false
7. Specify the contorl file path in pfile
*.control_files=
'+REDO01/<DBNAME>/CONTROLFILE/ctrl01.dbf',
'+REDO02/<DBNAME>/CONTROLFILE/ctrl02.dbf'
8. Change DB_NAME to duplicater DB name and db_create_file_dest='+DATADG'
8. Change instane_number =1
<DBNAME>.instance_number=1
9. Add entry for remote_listener in pfile
*.remote_listener='ptrandr-scan.mcsl.in:1526'
MPUTDB.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=10.88.11.21)(PORT=1526))'
10. Create password file for target database.
orapwd file=/oracle/product/11.2.0/db/dbs/orapw<DBNAME> password=<password> entries=10
11. Create adump dir in target server
mkdir -p /oracle/product/admin/<DBNAME>/adump
12. Setup the environment variables and startup nomount
ORACLE_SID=<DB_NAME>; export ORACLE_SID
sqlplus / as sysdba
STARTUP NOMOUNT;
exit
13.Connect RMAN with Auxiliary database
rman AUXILIARY /
RMAN>DUPLICATE DATABASE TO MPSWSDB
BACKUP LOCATION '/DBtemp/070914/MPPWSDB_20140907/';
for standby :-
DUPLICATE TARGET DATABASE
FOR STANDBY BACKUP LOCATION '/DBtemp/MPPBSDB/' ;
DUPLICATE TARGET DATABASE FOR STANDBY BACKUP LOCATION '/DBtemp/MPPBSDB/'
DB_FILE_NAME_CONVERT='+DATA','+DATADG';
14. Once duplication complete, you would get error in alert log that unable to create spfile.
15. Stop database and restart with pfile.
RMAN> shutdown database
16.Startup the database from pfile.
17. Create spfile from pfile.
CREATE SPFILE='+DATA/<DBNAME>/spfile<DBNAME>.ora' from pfile;
18. Edit pfile with spfile entry.
SPFILE='+DATA/<DBNAME>/spfile<DBNAME>.ora'
19. Unregister and Register DB
srvctl add database -d <DBNAME> -o /oracle/product/11.2.0/db -c RACONENODE -i <INSTANCE_NAME> -e mcslin-mum-air-dr-ptrandb1.mcsl.in
20. Start DB with srvctl
srvctl start database -d <DBNAME>
######################################################################3
@dytbs:
-----------
select 'create tablespace ' || df.tablespace_name || chr(10)
|| ' datafile ''' || df.file_name || ''' size ' || df.bytes
|| decode(autoextensible,'N',null, chr(10) || ' autoextend on maxsize '
|| maxbytes)
|| chr(10)
|| 'default storage ( initial ' || initial_extent
|| decode (next_extent, null, null, ' next ' || next_extent )
|| ' minextents ' || min_extents
|| ' maxextents ' || decode(max_extents,'2147483645','unlimited',max_extents)
|| ') ;'
from dba_data_files df, dba_tablespaces t
where df.tablespace_name=t.tablespace_name
/
######################################################################################
@order:
--------
bash-4.2$ cat order.sql
set serveroutput on size 50000
set echo off feed off veri off
accept SID prompt 'Enter Oracle SID: '
DECLARE
v_sid number;
s sys.v_$session%ROWTYPE;
p sys.v_$process%ROWTYPE;
BEGIN
begin
select sid into v_sid
from sys.v_$session s
where sid = &&SID;
exception
when no_data_found then
dbms_output.put_line('Unable to find SID &&SID!!!');
return;
when others then
dbms_output.put_line(sqlerrm||'naaaaaaaaaaaaaaaaaaaaa');
return;
end;
select * into s from sys.v_$session where sid = v_sid;
select * into p from sys.v_$process where addr = s.paddr;
dbms_output.put_line('=====================================================================');
dbms_output.put_line('SID/Serial : '|| s.sid||','||s.serial#);
dbms_output.put_line('Foreground : '|| 'PID: '||s.process||' - '||s.program);
dbms_output.put_line('Shadow : '|| 'PID: '||p.spid||' - '||p.program);
dbms_output.put_line('Terminal : '|| s.terminal || '/ ' || p.terminal);
dbms_output.put_line('OS User : '|| s.osuser||' on '||s.machine);
dbms_output.put_line('Ora User : '|| s.username);
dbms_output.put_line('Status Flags: '|| s.status||' '||s.server||' '||s.type);
dbms_output.put_line('Tran Active : '|| nvl(s.taddr, 'NONE'));
dbms_output.put_line('Login Time : '|| to_char(s.logon_time, 'Dy HH24:MI:SS'));
dbms_output.put_line('Last Call : '|| to_char(sysdate-(s.last_call_et/60/60/24), 'Dy HH24:MI:SS') || ' - ' || to_char(s.last_call_et/60, '9999999999.0') || ' min');
dbms_output.put_line('Lock/ Latch : '|| nvl(s.lockwait, 'NONE')||'/ '||nvl(p.latchwait, 'NONE'));
dbms_output.put_line('Latch Spin : '|| nvl(p.latchspin, 'NONE'));
dbms_output.put_line('Current SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.sql_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Previous SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.prev_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Session Waits:');
for c1 in ( select * from sys.v_$session_wait where sid = s.sid) loop
dbms_output.put_line(chr(9)||c1.state||': '||c1.event);
end loop;
dbms_output.put_line('Connect Info:');
for c1 in ( select * from sys.v_$session_connect_info where sid = s.sid) loop
dbms_output.put_line(chr(9)||': '||c1.network_service_banner);
end loop;
dbms_output.put_line('Locks:');
for c1 in ( select
decode(l.type,
-- Long locks
'TM', 'DML/DATA ENQ', 'TX', 'TRANSAC ENQ',
'UL', 'PLS USR LOCK',
-- Short locks
'BL', 'BUF HASH TBL', 'CF', 'CONTROL FILE',
'CI', 'CROSS INST F', 'DF', 'DATA FILE ',
'CU', 'CURSOR BIND ',
'DL', 'DIRECT LOAD ', 'DM', 'MOUNT/STRTUP',
'DR', 'RECO LOCK ', 'DX', 'DISTRIB TRAN',
'FS', 'FILE SET ', 'IN', 'INSTANCE NUM',
'FI', 'SGA OPN FILE',
'IR', 'INSTCE RECVR', 'IS', 'GET STATE ',
'IV', 'LIBCACHE INV', 'KK', 'LOG SW KICK ',
'LS', 'LOG SWITCH ',
'MM', 'MOUNT DEF ', 'MR', 'MEDIA RECVRY',
'PF', 'PWFILE ENQ ', 'PR', 'PROCESS STRT',
'RT', 'REDO THREAD ', 'SC', 'SCN ENQ ',
'RW', 'ROW WAIT ',
'SM', 'SMON LOCK ', 'SN', 'SEQNO INSTCE',
'SQ', 'SEQNO ENQ ', 'ST', 'SPACE TRANSC',
'SV', 'SEQNO VALUE ', 'TA', 'GENERIC ENQ ',
'TD', 'DLL ENQ ', 'TE', 'EXTEND SEG ',
'TS', 'TEMP SEGMENT', 'TT', 'TEMP TABLE ',
'UN', 'USER NAME ', 'WL', 'WRITE REDO ',
'TYPE='||l.type) type,
decode(l.lmode, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
4, 'S', 5, 'RSX', 6, 'X',
to_char(l.lmode) ) lmode,
decode(l.request, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
4, 'S', 5, 'RSX', 6, 'X',
to_char(l.request) ) lrequest,
decode(l.type, 'MR', o.object_name,
'TD', o.object_name,
'TM', o.object_name,
'RW', 'FILE#='||substr(l.id1,1,3)||
' BLOCK#='||substr(l.id1,4,5)||' ROW='||l.id2,
'TX', 'RS+SLOT#'||l.id1||' WRP#'||l.id2,
'WL', 'REDO LOG FILE#='||l.id1,
'RT', 'THREAD='||l.id1,
'TS', decode(l.id2, 0, 'ENQUEUE', 'NEW BLOCK ALLOCATION'),
'ID1='||l.id1||' ID2='||l.id2) objname
from sys.v_$lock l, dba_objects o
where sid = s.sid
and l.id1 = o.object_id(+) ) loop
dbms_output.put_line(chr(9)||c1.type||' H: '||c1.lmode||' R: '||c1.lrequest||' - '||c1.objname);
end loop;
dbms_output.put_line('=====================================================================');
END;
/
undef SID
===============================================
@movedatafile:
RMAN> ;
RMAN> SQL 'ALTER TABLESPACE soe OFFLINE';
Switch to the new datafile copy(s) and recover the tablespace.
RMAN> SWITCH DATAFILE 8 TO COPY;
RMAN> RECOVER TABLESPACE soe;
RMAN> SQL 'ALTER TABLESPACE soe ONLINE';
===================================================================================
@cloneothersid:
run{
backup database format '/u01/rmanbkp/rman_full_%d_%s_%p';
backup archivelog all format '/u01/rmanbkp/rman_full_arc_%d_%s_%p';
}
======ready pfile==========
do changes accoring ====> rman auxiliary /
run {
SET NEWNAME FOR DATABASE TO '/u01/app/oracle/oradata/orcl/%b';
SET NEWNAME FOR TEMPFILE 1 TO '/u01/app/oracle/oradata/orcl/temp01.dbf' ;
DUPLICATE DATABASE 'RMG' DBID 1604518329 TO ORCL BACKUP LOCATION '/u01/rmanbkp/'
LOGFILE
GROUP 1 ('/u01/app/oracle/oradata/orcl/redo01a.log',
'/u01/app/oracle/oradata/orcl/redo01b.log') SIZE 50M REUSE,
GROUP 2 ('/u01/app/oracle/oradata/orcl/redo02a.log',
'/u01/app/oracle/oradata/orcl/redo02b.log') SIZE 50M REUSE,
GROUP 3 ('/u01/app/oracle/oradata/orcl/redo03a.log',
'/u01/app/oracle/oradata/orcl/redo03b.log') SIZE 50M REUSE;
}
===============================================================================================
The following variables are introduced for SET NEWNAME from 11gR2 :-
%b The file name remains same as the original. For example, if a datafile is named D:\oracle\oradata\matrix\test.dbf, then %b results in test.dbf.
%f Specifies the absolute file number of the datafile for which the new name is generated.
%I Specifies the DBID.
%N Specifies the tablespace name.
%U Specifies the following format: data-D-%d_id-%I_TS-%N_FNO-%f.
===============================================================================================
@allfiles
=========
select name from v$tempfile
union
select member from v$logfile
union
select name from v$datafile
union
select name from v$controlfile;
======================================
@licence: http://www.jobacle.nl/?p=583
select 'set newname for datafile '||file#||' to '''||replace(name,'/u01/app/oracle/oradata/orcl/','/data10/oradata/DEVDBNEW/')||''';' from v$datafile;
====================================
@dbfilecreation
col name for a50
select d.creation_time,d.name,t.name from v$datafile d,v$tablespace t where d.ts#=t.ts# order by 1;
================================
@pass prod & Uat -->oracle-->$4oraTB@storage
===============================
@asm
set wrap off
set lines 155 pages 9999
col "Group Name" for a6 Head "Group|Name"
col "Disk Name" for a10
col "State" for a10
col "Type" for a10 Head "Diskgroup|Redundancy"
col "Total GB" for 9,990 Head "Total|GB"
col "Free GB" for 9,990 Head "Free|GB"
col "Imbalance" for 99.9 Head "Percent|Imbalance"
col "Variance" for 99.9 Head "Percent|Disk Size|Variance"
col "MinFree" for 99.9 Head "Minimum|Percent|Free"
col "MaxFree" for 99.9 Head "Maximum|Percent|Free"
col "DiskCnt" for 9999 Head "Disk|Count"
prompt
prompt ASM Disk Groups
prompt ===============
SELECT g.group_number "Group"
, g.name "Group Name"
, g.state "State"
, g.type "Type"
, g.total_mb/1024 "Total GB"
, g.free_mb/1024 "Free GB"
, 100*(max((d.total_mb-d.free_mb)/d.total_mb)-min((d.total_mb-d.free_mb)/d.total_mb))/max((d.total_mb-d.free_mb)/d.total_mb) "Imbalance"
, 100*(max(d.total_mb)-min(d.total_mb))/max(d.total_mb) "Variance"
, 100*(min(d.free_mb/d.total_mb)) "MinFree"
, 100*(max(d.free_mb/d.total_mb)) "MaxFree"
, count(*) "DiskCnt"
FROM v$asm_disk d, v$asm_diskgroup g
WHERE d.group_number = g.group_number and
d.group_number <> 0 and
d.state = 'NORMAL' and
d.mount_status = 'CACHED'
GROUP BY g.group_number, g.name, g.state, g.type, g.total_mb, g.free_mb
ORDER BY 1;
prompt ASM Disks In Use
prompt ================
col "Group" for 999
col "Disk" for 999
col "Header" for a9
col "Mode" for a8
col "State" for a8
col "Created" for a10 Head "Added To|Diskgroup"
--col "Redundancy" for a10
--col "Failure Group" for a10 Head "Failure|Group"
col "Path" for a19
--col "ReadTime" for 999999990 Head "Read Time|seconds"
--col "WriteTime" for 999999990 Head "Write Time|seconds"
--col "BytesRead" for 999990.00 Head "GigaBytes|Read"
--col "BytesWrite" for 999990.00 Head "GigaBytes|Written"
col "SecsPerRead" for 9.000 Head "Seconds|PerRead"
col "SecsPerWrite" for 9.000 Head "Seconds|PerWrite"
select group_number "Group"
, disk_number "Disk"
, header_status "Header"
, mode_status "Mode"
, state "State"
, create_date "Created"
--, redundancy "Redundancy"
, total_mb/1024 "Total GB"
, free_mb/1024 "Free GB"
, name "Disk Name"
--, failgroup "Failure Group"
, path "Path"
--, read_time "ReadTime"
--, write_time "WriteTime"
--, bytes_read/1073741824 "BytesRead"
--, bytes_written/1073741824 "BytesWrite"
, read_time/reads "SecsPerRead"
, write_time/writes "SecsPerWrite"
from v$asm_disk_stat
where header_status not in ('FORMER','CANDIDATE')
order by group_number
, disk_number
/
Prompt File Types in Diskgroups
Prompt ========================
col "File Type" for a16
col "Block Size" for a5 Head "Block|Size"
col "Gb" for 9990.00
col "Files" for 99990
break on "Group Name" skip 1 nodup
select g.name "Group Name"
, f.TYPE "File Type"
, f.BLOCK_SIZE/1024||'k' "Block Size"
, f.STRIPED
, count(*) "Files"
, round(sum(f.BYTES)/(1024*1024*1024),2) "Gb"
from v$asm_file f,v$asm_diskgroup g
where f.group_number=g.group_number
group by g.name,f.TYPE,f.BLOCK_SIZE,f.STRIPED
order by 1,2;
clear break
prompt Instances currently accessing these diskgroups
prompt ==============================================
col "Instance" form a8
select c.group_number "Group"
, g.name "Group Name"
, c.instance_name "Instance"
from v$asm_client c
, v$asm_diskgroup g
where g.group_number=c.group_number
/
prompt Free ASM disks and their paths
prompt ==============================
col "Disk Size" form a9
select header_status "Header"
, mode_status "Mode"
, path "Path"
, lpad(round(os_mb/1024),7)||'Gb' "Disk Size"
from v$asm_disk
where header_status in ('FORMER','CANDIDATE')
order by path
/
prompt Current ASM disk operations
prompt ===========================
select *
from v$asm_operation
/
This is how some of the changes look
Added To Total Free Seconds Seconds
Group Disk Header Mode State Diskgroup GB GB Disk Name Path PerRead PerWrite
----- ---- --------- -------- -------- ---------- ------ ------ ---------- ------------------- ------- --------
1 0 MEMBER ONLINE NORMAL 20-FEB-09 89 88 FRA_0000 /dev/oracle/disk388 .004 .002
1 1 MEMBER ONLINE NORMAL 31-MAY-10 89 88 FRA_0001 /dev/oracle/disk260 .002 .002
1 2 MEMBER ONLINE NORMAL 31-MAY-10 89 88 FRA_0002 /dev/oracle/disk260 .007 .002
2 15 MEMBER ONLINE NORMAL 04-MAR-10 89 29 DATA_0015 /dev/oracle/disk203 .012 .023
2 16 MEMBER ONLINE NORMAL 04-MAR-10 89 29 DATA_0016 /dev/oracle/disk203 .012 .021
2 17 MEMBER ONLINE NORMAL 04-MAR-10 89 29 DATA_0017 /dev/oracle/disk203 .007 .026
2 27 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0027 /dev/oracle/disk260 .011 .023
2 28 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0028 /dev/oracle/disk259 .009 .020
2 38 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0038 /dev/oracle/disk190 .012 .025
2 39 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0039 /dev/oracle/disk189 .014 .015
2 40 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0040 /dev/oracle/disk260 .011 .024
2 41 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0041 /dev/oracle/disk260 .009 .022
2 42 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0042 /dev/oracle/disk260 .011 .018
2 43 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0043 /dev/oracle/disk260 .003 .026
2 44 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0044 /dev/oracle/disk260 .008 .019
2 45 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0045 /dev/oracle/disk193 .008 .018
2 46 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0046 /dev/oracle/disk192 .007 .024
2 47 MEMBER ONLINE NORMAL 31-MAY-10 89 30 DATA_0047 /dev/oracle/disk191 .005 .022
2 48 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0048 /dev/oracle/disk190 .008 .021
2 49 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0049 /dev/oracle/disk189 .008 .026
2 50 MEMBER ONLINE NORMAL 31-MAY-10 89 29 DATA_0050 /dev/oracle/disk261 .009 .030
56 rows selected.
File Types in Diskgroups
========================
Group Block
Name File Type Size STRIPE Files Gb
------ ---------------- ----- ------ ------ --------
DATA CONTROLFILE 16k FINE 1 0.01
DATAFILE 16k COARSE 404 2532.58
ONLINELOG 1k FINE 3 6.00
PARAMETERFILE 1k COARSE 1 0.00
TEMPFILE 16k COARSE 13 440.59
FRA AUTOBACKUP 16k COARSE 2 0.02
CONTROLFILE 16k FINE 1 0.01
ONLINELOG 1k FINE 3 6.00
@diskindiskgroup
SELECT SUBSTR(d.name,1,16) AS asmdisk, d.mount_status, d.state,dg.name AS diskgroup FROM V$ASM_DISKGROUP dg, V$ASM_DISK d WHERE dg.group_number = d.group_number;
@pathstatus
col PATH for a40
select PATH, HEADER_STATUS, MODE_STATUS, STATE from v$asm_disk;
/
@mountstate
select inst_id,path,mount_status,header_status from gv$asm_disk where path='/dev/rhdisk17';
=====
@digasm
/etc/init.d/oracleasm listdisks
out:DSK1
/etc/init.d/oracleasm querydisk -d dsk1
out:Disk "DSK1" is a valid ASM disk on device [8, 17]
ls -l /dev |grep 8|grep 17
out:brw-r----- 1 root disk 8, 17 Aug 10 13:05 sdb1
==========================================
@renamedatafileasm
RMAN> COPY DATAFILE '+DATA/sfms/datafile/users.290.930691959' to '+DATA/sfms/datafile/users.dbf';
RMAN> switch datafile '+DATA/sfms/datafile/users.290.930691959' to copy;
RMAN> recover datafile 5;
SQL> alter database datafile 5 online;
======================================
@isdynamicparameter
select name,isses_modifiable,issys_modifiable,isinstance_modifiable from v$parameter where name like '&memory_max_target'
==============================
@cpuinfo
nproc
/proc/cupinfo
/proc/meminfo
======================
@tophelp
l âTo display or to hide load average line
t âTo display or to hide task/cpu line
1 âTo display or hide all other CPUâs
m âto display or to hide RAM and SWAP details
s âTo change the time interval for updating top results(value is in secâs)
R âTo sort by PID number
u â Press u then username to get only that user process details
P âTo sort by CPU utilization
M âTo sort by RAM utilization
c âTo display or hide command full path
r âTo renice a process, press r then the PID no then the renice value to renice a process.
k âTo kill a process, press k then PID number then enter to kill a process
w âTo save the modified configuration permanently.
q âTo quit the top command.
h âfor getting help on top command
=======================================================
@shrink
set verify off
column file_name format a50 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings format 999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report
column value new_val blksize
select value from v$parameter where name = 'db_block_size';
/
select file_name,
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest,
ceil( blocks*&&blksize/1024/1024) currsize,
ceil( blocks*&&blksize/1024/1024) -
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savings
from dba_data_files a,
( select file_id, max(block_id+blocks-1) hwm
from dba_extents
group by file_id ) b
where a.file_id = b.file_id(+) order by savings desc
/
=================================================
@activeuserlist:
select username,account_status,default_tablespace from dba_users where username not in('XDB',
'TSMSYS',
'TRACESVR',
'SYSTEM',
'SYS',
'SCOTT',
'ADAMS',
'JONES',
'CLARK',
'BLAKE',
'PERFSTAT',
'OUTLN',
'ORDSYS',
'ORDPLUGINS',
'ORACLE_OCM',
'MDSYS',
'LBACSYS',
'HR',
'OE',
'SH',
'EXFSYS',
'DSSYS',
'DMSYS',
'DIP',
'DEMO',
'DBSNMP',
'CTXSYS',
'CSMIG',
'AWR_STAGE',
'AURORA$ORB$UNAUTHENTICATED',
'ANONYMOUS') and account_status='OPEN';
==============================================
@multiblockreadcount
The formula for calculating DB_FILE_MULTIBLOCK_READ_COUNT is:
db_file_multiblock_read_count = min(max I/O size/db_block_size , db_cache_size/(sessions * db_block_size))
Note: Max I/O size is platform-dependent and equal to 1MB for most platforms
========================================================================================================================
@large table
col owner format a15
col segment_name format a30
col segment_type format a15
col gb format 999,999,999
select owner
, segment_name
, segment_type
, gb
from (
select owner
, segment_name
, segment_type
, bytes / 1024 / 1024 / 1024 gb
from dba_segments
where segment_type = 'TABLE'
order by bytes desc
)
where rownum < 10;
/
===========================================================================================================
@setdate in linux
date -s "05JAN2017 11:38:00"
=====================================================================
@sysdbausers
select * from v$pwfile_users
=====================================================================
@multiplearchivedest
log_archive_duplex_dest='path'
======================
@centos
https://wiki.centos.org/HowTos/Oracle12onCentos7
==================================================
@workshop
http://dbaworkshop.blogspot.in/p/recovery-scenarios_5.html
=====================
@image
rman> list copy of database;
==========================
@checkpoint&scn
select sequence#,first_change#,next_change#,first_time from v$archived_log order by first_time;
========================================================
@lastscn
select sequence#,first_change#,next_change#,first_time,status from v$log where status='CURRENT';
==============================
@resetlogs
http://www.dba-oracle.com/t_rman_71_recover_previous_incarnation.htm
=============================
@restore not done; all files read only, offline, or already restored
sol:restore tablespace example force;
===============================
@incarnation
RMAN> list incarnation of database;
SQL> select incarnation#, resetlogs_change# from v$database_incarnation;
*****************
RMAN> shutdown immediate
RMAN> startup mount
RMAN> reset database to incarnation 2;
database reset to incarnation 2
===================================
RMAN> list archivelog all
===================================
@recreate controlfile creation
CREATE CONTROLFILE REUSE DATABASE "EWSTEST" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo1.log' SIZE 30M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo2.log' SIZE 30M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo3.log' SIZE 30M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/system.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/sysaux.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/undo.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/example01.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/example02.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/bil03.dbf'
CHARACTER SET US7ASCII
;
=====================================
@changedbname
CREATE CONTROLFILE REUSE SET DATABASE "EWSTEST" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo1.log' SIZE 30M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo2.log' SIZE 30M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/redo3.log' SIZE 30M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/system.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/sysaux.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/undo.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/example01.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/example02.dbf',
'/u01/app/oracle/product/11.2.0/db_1/oradata/EWSTEST/bil03.dbf'
CHARACTER SET US7ASCII
;
==============================
@rmgrep
ls | grep chrome | xargs rm
==============================
@rowcount in table
select 'select count(*) from '||table_name||';' from dba_tables where owner = '&OWNER';
============or==================
DECLARE
val NUMBER;
BEGIN
FOR I IN (SELECT TABLE_NAME FROM USER_TABLES) LOOP
EXECUTE IMMEDIATE 'SELECT count(*) FROM ' || i.table_name INTO val;
DBMS_OUTPUT.PUT_LINE(i.table_name || ' ==> ' || val );
END LOOP;
END;
/
===============or======================
set pages 999;
col count format 999,999,999;
spool countlist.txt
select
table_name,
to_number(
extractvalue(
xmltype(
dbms_xmlgen.getxml('select count(*) c from '||table_name))
,'/ROWSET/ROW/C')) count
from
user_tables
order by
table_name;
==============================================================================
@setscn
SQL> shutdown immediate
SQL>startup mount
RMAN> run
{
set until scn=547891;
restore database;
recover database;
}
RMAN> alter database open resetlogs;
=========================
@minold
find . -mmin 3 #exactly 3 minutes old
find . -mmin +3 #more than 3 minutes old
find . -mmin -3 #less than 3 minutes old.
find . -mmin -360 #less than 6 hours old
=============================================
@sessionprivs
select * from session_privs;
=============================================
@restrictsysdba
SQLNET.AUTHENTICATION_SERVICES=(NONE)
============================================
@lastddl
SELECT LAST_DDL_TIME, TIMESTAMP
FROM USER_OBJECTS
WHERE OBJECT_TYPE = 'PROCEDURE'
AND OBJECT_NAME = 'MY_PROC';
=====================================
@wildel
ls -ltr o1_mf_1_2[5-7]*
rm -rf o1_mf_1_2[5-7]*
======================================
@maxtran SELECT ini_trans, max_trans from dba_tables WHERE table_name = 'TEST' ;
==================================================================================
@degreegather
BEGIN
SYS.DBMS_STATS.GATHER_TABLE_STATS (
OwnName => 'MK2'
,TabName => 'MIG_CASENAME'
,Degree => 4
,Cascade => TRUE
,No_Invalidate => FALSE);
END;
=========================================================
@arup
select sid, state, event
from v$session
where username = '&ARUP';
SID STATE EVENT
————— ————————————————— ————————————————————————————
2832 WAITED KNOWN TIME SQL*Net message from client
3346 WAITING enq: TX - row lock contention
----------------------------------------------------------------
col "Description" format a50
select sid,
decode(state, 'WAITING','Waiting',
'Working') state,
decode(state,
'WAITING',
'So far '||seconds_in_wait,
'Last waited '||
wait_time/100)||
' secs for '||event
"Description"
from v$session
where username = '&ARUP';
Output:
SID STATE Description
————— —————————— ———————————————————————————————————————————————————————
2832 Working Last waited 2029 secs for SQL*Net message from client
3346 Waiting So far 743 secs for enq: TX - row lock contention
4208 Waiting So far 5498 secs for SQL*Net message from client
----------------------------------------------------
select
blocking_session B_SID,
blocking_instance B_Inst
from v$session
where sid = &3346;
B_SID B_INST
—————— ———————
2832 1
----------------------------------------------------------
select row_wait_obj#,
row_wait_file#,
row_wait_block#,
row_wait_row#
from v$session
where sid = &3346;
ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW#
————————————— —————————————— ———————————————— ——————————————
241876 1024 2307623 0
-----------------------------------------------------------------------
select owner, object_type, object_name, data_object_id
from dba_objects
where object_id = &241876;
OWNER OBJECT_TYPE OBJECT_NAME DATA_OBJECT_ID
————— ———————————— ———————————— ——————————————
ARUP TABLE T1 241877
------------------------------------------------------------
select SID, osuser, machine, terminal, service_name,
logon_time, last_call_et
from v$session
where username = '&ARUP';
-------------------------------------------------------------
col username format a5
col program format a10
col state format a10
col last_call_et head 'Called|secs ago' format 999999
col seconds_in_wait head 'Waiting|for secs' format 999999
col event format a50
select sid, username, program,
decode(state, 'WAITING', 'Waiting',
'Working') state,
last_call_et, seconds_in_wait, event
from v$session
where machine = '&appsvr1'
-------------------------------------------------
select event
from v$session
where sid = &3011;
---------------------------------
@releaase
cat /etc/redhat-release
------------------------------------
@expirepassword
create user manoj identified by manoj1 password expire;
====================================================================
@nonasmtoasm
SQL> select name from v$database;
NAME
---------
YYAPRD
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------
/u04/oradata/YYAPRD/system01.dbf
/u04/oradata/YYAPRD/sysaux01.dbf
/u04/oradata/YYAPRD/undotbs01.dbf
/u04/oradata/YYAPRD/users01.dbf
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------
/u04/oradata/YYAPRD/temp01.dbf
SQL> col member form a50
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------
/u02/oradata/YYAPRD/redo01a.log
/u03/oradata/YYAPRD/redo01b.log
/u02/oradata/YYAPRD/redo02a.log
/u03/oradata/YYAPRD/redo02b.log
/u02/oradata/YYAPRD/redo03a.log
/u03/oradata/YYAPRD/redo03b.log
6 rows selected.
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
.3/dbs/spfileYYAPRD.ora
SQL> show parameter control_file
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/oradata/YYAPRD/control01.
ctl, /u02/oradata/YYAPRD/contr
ol02.ctl, /u03/oradata/YYAPRD/
control03.ctl
SQL> alter system set control_files='+DATA','+DATA1' scope=spfile;
System altered.
SQL> alter system set db_create_file_dest='+DATA' scope=spfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL>
SQL> startup nomount
ORACLE instance started.
Total System Global Area 2042241024 bytes
Fixed Size 1345968 bytes
Variable Size 838862416 bytes
Database Buffers 1191182336 bytes
Redo Buffers 10850304 bytes
[oracle@NODE1 11.2.0.3]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Apr 8 23:24:36 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: YYAPRD (not mounted)
RMAN> restore controlfile from '/u01/oradata/YYAPRD/control01.ctl';
Starting restore at 08-APR-13
using channel ORA_DISK_1
channel ORA_DISK_1: copied control file copy
output file name=+DATA/yyaprd/controlfile/current.256.812244559
output file name=+DATA1/yyaprd/controlfile/current.256.812244561
Finished restore at 08-APR-13
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> backup as copy database format '+DATA';
Starting backup at 08-APR-13
allocated channel: ORA_DISK_1
------
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DATA/yyaprd/datafile/system.257.812244625"
datafile 2 switched to datafile copy "+DATA/yyaprd/datafile/sysaux.259.812244827"
datafile 3 switched to datafile copy "+DATA/yyaprd/datafile/undotbs.260.812244881"
datafile 4 switched to datafile copy "+DATA/yyaprd/datafile/users.258.812244721"
RMAN> alter database open;
database opened
RMAN> exit
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------
+DATA/yyaprd/datafile/system.257.812244625
+DATA/yyaprd/datafile/sysaux.259.812244827
SQL> alter tablespace temp add tempfile size 500M;
Tablespace altered.
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------
/u04/oradata/YYAPRD/temp01.dbf
+DATA/yyaprd/tempfile/temp.263.812245559
SQL> alter database tempfile '/u04/oradata/YYAPRD/temp01.dbf' drop including datafiles;
Database altered.
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------
+DATA/yyaprd/tempfile/temp.263.812245559
SQL> alter database add logfile group 4 ('+DATA','+DATA1') size 10M;
Database altered.
SQL> alter database add logfile group 5 ('+DATA','+DATA1') size 10M;
Database altered.
SQL> alter database add logfile group 6 ('+DATA','+DATA1') size 10M;
Database altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ----------- ------------ -----------
1 1 115 10485760 512 2 NO INACTIVE 244292 08-APR-2013 268271 08-APR-2013
2 1 116 10485760 512 2 NO INACTIVE 268271 08-APR-2013 271180 08-APR-2013
3 1 117 10485760 512 2 NO CURRENT 271180 08-APR-2013 2.8147E+14
4 1 0 10485760 512 2 YES UNUSED 0 0
5 1 0 10485760 512 2 YES UNUSED 0 0
6 1 0 10485760 512 2 YES UNUSED 0 0
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ----------- ------------ -----------
3 1 117 10485760 512 2 NO INACTIVE 271180 08-APR-2013 274462 08-APR-2013
4 1 118 10485760 512 2 NO INACTIVE 274462 08-APR-2013 274465 08-APR-2013
5 1 119 10485760 512 2 NO CURRENT 274465 08-APR-2013 2.8147E+14
6 1 0 10485760 512 2 YES UNUSED 0 0
SQL> alter database drop logfile group 3;
Database altered.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------
+DATA/yyaprd/onlinelog/group_4.264.812246035
+DATA1/yyaprd/onlinelog/group_4.257.812246037
+DATA/yyaprd/onlinelog/group_5.265.812246095
+DATA1/yyaprd/onlinelog/group_5.258.812246097
======================================================================
@asmtononasm
==================================================================================
@BIT
getconf LONG_BIT
==================================
@GUI
yum install xorg-x11-apps.x86_64
=====================================
@deinstall
./runInstaller -deinstall -home /u01/app/oracle/product/12.1.0/dbhome_1/
---------------------
$ORACLE_HOME/oui/bin/runInstaller
================================================================================
@newlycreated
SELECT created,object_name
FROM dba_objects
WHERE object_name like '%EWU_USE%'
AND owner = 'EWSADMIN'
AND object_type = 'TABLE' order by 1;
====================================================
@perfstatdel
Deleting certain SNAP IDs
SQL> @?/rdbms/admin/sppurge.sql
Delete all snapshots
SQL> @?/rdbms/admin/sptrunc.sql
Delete the perfstat schema
SQL> @?/rdbms/admin/spdrop.sql
Delete a timerange
SQL> exec statspack.purge (i_begin_date=>to_date('01-JAN-2012', 'DD-MON-YYYY'),i_end_date =>to_date('02-JAN-2012', 'DD-MON-YYYY'),i_extended_purge=>TRUE);
=================================or===========================================
select SNAP_ID,to_char(SNAP_TIME,'dd-mon-yyyy hh24:mi') from stats$snapshot;
delete from stats$snapshot where SNAP_TIME < sysdate - (1/(24*60)) ;
=============================================================================================================================================================================================================
@resetsamepassword:
select password from sys.user$ where name='&QWERTY';
PASSWORD
-----------------------------
87FE2DD49B2882B2
alter user QWERTY identified by values '87FE2DD49B2882B2';
=======================================================================
@windowsprofile:
set PATH=%ORACLE_HOME%\perl\bin;%PATH%
path=%path%;E:\app\Administrator\product\11.2.0\dbhome_1\OPatch
===============================================
@list of directories
ls -ltr | grep "^d"
=====================================================
@7of7zipfile
1-Db
2-Db
3-Grid
4-Client
5-Oracle Gateways
6-Oracle Examples
7-Deinstall
================================================================================
@indexsstatus
select OWNER,INDEX_NAME,owner,status,table_name from dba_indexes where owner like %PMD%';
SELECT index_name,status,Blevel,LEAF_BLOCKS,DISTINCT_KEYS,NUM_ROWS,CLUSTERING_FACTOR FROM DBA_INDEXES WHERE index_name = 'ORGANIZED_IDX';
===================================================================================================================================
@tabstats
EXEC DBMS_STATS.gather_table_stats('PMD', 'VW_DAG_0',cascade => true,estimate_percent => dbms_stats.auto_sample_size);
============================================================================================
@redomultiplexing
alter database add logfile member '/u03/app/oracle/oradata/orcl/redo/redo01_b.log' to group 1;
ALTER DATABASE ADD LOGFILE group 7 ('/u02/oradata/P38/redo07a.log', '/u03/oradata/P38/redo07b.log') size 100m;
http://www.oracledistilled.com/oracle-database/administration/multiplexing-the-redo-log-files/ --multiplexing
alter database add logfile member '/u03/app/oracle/oradata/orcl/redo/redo01_b.log' to group 1;
https://muneer2908.wordpress.com/2011/01/27/how-to-change-the-redo-log-file-size-in-oracle-database/ --increase size
======================================
@nls
SELECT * FROM NLS_DATABASE_PARAMETERS;
select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
========================================
@cachefusion:
@sess_stats.sql
SELECT sn.name,
st.value
FROM v$statname sn
JOIN v$sesstat st
ON sn.STATISTIC#=st.STATISTIC#
WHERE sn.name IN ('session logical reads','physical reads','gc cr block received','gc current block received')
AND st.sid=SYS_CONTEXT('USERENV','SID')
ORDER BY sn.STATISTIC#;
-------------------------------------------------------
@tracemysession
declare
v_sid number;
v_serial number;
begin
select sid,serial# into v_sid,v_serial from v$session
where sid=SYS_CONTEXT('USERENV','SID');
dbms_monitor.session_trace_enable(v_sid,v_serial,TRUE,TRUE);
end;
-----------------------------
@mytracefile
select
pm.value ||'/diag/rdbms/'||d.name||'/'||i.instance_name||
'/trace/'||i.instance_name||'_ora_'||pr.spid||'.trc' as trace_file
from
(select
p.spid
from
v$session s
join
v$process p
on s.paddr=p.addr
where
s.sid=SYS_CONTEXT('USERENV','SID')) pr
cross join
(select
value
from v$parameter
where name='diagnostic_dest') pm
cross join
(select instance_name
from v$instance) i
cross join
(select
lower(name) as name
from v$database) d;
-----------------------------------------------------------------------
@mysid
select SYS_CONTEXT('USERENV','SID') from dual;
select SYS_CONTEXT('USERENV','CURRENT_USER') from dual;
@traceenable
exec DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(sid,serial#,true);
------------------------------------------------------------------
@optsession
@opttransaction
session= (1.1 * PROCESSES) + 5
transaction= (1.1 * SESSIONS)
---------------------------------------------------------------------------
@service :A service is a logical grouping of sessions performing similar kind of work.
$srvctl add service -s test -d hrms -r hrms1 -a hrms2 -P basic r=prefer
#to see status of specific service
$srvctl status service -s test -d hrms
#to delete service
$srvctl remove service -s test -d hrms
--------------
@modify service
srvctl modify service -d RTGS -s myser -n -i RTGS1,RTGS2
srvctl add service -d testing -s testsrv -r testing2,testing1
-----------------------------------------
select service_name,inst_id,count(*)
from gv$session
group by service_name,inst_id
order by service_name,inst_id;
----------------
select name from v$services
-----------
@findvip
olsnodes -i
--------
@clientsysdba
sqlplus sys/SYS123@OCAS as sysdba
-------------------------------------------
@adrci
purge -age 43200 (older then one month)
adrci>show alert -tail -f
adrci>show home
adrci>set homepath diag/rdbms/orclbi/orclbi2
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@pt
select sid,event,p1,p2,p3 from v$session_wait where event='db file sequential read';
select owner,segment_name,segment_type from dba_extents where file_id= 21 and 969567 between block_id and block_id + blocks -1;
-----------------------------------------------------------------------------------
@blkid
----------------------------------------------------------------------------------
@sysauxpurge
set linesize 120
set pagesize 100
COLUMN "Item" FORMAT A25
COLUMN "Space Used (GB)" FORMAT 999.99
COLUMN "Schema" FORMAT A25
COLUMN "Move Procedure" FORMAT A40
SELECT occupant_name "Item",
space_usage_kbytes/1048576 "Space Used (GB)",
schema_name "Schema",
move_procedure "Move Procedure"
FROM v$sysaux_occupants
ORDER BY 1
/
--How long old stats are kept
1
select dbms_stats.get_stats_history_retention from dual;
--Set retention of old stats to 10 days
1
exec dbms_stats.alter_stats_history_retention(10);
--Purge stats older than 10 days (best to do this in stages if there is a lot of data (sysdate-30,sydate-25 etc)
1
exec DBMS_STATS.PURGE_STATS(SYSDATE-10);
--Show available stats that have not been purged
1
select dbms_stats.get_stats_history_availability from dual;
--Show how big the tables are and rebuild after stats have been purged
https://jhdba.wordpress.com/2009/05/19/purging-statistics-from-the-sysaux-tablespace/
--------------------------------------------------------------
@html
set markup html on
set pagesize 30
spool processes_sessions.html
select
p.username "V$PROCESS - OS USERNAME",
p.terminal,
p.program,
s.username "V$SESSION - USERNAME",
s.command,
s.status,
to_char(s.LOGON_TIME,'DD-MON-YY HH24:MI:SS') "LOGON TIME",
s.LAST_CALL_ET/60 "LAST_CALL TIME",
s.server,
s.process,
s.machine,
s.port,
s.terminal,
s.program,
s.sid,
s.serial#,
p.spid
FROM v$session s,v$process p
WHERE p.addr=s.paddr
order by p.background desc;
spool off
exit;
---------------------------------------------------------------------------------------------------------
@audit(schema)
https://oracle-base.com/articles/10g/auditing-10gr2
SHOW PARAMETER AUDIT
AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }
ALTER SYSTEM SET audit_trail=db SCOPE=SPFILE; bounce db
CONNECT sys/password AS SYSDBA
--pri
AUDIT ALL BY SCOTT BY ACCESS;
AUDIT SELECT TABLE, UPDATE TABLE, INSERT TABLE, DELETE TABLE BY SCOTT BY ACCESS;
AUDIT EXECUTE PROCEDURE BY SCOTT BY ACCESS;
---dictionary tab info
SELECT view_name FROM dba_views WHERE view_name LIKE 'DBA%AUDIT%' ORDER BY view_name;
---check audit
COLUMN username FORMAT A10
COLUMN owner FORMAT A10
COLUMN obj_name FORMAT A10
COLUMN extended_timestamp FORMAT A35
SELECT username,
extended_timestamp,
owner,
obj_name,
action_name
FROM dba_audit_trail
WHERE owner = 'AUDIT_TEST'
ORDER BY timestamp;
----------------------------
@audithousekeeping
https://oracle-base.com/articles/11g/auditing-enhancements-11gr2 --
--------------------------------------------------------------------------------------------------------------
@mastertableissue
SET lines 150
COL owner_name FORMAT a10
COL job_name FORMAT a20
COL operation FORMAT a10
SELECT owner_name, job_name, operation
FROM dba_datapump_jobs where state='NOT RUNNING' and attached_sessions=0;
set head off
SELECT 'drop table ' || owner_name || '.' || job_name || ';'
FROM dba_datapump_jobs WHERE state='NOT RUNNING' and attached_sessions=0;
--------------------------------------------------------------------------------------------------------------
@HOW TO GENERATE ARCHIVE LOG FROM ASM TO LOCAL DISK
SQL> CREATE or replace DIRECTORY archdir AS '+ARCH/mscdxb/arch/';SQL> Directory created.SQL> CREATE or replace DIRECTORY tempdir AS '/u01/starch/';Directory created.
spool archmove.sql
set linesize 250
set pagesize 250
select 'EXECUTE DBMS_FILE_TRANSFER.COPY_FILE(''ARCHDIR'','''||
SUBSTR(NAME,INSTR(NAME,'/',-1) + 1) ||''',''TEMPDIR'','''||
SUBSTR(NAME,INSTR(NAME,'/',-1) + 1)||''');'
FROM V$ARCHIVED_LOG where name is not null;
spool off;
exit;
----------------------------------------------------------------------------------------------------------------
@aixinstallation:
kernal:
# lsattr -E -l sys0 -a maxuproc
maxuproc 128 Maximum number of PROCESSES allowed per user True
# smit chgsys ( Change / Show Characteristics of Operating System)
#chdev -l sys0 -a maxuproc=1000
# getconf -a
AIO_LISTIO_MAX: 4096
AIO_MAX: 4096
AIO_PRIO_DELTA_MAX: 0
ARG_MAX: 24576
# bootinfo -K (64 or 32)
# /usr/bin/getconf HARDWARE_BITMODE --(To determine if the system architecture)
# /usr/sbin/lsps -a (To determine swap)
# /usr/sbin/lsattr -E -l sys0 -a realmem (To determine the RAM size)
----------------------------------------------------------------------------
ERROR at line 1:
ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: at "SYS.DBMS_STATS", line 24281
ORA-06512: at "SYS.DBMS_STATS", line 24332
ORA-06512: at line 1
------------------------ sol-------------------
exec dbms_stats.unlock_table_stats('EWSADMIN', 'EWN_COMP_MODEL_SCORE');
-------------------------------------------------------------------------------
@dbfutilization
SET PAUSE ON
SET PAUSE 'Press Return to Continue'
SET PAGESIZE 60
SET LINESIZE 300
COLUMN "Tablespace Name" FORMAT A20
COLUMN "File Name" FORMAT A80
SELECT Substr(df.tablespace_name,1,20) "Tablespace Name",
Substr(df.file_name,1,80) "File Name",
Round(df.bytes/1024/1024,0) "Size (M)",
decode(e.used_bytes,NULL,0,Round(e.used_bytes/1024/1024,0)) "Used (M)",
decode(f.free_bytes,NULL,0,Round(f.free_bytes/1024/1024,0)) "Free (M)",
decode(e.used_bytes,NULL,0,Round((e.used_bytes/df.bytes)*100,0)) "% Used"
FROM DBA_DATA_FILES DF,
(SELECT file_id,
sum(bytes) used_bytes
FROM dba_extents
GROUP by file_id) E,
(SELECT Max(bytes) free_bytes,
file_id
FROM dba_free_space
GROUP BY file_id) f
WHERE e.file_id (+) = df.file_id
AND df.file_id = f.file_id (+)
ORDER BY df.tablespace_name,
df.file_name
/
-------------------------------------------------------------------------------------------------------------
@allocaterestore:
run {
allocate channel ch1 device type 'sbt';
allocate channel ch2 device type 'sbt';
allocate channel ch3 device type 'sbt';
send 'NB_ORA_POLICY=DB_rman_full,NB_ORA_SERV=master-bk';
restore database;
release channel ch1;
release channel ch2;
release channel ch3;
}
----------------------asm to nonasm-----------
run
{
set newname for datafile 1 to '/data/emrep/oradata/EMREP/datafile/system.283.903890003';
set newname for datafile 2 to '/data/emrep/oradata/EMREP/datafile/sysaux.278.903889977';
set newname for datafile 3 to '/data/emrep/oradata/EMREP/datafile/undotbs1.282.903890003';
set newname for datafile 4 to '/data/emrep/oradata/EMREP/datafile/users.285.903890027';
set newname for datafile 5 to '/data/emrep/oradata/EMREP/datafile/mgmt_ecm_depot_ts.281.903890003';
set newname for datafile 6 to '/data/emrep/oradata/EMREP/datafile/mgmt_tablespace.284.903890027';
set newname for datafile 7 to '/data/emrep/oradata/EMREP/datafile/mgmt_ad4j_ts.280.903889977';
set newname for datafile 8 to '/data/emrep/oradata/EMREP/datafile/rman_catalog.279.903889977';
set newname for datafile 9 to '/data/emrep/oradata/EMREP/datafile/mgmt_tablespace.499.916503681';
SET NEWNAME FOR TEMPFILE 1 TO '/data/emrep/oradata/EMREP/datafile/temp01.dbf';
set until scn 658140403;
DUPLICATE TARGET DATABASE TO EMREP
NOFILENAMECHECK
DB_FILE_NAME_CONVERT '+DATA','/data/emrep/oradata/EMREP/datafile'
LOGFILE
GROUP 1 ('/data/emrep/onlinelog/EM_GRIDP03/redo01a.log','/data/emrep/onlinelog/EM_GRIDP03/redo01b.log') SIZE 600M REUSE,
GROUP 2 ('/data/emrep/onlinelog/EM_GRIDP03/redo02a.log','/data/emrep/onlinelog/EM_GRIDP03/redo02b.log') SIZE 600M REUSE
SPFILE
SET LOG_FILE_NAME_CONVERT '+FRA/','/data/emrep/onlinelog', '+DATA','/data/emrep/onlinelog'
SET AUDIT_FILE_DEST '/app/oracle/admin/EMREP/adump'
SET CONTROL_FILES '/data/emrep/oradata/EMREP/controlfile/control01.ctl'
SET DB_RECOVERY_FILE_DEST '/data/emrep/FRA'
SET DB_CREATE_FILE_DEST '/data/emrep/oradata/EMREP/datafile/'
SET DIAGNOSTIC_DEST '/app/oracle/admin';
}
-----------------------------------------------------------------
@bandwidth
Let us assume the redo rate is a 500 KB/sec.
Required bandwidth = ((Redo rate bytes per sec. / 0.75) * 8) / 1,000,000 = bandwidth in Mbps Required bandwidth = ((512000/0.75) * 8) /1,000,000 Required bandwidth = 5.46 Mbps
Also you can find the Minimum and Maximum Bandwidth limit using the below query,
SELECT DT,SUM(RB*8/3600000000*1.3) TOTAL_Mbps_REQ_FOR_A_DAY,MIN(RB*8/3600000000*1.3) MIN_Mbps_REQ_FOR_AN_HOUR,MAX(RB*8/3600000000*1.3) MAX_Mbps_REQ_FOR_AN_HOUR ,AVG(RB*8/3600000000*1.3) AVG_Mbps_REQ_FOR_AN_HOURFROM(SELECT TRUNC (COMPLETION_TIME) DT,TO_CHAR (COMPLETION_TIME,'HH24') HH,SUM(BLOCKS*BLOCK_SIZE) RBFROMV$ARCHIVED_LOGWHERE COMPLETION_TIME > SYSDATE-5AND DEST_ID=1GROUP BY TRUNC(COMPLETION_TIME),TO_CHAR (COMPLETION_TIME, 'HH24'))GROUP BY DT;
Reference:
How To Calculate The Required Network Bandwidth Transfer Of Redo In Data Guard Environments (Doc ID 736755.1)
As an Alternative you can also get the 'Redo rate bytes per sec.' from V$SYSMETRIC_HISTORY, eg.
SQL> select *
from v$sysmetric_history where metric_name = 'Redo Generated Per Sec';
------------------------------------------------------------------------------------
@indexonwhichcolumn
SELECT * FROM dba_ind_columns t where t.table_owner='EWSADMIN'
------------------------------------------------------------------------------------
@flashback
SELECT FLASHBACK_ON FROM V$DATABASE;
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320; -- 3 days default is 1440
ALTER DATABASE FLASHBACK ON;
-----------------------------------------------------------------------------
@$ORACLE_HOME/rdbms/admin/sqltrpt.sql
--------------------------------
@compilepackage ALTER PACKAGE UTL_FILE COMPILE BODY;
--------------------------------
@changehome
https://pierreforstmanndotcom.wordpress.com/2014/09/30/how-to-move-or-rename-oracle-home/
---------------------------------------------
@telnetexit
ctl+]
telnet > quit
*********************************************************************************************************************
@spusteps:http://ermanarslan.blogspot.in/2016/11/rdbms-applying-db-psu-and-ojvm-psu-to.html
*Shutdown listener and Databases running from target ORACLE HOME
*Add opatch to the path ($PATH env variable)
export PATH=$PATH:$ORACLE_HOME/OPatch
--export PATH=$ORACLE_HOME/OPatch:$PATH
opatch lsinventory -detail
opatch lsinventory
opatch version
/home/oracle/oracle_11204/psu/24006111
*PREREQ & CONFLICT CHECK
[oracle@coinactdbtst 24006111]$ opatch prereq CheckConflictAmongPatchesWithDetail -phBaseDir /home/oracle/25879656
*WE APPLY PSU using Opatch apply
export PATH=$PATH:$ORACLE_HOME/OPatch
csd /home/oracle/oracle_11204/psu/24006111
opatch apply
*********rollback*********
opatch rollback -id 15941858
***********@rpatch***************
export CRS_ORA_HOME=/opt/oracrs/oragrid/11.2.0.4
export ORACLE_HOME=/opt/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/Opatch
cd /orastage/PSU/PSU_PATCH_OCT_2016
NPRD:oracle@ausyd23db05cn01:>ls -trl
total 798464
-rw-r--r-- 1 oracle oinstall 105489166 Nov 15 16:42 p24006111_112040_Linux-x86-64-RDBMS.zip
-rw-r--r-- 1 oracle oinstall 712035213 Nov 15 16:51 p24436338_112040_Linux-x86-64-GI.zip
drwxrwxr-x 3 oracle oinstall 3896 Nov 17 18:09 RDBMS_PSU/
drwxrwxr-x 3 oracle oinstall 3896 Nov 17 18:09 GI_PSU/
unzip p24006111_112040_Linux-x86-64-RDBMS.zip -d RDBMS_PSU
unzip p24436338_112040_Linux-x86-64-GI.zip -d GI_PSU
-- Stop agents on all nodes
cd /opt/oracle/product/agent/core/12.1.0.5.0/bin/
./emctl status agent
./emctl stop agent
-- unix Team to stop crs service, only node one
$CRS_ORA_HOME/bin/crsctl stop crs
export CRS_ORA_HOME=/opt/oracrs/oragrid/11.2.0.4
export ORACLE_HOME=/opt/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/Opatch
/opt/oracrs/oragrid/11.2.0.4/bin/crsctl stop crs
-- crosscheck above command
$lsof |grep /opt/oracle/product/1120
-----------------------------------------------
cd $CRS_ORA_HOME
>> from node1 and all other nodes
cd /opt/oracrs/oragrid/11.2.0.4
tar -cvpf /ora_conv/ora_node1_bak_11.2.0.4/gi_bkp_n1.tar ./
cd $ORACLE_HOME
>> from node1 and all other nodes
cd /opt/oracle/product/11.2.0.4
tar -cvpf /ora_conv/ora_node1_bak_11.2.0.4/db_bkp_n1.tar ./
$** As Oracle user **
cd /opt/oracle/oraInventory
>> from node1 and all other nodes
cd /opt/oracle/oraInventory
tar -cvpf /ora_conv/ora_node1_bak_11.2.0.4/inv_bkp_n1.tar ./
-- crontab backup and comment all jobs on both nodes..
<<flag-1>>
/ora_conv/ora_node1_bak_11.2.0.4
cd /opt/oracrs/oragrid/11.2.0.4
tar -cvpf /ora_conv/oradata/node1_bak/gi_bkp_n1.tar ./
cd /opt/oracle/product/11.2.0.4
tar -cvpf /ora_conv/oradata/node1_bak/db_bkp_n1.tar ./
cd /opt/oracle/oraInventory
tar -cvpf /ora_conv/oradata/node1_bak/inv_bkp_n1.tar ./
-- unix Team to start crs service.
$CRS_ORA_HOME/bin/crsctl start crs
/opt/oracrs/oragrid/11.2.0.4/bin/crsctl start crs
export CRS_ORA_HOME=/opt/oracrs/oragrid/11.2.0.4
export ORACLE_HOME=/opt/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/Opatch
/opt/oracrs/oragrid/11.2.0.4/bin/crsctl start crs
-- Make OCM Configuration (make response file)
cd $CRS_ORA_HOME/OPatch/ocm/bin/
./emocmrsp
-- Validation of Oracle Inventory / If the below command succeeds, we are good /
$CRS_ORA_HOME/OPatch/opatch lsinventory -detail -oh $CRS_ORA_HOME
$ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME
-- ** As Root user ** / might not required in rare case /
$ORACLE_HOME/crs/install/rootcrs.pl -unlock
$ORACLE_HOME/crs/install/roothas.pl -unlock
opatch lsinventory | grep 25476126
**************** GRID and DATABASE Home Patching ****************
25476126
--- Apply auto patch on GRID and RDBMS in one go
$CRS_ORA_HOME/OPatch/opatch auto /orastage/PSU/PSU_PATCH_APR_2017/GI_PSU/25476126 -ocmrf $CRS_ORA_HOME/OPatch/ocm/bin/ocm.rsp
/opt/oracrs/oragrid/11.2.0.4
export CRS_ORA_HOME=/opt/oracrs/oragrid/11.2.0.4
export ORACLE_HOME=/opt/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/Opatch
/opt/oracrs/oragrid/11.2.0.4/OPatch/opatch auto /orastage/PSU/PSU_PATCH_APR_2017/GI_PSU/25476126 -ocmrf /opt/oracrs/oragrid/11.2.0.4/OPatch/ocm/bin/ocm.rsp
{after sucess of this directly jump to > * DATABASE Patching }
-- Apply patch on GRID (make below comand in a file, and ask unix team to execute)
$CRS_ORA_HOME/OPatch/opatch auto <patch_location>/GI_PSU -oh $CRS_ORA_HOME -ocmrf $CRS_ORA_HOME/OPatch/ocm/bin/ocm.rsp
**************** DATABASE Patching ****************
This need to be done, on all database either of the nodes.
vi db_patch_apply.sql
set lines 132 pages 300
set serveroutput on
set sqlbl on
exec dbms_output.put_line('***PSU Status before PATCH ***');
select name from v$database;
col ACTION_TIME for a30
col COMMENTS for a30
col BUNDLE_SERIES for a10
select ACTION_TIME, comments, version, bundle_series
from sys.registry$history
where bundle_series = 'PSU'
order by action_time desc
;
@?/rdbms/admin/catbundle.sql psu apply
@?/rdbms/admin/utlrp.sql
exec dbms_output.put_line('***PSU Status after PATCH ***');
set lines 132 pages 300
col ACTION_TIME for a30
col COMMENTS for a30
col BUNDLE_SERIES for a10
select ACTION_TIME, comments, version, bundle_series
from sys.registry$history
where bundle_series = 'PSU'
order by action_time desc
;
exit
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
==========================
export ORACLE_SID=DSPCAN101
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLPSYD201
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD121
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDCAN021
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDCAN051
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=DSDCAN021
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDCAN031
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD111
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=DSDCAN031
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD131
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=CTLGDB1
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDCAN041
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD091
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=DSDCAN051
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=DSDCAN041
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
export ORACLE_SID=OLDSYD081
nohup sqlplus "/ as sysdba" @db_patch_apply.sql > nohup_db_patch_apply_$ORACLE_SID.out &
***********************************************************************************************************************************
set lines 200
set pages 200
set time on
col ACTION_TIME for a35
col ACTION for a12
col NAMESPACE for a12
col VERSION for a12
col COMMENTS for a30
col BUNDLE_SERIES for a10
select * from registry$history;
-------------------------------------------------------------------------------
@afterupgraderemove
1.export old home
export ORACLE_HOME=$OLD_GI_HOME
2.$OLD_GI_HOME/oui/bin/runInstaller -detachHome -silent ORACLE_HOME=$OLD_GI_HOME
--/home/oracle/app/oracle/product/11.2.0/dbhome/oui/bin/runInstaller -detachHome -silent ORACLE_HOME=$ORACLE_HOME
## confirm $OLD_HOME is removed from central inventory:
$OLD_GI_HOME/OPatch/opatch lsinventory -all
## remove files in OLD_HOME manually:
/bin/rm -rf $OLD_GI_HOME
unset ORACLE_HOME
-------------------------------------------------------------------------------
@objnameindatafile
How can we check in which datafile my object resides?
select a.segment_name,a.file_id,b.file_name Datafile_name from dba_extents a,dba_data_files b where a.file_id=b.file_id and a.segment_name='YOUR OBJECT NAME';
How can we check what objects are there in a datafile?
select a.segment_name,a.file_id,b.file_name Datafile_name from dba_extents a,dba_data_files b where a.file_id=b.file_id and b.file_name=<your datafile name with path>;
--------------------------------------------------------------------------------------
@getpassword
select
'alter user "'||username||'" identified by values '''||extract(xmltype(dbms_metadata.get_xml('USER',username)),'//USER_T/PASSWORD/text()').getStringVal()||''';' old_password
from
dba_users
where
username = '&WATADMIN';
----------------------------------------------------------------------------------------------------
@prelim
sqlplus -prelim / as sysdba
oradebug setmypid
oradebug unlimit;
oradebug dump systemstate 266
...wait for 2 mins
oradebug dump systemstate 266
oradebug tracefile_name <=== To check the dump file location
exit
-------------------------------------------------------------------------------------------------------------------------------
@oradim
oradim -new -sid ORCL -syspwd mgrorcl -startmode auto -pfile C:\app\mgrvinod\product\11.2.0\dbhome_1\dbs\init_orcl.ora;
-------------------------
@CSSD won’t start automatically
[oracle@Linux4 ~]$ crsctl stat res ora.cssd -p
[oracle@Linux4 ~]$ crsctl modify resource "ora.cssd" -attr "AUTO_START=always"
[oracle@Linux4 ~]$ crsctl modify resource "ora.asm" -attr "AUTO_START=always"
@end--------------------------
*************************************************
https://dbdwell.wordpress.com/category/rac/
***************************************************
http://select-star-from.blogspot.in/2013/07/oracle-dba-interview-questions-answers_24.html
***************************************************
http://oracle4ryou.blogspot.in/2013/11/oracle-11g-rac-interview-question-and.html
***************************************************
http://www.freeoraclehelp.com/2011/12/scan-setup-for-oracle-11g-release211gr2.html
***************************************************
http://ranjeetwipro.blogspot.in/2011/03/rolling-patch-opatch-support-for-rac.html
***************************************************
https://anargodjaev.wordpress.com/2015/03/10/ra-01503-ora-01189-when-trying-to-recreate-controlfile/
***************************************************
http://dbarohit.blogspot.in/2012/12/why-oracle-recommends-voting-disks-in_25.html
***************************************************
https://oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux
***************************************************
http://expertoracle.com/2014/04/01/data-guard-broker-basics/
***************************************************
http://oracleinstance.blogspot.in/2012/01/create-single-instance-standby-database.html
***************************************************
http://www.oracleracexpert.com/2014/01/optimal-redo-logfile-size-in-oracle.html
***************************************************
https://martincarstenbach.wordpress.com/2010/04/30/applying-psu-11-2-0-1-1-to-grid-infrastructure-rdbms-2/
***************************************************
https://nehakohlidba.wordpress.com/2015/01/18/database-upgrade-11-2-0-1-to-11-2-0-4-on-sap-using-mopatch-on-windows/
***************************************************
https://sadanandhudge.wordpress.com/2015/11/11/database-upgrade-from-11-2-0-1-to-11-2-0-4-on-linux-64bit/
***************************************************
http://www.dba-oracle.com/t_goldengate_upgrade_to_oracle12c.htm
***************************************************
http://dbaoracletips.blogspot.in/2014/02/owb-component-not-upgraded-to-11204.html
***************************************************
https://oracle-base.com/articles/11g/data-guard-setup-using-broker-11gr2
***************************************************
https://sachinichake.wordpress.com/2013/05/10/frequently-asked-questions/
***************************************************
http://expertoracle.com/2014/03/05/rman-recovery-scenarios-related-to-database/
***************************************************
http://www.dbas-oracle.com/2013/05/10-steps-to-analyze-awr-report-in-oracle.html
***************************************************
http://dbaquest.blogspot.in/2014/02/rac-11gr2-clusterware-startup-sequence.html
***************************************************
http://karandba.blogspot.in/2014/09/12c-sql-plan-management-spm.html
***************************************************
https://mewithoracle.wordpress.com/2012/05/02/recovering-through-an-added-datafile/
***************************************************
https://orainternals.wordpress.com/tag/ohasd-startup/
****************************************************
http://www.oraclebuffer.com/goldengate/understanding-oracle-goldengate-architecture/
****************************************************
https://dbastar.wordpress.com/2015/10/29/applying-psu-oct-2015-patch-11-2-0-4-8-to-a-two-node-rac/
****************************************************
https://docs.oracle.com/cd/B16240_01/doc/em.102/e15294/rac.htm
****************************************************
http://anotherdatabaseblog.blogspot.in/2011/10/crerating-ocm-response-file-for-gi-home.html
****************************************************
https://dbdwell.wordpress.com/category/rac/
***************************************************
https://aprakash.wordpress.com/2012/01/19/moving-aud-table-to-another-tablespace-in-11gr2/
****************************************************
https://hoopercharles.wordpress.com/2009/12/01/sql-plan_hash_value-changes-for-the-same-sql-statement/
****************************************************
https://web.stanford.edu/dept/itss/docs/oracle/10gR2/backup.102/b14191/rcmtspit001.htm
****************************************************
https://stackoverflow.com/questions/16011976/hash-value-for-sql-statement
****************************************************
https://oracle-dba-help.blogspot.in/2017/04/oracle-asm-interview-questions.html?m=1
****************************************************
http://oracle-dba-help.blogspot.in/search/label/Frequently%20Asked
****************************************************
https://blogshavail.wordpress.com/2012/03/03/remove-previous-gicrsasm-home-after-upgrade/
****************************************************
https://community.oracle.com/docs/DOC-1012784
****************************************************
http://enterprise-manager.blogspot.in/2011/04/favourite-questions-and-answers-from-em.html
****************************************************
http://blog.oracle48.nl/oracle-database-undo-space-explained/
****************************************************
http://vetriveldba.blogspot.in/2017/03/how-to-calculate-network-bandwidth-for.html
*****************************************************
http://searchoracle.techtarget.com/answer/26-performance-tuning-questions-and-solutions-1-10
*****************************************************
http://dba-expert.blogspot.in/2012/02/cross-platform-migration-using-rman.html
******************************************************
https://oracleracdba1.wordpress.com/2014/07/14/how-to-clone-oracle-binaries/
******************************************************
https://oracleracdba1.wordpress.com/category/oracle-rac/asm/
******************************************************
http://www.dba-oracle.com/t_data_pump_disable_archive_logging.htm
******************************************************
http://subudba.blogspot.in/search/label/Performance%20Tunning
***********************************************************
http://oukc.oracle.com/static09/opn/core09/oracle9i_database/89067/062410_89067/062410_89067_demo.html
***********************************************************
http://www.oracle-scripts.net/
***********************************************************
https://samadhandba.wordpress.com/2011/03/07/reducing-datafile-size-to-recover-free-space-%E2%80%93-oracle-database-10g/
***********************************************************
https://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_1019.htm#REFRN30170
***********************************************************
https://alexzeng.wordpress.com/2012/09/25/valuate-oracle-awr-automatic-workload-repository/
***********************************************************
https://www.tutorialspoint.com/unix/unix-regular-expressions.htm
***********************************************************
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=542863524161349&parent=DOCUMENT&sourceId=1366610.1&id=112248.1&_afrWindowMode=0&_adf.ctrl-state=jnzbip2ie_4 -- resetlogs
***********************************************************
http://dillidba.blogspot.in/2016/06/upgrade-oracle-11g-r2-11204-database-to.html --upgrade
***********************************************************
http://oracledbabhuvan.blogspot.in/2011/05/recreating-oracle-inventory-in-10g11g.html --recreate oracleinventory
***********************************************************
http://dnccfg.blogspot.in/ --Add node into RAC
***********************************************************