Saturday, 18 January 2025
Gather Stats for schemas
Health Check SQL Queries
Sunday, 12 January 2025
Script to find temp tablespace free and used space
Script to check all tablespace details in the database
Script to find top10active jobs in database.
shows the top 10 longest-active user sessions
*/
col osuser format a10 trunc
col LastCallET format 99,999
col username format a10 trunc
col uprogram format a25 trunc
col machine format a10 trunc
set linesize 132 pages 20
set verify off
accept trgtuser char default ALL prompt 'Limit to what userid <ALL> : '
select * from (
select to_char(s.logon_time, 'mm/dd hh:mi:ssAM') loggedon,
s.sid, s.status,
floor(last_call_et/60) "LastCallET",
s.username, s.osuser,
p.spid, s.module || ' - ' || s.program uprogram,
s.machine, s.sql_hash_value
from v$session s, v$process p
where p.addr = s.paddr
and s.type = 'USER'
and s.username is not null
and s.status = 'ACTIVE'
and (s.username = upper('&trgtuser') or upper('&trgtuser') = 'ALL')
order by 4 desc)
where rownum < 31;
Script to check tablespace details.
To find information about locks in the database
Check the size of different pools in database using SQL command and database parameter file.
set pages 200
col name for a35
col value for a35
Checking at OS Level.
egrep -i 'shared_pool_size|shared_pool_reserved_size|db_cache_size|sga_max_size|sga_target' initTEST.ora
*.sga_max_size=0
*.sga_target=0
*.shared_pool_reserved_size=320M
*.shared_pool_size=3500M
*pga_aggregate
Solaris tar and untar commands
++++++++++++++++++++++++
solaris tar commands
++++++++++++++++++++++
nohup tar -cvf - appl |gzip -c > /backup/rman_1060/bhaogpp1/bin_25feb13/appl.tar.gz &
nohup tar -cvf - 10.1.2 |gzip -c > /backup/rman_1060/bhaogpp1/bin_25feb13/1012.tar.gz &
nohup tar -cvf - comn |gzip -c > /backup/rman_1060/bhaogpp1/bin_25feb13/comn.tar.gz &
nohup tar -cvf - 10.1.3 |gzip -c > /backup/rman_1060/bhaogpp1/bin_25feb13/1013.tar.gz &
+++++++++++++++++++++++++++
solaris untar commands
+++++++++++++++++++++++++
nohup gunzip -c /backup/rman_0008/bhaerp99/BIN_18oct12/comn.tar.gz | tar -xvf - &
nohup gunzip -c /backup/rman_0008/bhaerp99/BIN_18oct12/1012.tar.gz | tar -xvf - &
nohup gunzip -c /backup/rman_0008/bhaerp99/BIN_18oct12/appl.tar.gz | tar -xvf - &
nohup gunzip -c /backup/rman_0008/bhaerp99/BIN_18oct12/1013.tar.gz | tar -xvf - &
nohup gunzip -c /backup/rman_0008/bhaerp99/BIN_18oct12/1120.tar.gz | tar -xvf - &
Change database global name
Global database name
=========================
alter database rename global_name to abcgapn1.bh.com;
Linux tar and untar command
------------------
Linux Tar Command:
-------------------
cd /u01/oracle/
nohup tar -czvf /bhapgag1/staging/bin_gpap1_01Sep2013/PGAP1_1120.tar.gz 11.2.0 > /bhapgag1/staging/bin_gpap1_01Oct2013/1120.log &
nohup tar -czvf /bhapgag1/staging/bin_gpap1_01Oct2013/PGAP1_appl.tar.gz appl > /bhapgag1/staging/bin_gpap1_01Oct2013/appl.log &
nohup tar -czvf /bhapgag1/staging/bin_gpap1_01Oct2013/GAP1_comn.tar.gz comn > /bhapgag1/staging/bin_gpap1_01Oct2013/comn.log &
nohup tar -czvf /bhapgag1/staging/bin_gpap1_01Oct2013/PGAP1_1012.tar.gz 10.1.2 > /bhapgag1/staging/bin_gpap1_01Oct2013/10.1.2.log &
nohup tar -czvf /bhapgag1/staging/bin_gpap1_01Oct2013/PGAP1_1013.tar.gz 10.1.3 > /bhapgag1/staging/bin_gpap1_01Oct2013/10.1.3.log &
Linux Untar Command:
---------------------
cd /u01
nohup tar -xzvf /bhapgag1/staging/bin_gpap1_01Sep2013/PGAP1_1120.tar.gz > /bhapgag1/staging/bin_gpap1_01Oct2013/1120_untar.log &
nohup tar -xzvf /bhapgag1/staging/bin_gpap1_01Oct2013/PGAP1_appl.tar.gz > /bhapgag1/staging/bin_gpap1_01Oct2013/appl_untar.log &
nohup tar -xzvf /bhapgag1/staging/bin_gpap1_01Oct2013/PGAP1_comn.tar.gz > /bhapgag1/staging/bin_gpap1_01Oct2013/comn_untar.log &
nohup tar -xzvf /bhapgag1/staging/bin_gpap1_01Oct2013/PGAP1_1012.tar.gz > /bhapgag1/staging/bin_gpap1_01Oct2013/10.1.2_untar.log &
nohup tar -xzvf /bhapgag1/staging/bin_gpap1_01Oct2013/PGAP1_1013.tar.gz > /bhapgag1/staging/bin_gpap1_01Oct2013/10.1.3_untar.log &
setup ssh
setup ssh
++++++++++
on Node1:
---------
mkdir $HOME/.ssh
ssh-keygen -t rsa
copy content of id_rsa.pub to authorized_keys on other (node2) server
on Node2:
---------
and do the same on node2
mkdir $HOME/.ssh
ssh-keygen -t rsa
copy content of id_rsa.pub to authorized_keys on other (node1) server
How to to find out toad session
==========================
To find out toad session
==========================
select p.spid,s.sid,s.serial#,s.username,s.status,s.last_call_et,p.program,p.terminal,logon_time,module,s.osuser
from V$process p,V$session s where s.paddr = p.addr and s.status = 'ACTIVE' and s.module like '%TOAD%';
How to get encrypted password of a user.
====================================
To get encrypted password of a user.
===================================
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 = 'GLOGOWNER';
How to remove archives for a specific date?
++++++++++++++++
How to remove archives for a specific date?
++++++++++++++++
$cd /u01/archive
$rm `ls -l|grep "Apr 13" |awk '{print $9}'`