user:
-----
set linesize 100
set feedback off
set verify off
set pagesize 66
set wrap off
set pages 50
set lines 131
prompt
prompt Status of top active users by CPU
prompt
select to_char(sysdate,'YY-MM-DD:HH24-MI-SS') stime from dual;
column u_name format a8
column Osuser format a8
column Orauser format a8
column Sid_sn# format a13 Heading "'SID,SNO#'"
column S_pid format a5
column C_pid format a5
column Server format a10
column client_program format a28
select s.osuser "Osuser",s.username "Orauser",''''||s.sid||','||s.serial#||'''' sid_sn#,
s.process C_pid,substr(p.spid,1,5) "S_pid", s.machine Server,
decode(instr(s.program,'@'), 0, s.program, nvl(substr(s.program,1,instr(s.program,'@')-1),p.program)) client_program,
l.value "CPU",m.value "READS",to_char(s.logon_time, 'YY-MM-DD:HH24:MI:SS') logon_time from
v$session s,v$process p, v$sesstat l, v$sesstat m
where s.paddr = p.addr
and l.sid=m.sid
and s.status='ACTIVE'
and s.sid=l.sid and l.statistic#=12
and (l.value > 0 or m.value > 0)
and m.statistic#=9
order by l.value
ams SPace:
----------
col path for a40
select NAME,STATE,TOTAL_MB,FREE_MB from v$ASM_DISKGROUP;
select GROUP_NUMBER,DISK_NUMBER,TOTAL_MB,FREE_MB,STATE,PATH,NAME from v$asm_disk;
Invalid object:
--------------
set lines 132
col object_name format a50
spool invalids.out
select owner,object_type,object_name,last_ddl_time from dba_objects where status='INVALID'
order by owner,object_type,object_name;
spool off
Locks:
------
set lines 132
column Session_ID format a15;
SELECT DECODE(request,0,'Holder: ','Waiter: ')||sid Session_ID,
id1 Lock_ID_1, id2 Lock_ID_2,
decode(lmode,1,'Null',2,'Row-S(SS)',3,'Row-X(SX)',4,'Share(S)',5,'S/Row-x(SSX)',6,'Exclusive(X)','None') Lock_Mode,
decode(request,1,'Null',2,'Row-S(SS)',3,'Row-X(SX)',4,'Share(S)',5,'S/Row-x(SSX)',6,'Exclusive(X)','None') Lock_Mode_Request,
decode(type,'TX','Transaction Enqueue(TX)','TM','DML Enqueue(TM)','UL','User Supplied(UL)') Type_of_Lock,
round(ctime/60,2) Time_Min
FROM V$LOCK
WHERE (id1, id2, type) IN
(SELECT id1, id2, type FROM V$LOCK WHERE request>0)
ORDER BY id1, request;
px waits:
----------
set lines 131
column sid format 9999
column event format a25
column p1text format a20
column p2text format a10
column p3text format a10
select sw.sid,event,p1text,p1,p2text,p2,p3text,p3,server_set
from v$session_wait sw, v$px_session ps
where ps.sid = sw.sid
order by qcsid,server_group,server_set,server#
px stats:
---------
set lines 131
column name format a26
break on name skip 1
compute sum of value on name
select /*+ ordered */ name,value,sid,serial#,qcsid,server_group,server_set,server#,degree,req_degree
from v$statname n, v$px_sesstat ps
where ps.statistic# = n.statistic#
and name in ('physical reads direct','session logical reads')
order by name,qcsid,server_group,server_set,server#
space_ts_report:
-----------------
set lines 120
set pages 60
ttitle center "Tablespace Space Usage Report" skip 2
break on report
compute sum of ddf_sum_megs on report
compute sum of dfs_sum_megs on report
compute avg of dfs_percent_free on report
column dfs_tablespace_name format a30 heading "Tablespace"
col ddf_sum_megs format 999,999,999.9 heading "MB Allocated"
col dfs_sum_megs format 999,999,999.9 heading "MB Free"
col dfs_percent_free format 999.9 heading "% Free"
col dfs_max_megs format 999,999,999.9 heading "MB Max Free"
col dfs_c_extents format 999,999,999,999 heading "# Free Extents"
col dfs_avg_megs format 999,999,999.9 heading "MB Avg Free"
spool /tmp/ts_space_report
select ddf_tablespace_name TABLESPACE,
ddf_sum_bytes/1024/1024 ddf_sum_megs,
nvl(dfs_sum_bytes,0)/1024/1024 dfs_sum_megs,
(nvl(dfs_sum_bytes,0)/ddf_sum_bytes) * 100 dfs_percent_free,
nvl(dfs_max_bytes,0)/1024/1024 dfs_max_megs,
nvl(dfs_cnt_extents,0) dfs_c_extents,
(nvl(dfs_sum_bytes,0)/dfs_cnt_extents)/1024/1024 dfs_avg_megs
from (
select tablespace_name dfs_tablespace_name,
sum(bytes) dfs_sum_bytes,
max(bytes) dfs_max_bytes,
count(*) dfs_cnt_extents
from dba_free_space
group by tablespace_name
union all
select tname dfs_tablespace_name,
nvl(tbytes,0) - nvl(ubytes,0) dfs_sum_bytes,
mblocks dfs_max_bytes,rcount dfs_cnt_extents
from
(select tablespace_name tname,sum(bytes) tbytes,count(*) rcount from dba_temp_files group by tablespace_name),
(select tablespace stname,sum(blocks)*8182 ubytes,max(blocks) mblocks from v$sort_usage group by tablespace)
where stname (+) = tname
),
(
select tablespace_name ddf_tablespace_name,
sum(bytes) ddf_sum_bytes
from dba_data_files
group by tablespace_name
union all
select tablespace_name ddf_tablespace_name,
sum(bytes) ddf_sum_bytes
from dba_temp_files
group by tablespace_name
)
where dfs_tablespace_name (+) = ddf_tablespace_name
order by dfs_percent_free desc;
lag
----
SELECT to_char(APPLIED_TIME,'dd/mm/yyyy hh24:mi:ss') "Standby Time",
to_char(READ_TIME,'dd/mm/yyyy hh24:mi:ss') "Recover time",
to_char(sysdate,'dd/mm/yyyy hh24:mi:ss') "Production Time",
trunc(((86400*(sysdate-APPLIED_TIME))/60/60/24))-(trunc((((86400*(sysdate-APPLIED_TIME))/60)/60/24)/30)) "Days",trunc(((86400*(sysdate-APPLIED_TIME))/60)/60)-24*(trunc((((86400*(sysdate-APPLIED_TIME))/60)/60)/24)) "Hrs",
trunc((86400*(sysdate-APPLIED_TIME))/60)-60*(trunc(((86400*(sysdate-APPLIED_TIME))/60)/60)) "Min",
trunc(86400*(sysdate-APPLIED_TIME))-60*(trunc((86400*(sysdate-APPLIED_TIME))/60)) "Sec"
FROM DBA_LOGSTDBY_PROGRESS;
current sql :
-------------
select sid, s.sql_id, s.sql_child_number, sql_fulltext
from v$session s, v$process p, v$logstdby l, v$sql a
where s.paddr=p.addr and p.spid=l.pid and s.sql_id=a.sql_id and s.sql_child_number=a.child_number;
select t.*
from v$session s, v$process p, v$logstdby l, v$sql a, table(DBMS_XPLAN.DISPLAY_CURSOR(a.sql_id, a.child_number, 'BASIC')) t
where s.paddr=p.addr and p.spid=l.pid and s.sql_id=a.sql_id and s.sql_child_number=a.child_number;
select sql_id, parse_calls, disk_reads, direct_writes, buffer_gets, rows_processed, fetches, executions, loads, version_count,
cpu_time, elapsed_time, sorts, sharable_mem, total_sharable_mem
from v$sqlstats where sql_id in (
select s.sql_id from v$session s, v$process p, v$logstdby l where s.paddr=p.addr and p.spid=l.pid);
Explain:
--------
REM
REM ident @(#) BU DBA Group - P2K: explain.sql 1.4 07/06/01 09:33:13
REM
REM File: explain.sql Release 1.4 06/01/07 09:33:13
REM This version checked out of SCCS on 07/06/01 at 09:33:13
REM Control: /opt/oracle/dba/SCCS/common/sql/s.explain.sql
REM -------------------------------------------------------------------------
REM *** Do not edit this file outside of SCCS control ***
REM
REM To get an editable copy of this file use the command: sccs edit explain.sql
REM Edit the file with your favourite editor.
REM When finished editing use the command: sccs delget explain.sql
REM -------------------------------------------------------------------------
REM
REM Author: Oracle 9.2 feature scripted by Muthu Chinnasamy
REM
REM Synopsis: Explain some arbitary SQL
REM
REM Syntax: @explain.sql SQLfilename
REM
REM Example:
REM 1. Logon to sqlplus
REM 2. Run the command
REM explain plan for "your SQL"
REM 3. @explain
REM
REM Assumptions: Requires $ORACLE_HOME/rdbms/admin/utlxplan.sql
REM
REM History: sccs prt explain.sql
REM
REM -- set error traps so that we can detect failure in the calling kshell
whenever sqlerror exit sql.sqlcode rollback
whenever oserror exit failure rollback
set lines 132 pages 2000
select * from table(dbms_xplan.display);
rollback;
REM spool off
REM exit
getsql
-------
set pages 100 lines 110 wrap on feed 0 termout on veri off head on
accept sessionid Prompt "Enter SID : "
column sid format 99999
column serial# format 99999
column program format a35
column ora_user format a10
column osuser format a10
column cproc format 99999
column sproc format 99999
set long 5000
select s.sid SID ,s.serial# serial#,s.program program, s.username ora_user ,s.osuser osuser,
s.process c_proc,s.sql_hash_value,p.spid s_proc,s.sql_id sqlid from v$session s,v$process p
where sid=&sessionid
and s.paddr=p.addr;
select t.sql_text from v$session s,v$sqltext t
where sid=&sessionid
and s.sql_hash_value = t.hash_value (+)
order by t.piece
;
sqlid:
------
set lines 250 pages 9999 veri off long 9999
col snap_time format a13
col agg_cpu format 999999.99
col agg_et format 999999.99
col to_from format a13
col ins format 99
col exec format 999,999,999
col bg format 999,999,999,999
col bg_exe format 999,999,999
col et_exe format 999,999.99
col cpu_exe format 999,999.99
col dr_exe format 999,999,999
col rows_proc format 9,999,999
col sql_id new_value sqlid
select sql_id,sql_text from dba_hist_sqltext where sql_id='&sql_id';
select
b.sql_id,
to_char(s.begin_interval_time,'YYYYMMDD::HH24') snap_time,
b.snap_id||'-'||b.snap_id to_from,
s.instance_number ins,
b.plan_hash_value plan_hash,
b.executions_delta exec,
b.buffer_gets_delta bg,
case b.executions_delta when 0 then 0 else (b.buffer_gets_delta / b.executions_delta) end bg_exe,
case b.executions_delta when 0 then 0 else (b.cpu_time_delta/1000000)/b.executions_delta end cpu_exe,
case b.executions_delta when 0 then 0 else (b.elapsed_time_delta/1000000)/b.executions_delta end et_exe,
case b.executions_delta when 0 then 0 else b.disk_reads_delta/b.executions_delta end dr_exe,
b.rows_processed_delta rows_proc
from
dba_hist_sqlstat b,
dba_hist_snapshot s
where
b.sql_id = '&sqlid' and
b.snap_id = s.snap_id
and s.begin_interval_time >= sysdate-&days_back
and s.instance_number = b.instance_number
and b.executions_delta > 0
order by
b.sql_id,
b.snap_id,
b.snap_id,
s.instance_number
;
FRA:
select * from v $ recovery_file_dest;выберите * из v $ flash_recovery_area_usage;
выберите тип файла, space_used процент_спространства_используется / 100/1024/1024 используется, пробел_рекламируемый процент_спространства_возвратный / 100/1024/1024 восстанавливается, frau.number_of_file vs $ $, v $ flash_recovery_area_usage frau;