Saturday, 18 January 2025
Backup Database Link Before Cloning & create them back after clone.
Script to remove archives from Solaris Operating system
Synonyms without a prefix or accessing the object without prefix
Database Features Usage
Script to remove archives
Script to move files to another directory
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}'`
Wednesday, 22 May 2019
You Cannot Analyze a Table Through a Synonym
This was tested on an Oracle 12 database. First I created a table and analyzed it:
$ sqlplus "/as sysdba"
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 22 08:56:23 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> create table wasiq11 (one_col number);
Table created.
SQL> analyze table wasiq11 compute statistics;
Table analyzed.
Then I created a synonym for the table
SQL> create synonym wasiq22 for wasiq11;
Synonym created.
I found that I was able to describe the table via the synonym
SQL> desc wasiq22
Name Null? Type
----------------------------------------- -------- ----------------------------
ONE_COL NUMBER
but I could not able to analyze the table through a synonym
SQL> analyze table wasiq22 compute statistics;
analyze table wasiq22 compute statistics
*
ERROR at line 1:
ORA-00942: table or view does not exist
sqlplus /nolog
-bash-3.2$ sqlplus /nolog
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 22 08:27:44 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> select sysdate from dual;
SP2-0640: Not connected
SQL> show user
USER is ""
SQL>
Tuesday, 21 May 2019
Oracle: Show installed components/options and feature-usage
SELECT * FROM DBA_REGISTRY;
This view also shows the coresponding schema to a component – and also it’s related schemas.
To check which options are enabled:
SELECT * FROM V$OPTION;
To check which features are used:
SELECT * FROM DBA_FEATURE_USAGE_STATISTICS;