Monday, October 19, 2020

Find current running SQL :


select sesion.sid,
ses.username,
optimizer_mode,
hash_value,
address,
cpu_time,
elapsed_time,
sql_text
from v$sqlarea sa, v$session ses
where ses.sql_hash_value = sa.hash_value
and ses.sql_address = sa.address
and ses.username is not null;

Sunday, April 26, 2020



How to estimate the daily growth of a tablespace: 

select
   dhs.begin_interval_time,
   dt.tablespace_name,
   trunc(dhtsu.tablespace_size*dt.block_size/1024/1024/1024)  gb,
   trunc(dhtsu.tablespace_usedsize*dt.block_size/1024/1024/1024) gb_used
from
   dba_hist_tbspc_space_usage dhtsu,
   v$tablespace vts,
   dba_tablespaces dt,
   dba_hist_snapshot dhs
where dhtsu.snap_id = dhs.snap_id
and   dhtsu.tablespace_id = vts.ts#
and   vts.name          = dt.tablespace_name
and vts.name                         = '&tablespace name'
order by 2,1 desc;

Monday, February 17, 2020

How to relocate Controlfile To a new location In Oracle

Below steps describes for relocating the controlfiles

1. Get the current control_file location
SQL>  show parameter control_files

2. Set the new location of controlfile:
SQL> alter system set control_files='\Data\TESTDB\Control01.ctl' scope=spfile;
3. shutdown the database:
4. Move control files physically from old location to new location

5. startup the database
SQL> startup;