设为首页 收藏本站
查看: 2712|回复: 1

[经验分享] 收集oracle信息的2个脚本

[复制链接]

尚未签到

发表于 2018-9-26 11:45:07 | 显示全部楼层 |阅读模式
  info_new.sql
  

  


  • set pages 20000 trims on;
  • set linesize 500;
  • col "Global Name" format a20;
  • col "DB Version" format a20;
  • col "Host Name" format a10;
  • column today noprint new_value xdate
  • select to_char(sysdate,'yyyy-mm-dd') today from dual;
  • column name noprint new_value dbname
  • select name from v$database;
  • spool info_&dbname._&xdate..sql
  • select a.name "DB Name", e.global_name "Global Name", b.banner "DB Version", c.host_name "Host Name", c.instance_name "Instance Name" ,c.startup_time "Instance Start Time", DECODE(c.logins,'RESTRICTED','YES','NO') "Restricted Mode",a.log_mode  "Archive Log Mode"  FROM v$database a, v$version b, v$instance c,global_name e  WHERE b.banner LIKE '%Oracle%';
  • col "Parameter Name" format a40;
  • col "Value" format a40;
  • SELECT parameter "Options" FROM   v$option WHERE  value='TRUE';
  • show sga;
  • SELECT    name "Name", value/1024 "Size (K)" FROM v$sga ORDER BY name;
  • select substr(name,0,512) "Parameter Name",  substr(value,0,512) "Value",  isdefault "Default",  issys_modifiable "Dynamic" from v$parameter order by name;
  • select  b.value "Max No. of Processes" from (select count(*) count from v$session) a, (select value from v$parameter where name='processes') b;
  • select SESSIONS_HIGHWATER  from v$license;
  • col RESOURCE_NAME format a25
  • col INIT_ALLOCATION format a10
  • col LIMIT_VALUE format a10
  • select RESOURCE_NAME, CURRENT_UTILIZATION "CURRENT_UTILIZ" ,
  • MAX_UTILIZATION "MAX__UTILIZ", INITIAL_ALLOCATION "INIT_ALLOCATION",
  • LIMIT_VALUE from v$resource_limit;
  • SELECT   owner "Schema", object_type "Object Type", COUNT(*) "# Objects" FROM     dba_objects WHERE    owner  'SYS' AND    owner  'SYSTEM' GROUP BY owner, object_type ORDER BY owner, object_type;
  • col "Table" format a30
  • col "Tablespace" format a10
  • col "Table Owner" for a12
  • select a.owner "Table Owner", a.segment_name "Table", b.tablespace_name "Tablespace", sum(a.bytes) "Total Space Used (Bytes)",sum(a.extents) "Total Extents" from dba_segments a, dba_tables b where a.owner  'SYS' and a.owner  'SYSTEM' and a.segment_type = 'TABLE' and a.segment_name = b.table_name and a.owner = b.owner group by a.owner, a.segment_name, b.tablespace_name;
  • col "Schema" format a20
  • col "Name" format a40
  • select owner "Schema", object_name "Name", object_id "Id #",object_type "Type", status "Status" from dba_objects where status != 'VALID';
  • SELECT DISTINCT d.username "Username", d.account_status "Account Status", d.expiry_date "Expire Date", d.default_tablespace "Default Tablespace", d.temporary_tablespace "Temporary Tablespace", d.profile "Profile", d.created "Created", decode(p.sysdba,'TRUE', 'TRUE','') "SYSDBA",decode(p.sysoper,'TRUE','TRUE','')  "SYSOPER" FROM dba_users d, v$pwfile_users p WHERE p.username (+) = d.username ORDER BY initcap(d.username);
  • select grantee "Username", granted_role "Role",  admin_option "Admin Option", default_role "Default" from sys.dba_role_privs order by grantee;
  • col "Name" format a60
  • SELECT    name "Name", status "Status" from v$controlfile;
  • SELECT d.status "Status", d.tablespace_name "Name", d.contents "Type", TO_CHAR(NVL(a.bytes / 1024 / 1024, 0),'99G999G990D900') "Size (M)", TO_CHAR(NVL(a.bytes - NVL(f.bytes, 0),0)/1024/1024, '99G999G990D900') "Used (M)", TO_CHAR(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0), '990D00') "Used %" FROM sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name) a, (select tablespace_name, sum(bytes) bytes from dba_free_space group by tablespace_name) f WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+);
  • col "Name" format a40
  • col "Tablespace" format a20
  • SELECT v.status "Status", d.file_name "Name", d.tablespace_name "Tablespace", TO_CHAR((d.bytes / 1024 / 1024), '99999990D000') "Size (M)", TO_CHAR(NVL(d.bytes - s.bytes, d.bytes)/1024/1024 , '99999990D000')|| '/' ||  d.autoextensible "Used (M)", TO_CHAR((NVL(d.bytes - s.bytes, d.bytes) / d.bytes * 100), '990D00') "Used %" FROM sys.dba_data_files d, v$datafile v, (SELECT file_id, SUM(bytes) bytes  FROM sys.dba_free_space  GROUP BY file_id) s WHERE (s.file_id (+)= d.file_id) AND (d.file_name = v.name);
  • col file_name format a40
  • col status format a8
  • select a.group# "group", b.member "file_name", a.bytes/1024/1024 "size(M)", a.status "status", b.status "status"
  • from v$log a, v$logfile b where a.group# = b.group# order by 1,2;
  • col usn format 9999
  • col SHRINKS format 9999999
  • select usn,EXTENTS,RSSIZE,OPTSIZE,HWMSIZE,SHRINKS,STATUS,CUREXT,WRAPS,WAITS   from v$rollstat;
  • col "Segment" format a30
  • select segment_name &quot;Segment&quot;,segment_type &quot;Segment Type&quot;,tablespace_name &quot;Tablespace&quot;,extents &quot;# of Extents&quot;,max_extents &quot;Max Extents&quot; from dba_segments where max_extents - 10 < extents and max_extents != 0 order by tablespace_name;
  • col &quot;Tablespace&quot; format a30
  • select t.tablespace_name &quot;Tablespace&quot;,owner &quot;Schema&quot;, table_name &quot;Table&quot;,next_extent &quot;Next Extent&quot; from dba_tables t where t.next_extent > (select max(bytes) from dba_free_space f where t.tablespace_name=f.tablespace_name);
  • select t.tablespace_name &quot;Tablespace&quot;,owner &quot;Schema&quot;,
  • segment_name &quot;Segment&quot;,segment_type &quot;Segment Type&quot;,
  • next_extent &quot;Next Extent&quot; from dba_segments t
  • where t.next_extent > (select max(bytes) from dba_free_space f
  • where t.tablespace_name=f.tablespace_name);
  • col &quot;Datafile&quot; format a50;
  • select df.TABLESPACE_NAME  &quot;Tablespace&quot;,df.file_name  &quot;Datafile&quot;,
  • to_char(NVL(i.phyrds ,0),'9G999G999G990')   &quot;Physical reads&quot;,
  • to_char(NVL(i.phywrts,0),'9G999G999G990')    &quot;Physical writes&quot;,
  • to_char(NVL(i.phyblkrd,0),'9G999G999G990')  &quot;Physical Blks Read&quot;,
  • to_char(NVL(i.phyblkwrt,0), '9G999G999G990')  &quot;Physical Blks Wrtn&quot;,
  • to_char(NVL(readtim,0),'9G999G999G999G990')    &quot;Read Time&quot;,
  • to_char(NVL(writetim,0),'9G999G999G999G990')   &quot;Write Time&quot;,
  • to_char(NVL(i.phyblkrd/i.phyrds,0),'9G999G999G990D999') &quot;Blocks per Read&quot;,
  • to_char(NVL(i.phyblkwrt/nvl(decode(i.phywrts,0,1),1),0),'9G999G999G990D999') &quot;Blocks per Write&quot; from sys.v_$filestat i , sys.dba_data_files df where i.phyrds > 0
  • and df.file_id = i.file# order by df.tablespace_name;
  • spool off

  

  

  health_check.sql
  


  • PROMPT   ****************************************************************************
  • PROMPT   ****************                                     ***********************
  • PROMPT   **************** Database HealthCheck Report ***********************
  • PROMPT   ****************                                     ***********************
  • PROMPT   ****************************************************************************
  • Script
  • break on today
  • column today noprint new_value xdate
  • select to_char(sysdate,'yyyy-mm-dd') today from dual;
  • column name noprint new_value dbname
  • select name from v$database;
  • set heading on
  • set pages 40000 lines 300 trims on
  • set feedback off
  • spool db_check_&dbname._&xdate..sql
  • select substr(to_char(sysdate,'fmMonth DD, YYYY HH:MI:SS P.M.'),1,35) today from dual;
  • prompt
  • prompt **********************************************************
  • prompt *****            Database Information                *****
  • prompt **********************************************************
  • ttitle left &quot;DATABASE:  &quot;dbname&quot;    (AS OF:  &quot;xdate&quot;)&quot;
  • select name, created, log_mode from v$database;
  • prompt
  • prompt **********************************************************
  • prompt *****            Database Insatll Option             *****
  • prompt **********************************************************
  • col parameter format a40
  • col value format a10
  • select * from v$option where value = 'TRUE';
  • clear columns
  • prompt
  • prompt **********************************************************
  • prompt *****            Database Version                    *****
  • prompt **********************************************************
  • set heading off
  • select * from v$version;
  • set heading on
  • prompt
  • prompt **********************************************************
  • prompt *****            Database Use Session Status         *****
  • prompt **********************************************************
  • select SESSIONS_CURRENT , SESSIONS_HIGHWATER  from v$license;
  • prompt
  • prompt **********************************************************
  • ttitle off
  • clear breaks
  • clear computes
  • set feedback off
  • set heading on
  • set termout on
  • column &quot;Physical Reads&quot; format 99,999,999,999
  • column &quot;Consistent Gets&quot; format 99,999,999,999
  • column &quot;DB Block Gets&quot; format 99,999,999,999
  • column &quot;Percent (Above 90% ?)&quot; format 999.99
  • TTitle left skip 1 - left &quot;*****  Database:  &quot;dbname&quot;, DB Block Buffers Hit Ratio  *****&quot; skip 2
  • select phys.value &quot;Physical Reads&quot;, con.value &quot;Consistent Gets&quot;, cur.value &quot;DB Block Gets&quot;,
  • 100*(cur.value + con.value - phys.value)/(cur.value + con.value) &quot;Percent (Above 90% ?)&quot;
  • from v$sysstat cur,v$sysstat con,v$sysstat phys,v$statname ncu,v$statname nco,v$statname nph
  • where cur.statistic# = ncu.statistic#
  •     and ncu.name = 'db block gets'
  •         and con.statistic# = nco.statistic#
  •         and nco.name = 'consistent gets'
  •         and phys.statistic# = nph.statistic#
  •         and nph.name = 'physical reads';
  • set heading off
  • set termout off
  • ttitle off
  • clear breaks
  • clear computes
  • set heading on
  • set termout on
  • ttitle left skip 1 - left &quot;**********     Show Sga Size     **********&quot; skip 1
  • SELECT    name &quot;Name&quot;, value/1024 &quot;Size (K)&quot; FROM v$sga ORDER BY name;
  • column &quot;Executions&quot; format 999,999,990
  • column &quot;Cache Misses Executing&quot; format 999,999,990
  • column &quot;Data Dictionary Gets&quot; format 999,999,999
  • column &quot;Get Misses&quot; format 999,999,999
  • ttitle left skip 1 - left &quot;**********     Shared Pool Size (Execution Misses)     **********&quot; skip 1
  • select sum(pins) &quot;Executions&quot;,
  •        sum(reloads) &quot;Cache Misses Executing&quot;,
  •      (sum(reloads)/sum(pins)*100) &quot;% Ratio (STAY UNDER 1%)&quot;
  • from v$librarycache;
  • ttitle left &quot;**********     Shared Pool Size (Dictionary Gets)     **********&quot;  skip 1
  • select sum(gets) &quot;Data Dictionary Gets&quot;,
  •        sum(getmisses) &quot;Get Misses&quot;,
  •        100*(sum(getmisses)/sum(gets)) &quot;% Ratio (STAY UNDER 10%)&quot;
  • from v$rowcache;
  • ttitle off
  • ttitle left &quot;**********     Log Buffers     **********&quot; skip 1
  • select  substr(name,1,25) Name,
  •         substr(value,1,15) &quot;VALUE (Near 0?)&quot;
  • from v$sysstat
  • where name in ('redo log space requests','redo log space wait time');
  • ttitle off
  • ttitle left &quot;**********     Latch Information     **********&quot; skip 1
  • select  substr(ln.name,1,25) Name,
  •         l.gets, l.misses,
  •         100*(l.misses/l.gets) &quot;% Ratio (STAY UNDER 1%)&quot;
  • from v$latch l, v$latchname ln
  • where ln.name in ('cache buffers lru chain')
  • and ln.latch# = l.latch#;
  • ttitle off
  • ttitle left &quot;**********     Sort Information     **********&quot; skip 1
  • select a.value &quot;Sort(Disk)&quot;, b.value &quot;Sort(Memory)&quot;,
  • round(100*(a.value/decode((a.value+b.value), 0,1,(a.value+b.value))),2) &quot;% Ratio (STAY UNDER 5%)&quot;
  • from v$sysstat a, v$sysstat b
  • where a.name = 'sorts (disk)'
  • and b.name = 'sorts (memory)';
  • ttitle off
  • column name noprint new_value xdbname
  • select name from v$database;
  • prompt
  • prompt *******************************
  • prompt Show Tablespaces and Datafiles
  • prompt *******************************
  • clear breaks
  • clear computes
  • clear columns
  • ttitle left &quot;**********     Show Tablespaces and Datafiles    **********&quot; skip 1
  • set heading on
  • column tablespace_name heading 'Tablespace' justify left format a10 truncated
  • column file_id heading 'File|ID' justify center format 999
  • column file_name heading 'Datafile' justify center format a55 word_wrapped
  • column size Heading 'Size|in MG.' justify center format 99,999,990.99
  • break on tablespace_name skip 1 on report skip 2
  • compute sum label 'TS SIZE:' of size on tablespace_name
  • compute sum label 'DB SIZE:' of size on report
  • select tablespace_name,
  •        file_id,
  •        file_name,
  •        bytes/1024/1024 &quot;size&quot;
  • from dba_data_files
  • order by tablespace_name, file_id, file_name;
  • clear breaks
  • clear computes
  • column &quot;Total Bytes&quot; format 99,999,999,999,999
  • column &quot;Bytes Free&quot; format 99,999,999,999
  • column &quot;Bytes Used&quot; format 99,999,999,999
  • column &quot;% Free&quot; format 9999.999
  • column &quot;% Used&quot; format 9999.999
  • break on report
  • compute sum of &quot;Total Bytes&quot; on report
  • compute sum of &quot;SQL Blocks&quot; on report
  • compute sum of &quot;VMS Blocks&quot; on report
  • compute sum of &quot;Bytes Free&quot; on report
  • compute sum of &quot;Bytes Used&quot; on report
  • compute avg of &quot;% Free&quot; on report
  • compute avg of &quot;% Used&quot; on report
  • TTitle left &quot;*******   Database:  &quot;dbname&quot;, Current Tablespace Usage    *******&quot; skip 1
  • col df.file_name for a52
  • select  fs.tablespace_name,
  •         df.file_name ,
  •         df.bytes &quot;Total Bytes&quot;,
  •         df.blocks &quot;DB Blocks&quot;,
  •         sum(fs.bytes) &quot;Bytes Free&quot;,
  •         (100*((sum(fs.bytes))/df.bytes)) &quot;% Free&quot;,
  •         df.bytes-sum(fs.bytes) &quot;Bytes Used&quot;,
  •     (100*((df.bytes-sum(fs.bytes))/df.bytes)) &quot;% Used&quot;
  • from sys.dba_data_files df, sys.dba_free_space fs
  • where df.file_id(+) = fs.file_id
  • group by fs.tablespace_name, df.file_name, df.bytes, df.blocks
  • order by fs.tablespace_name, df.file_name;
  • clear columns
  • ttitle off
  • column &quot;File Total&quot; format 9,999,999,990
  • ttitle  &quot;        *****   Database:  &quot;dbname&quot;, DataFile's Disk Activity   *****&quot;
  • select substr(df.file#,1,2) &quot;ID&quot;,
  •        rpad(substr(name,1,52),52,'.') &quot;File Name&quot;,
  •        rpad(substr(phyrds,1,10),10,'.') &quot;Phy Reads&quot;,
  •        rpad(substr(phywrts,1,10),10,'.') &quot;Phy Writes&quot;,
  •        rpad(substr(phyblkrd,1,10),10,'.') &quot;Blk Reads&quot;,
  •        rpad(substr(phyblkwrt,1,10),10,'.') &quot;Blk Writes&quot;,
  •        rpad(substr(readtim,1,9),9,'.') &quot;Read Time&quot;,
  •        rpad(substr(writetim,1,10),10,'.') &quot;Write Time&quot;,
  •        (sum(phyrds+phywrts+phyblkrd+phyblkwrt+readtim)) &quot;File Total&quot;
  • from v$filestat fs, v$datafile df
  • where fs.file# = df.file#
  • group by df.file#, df.name, phyrds, phywrts, phyblkrd,
  •          phyblkwrt, readtim, writetim
  • order by sum(phyrds+phywrts+phyblkrd+phyblkwrt+readtim) desc, df.name;
  • ttitle off
  • prompt
  • prompt ****************************************************
  • prompt Tablespace Fragmentation
  • prompt ****************************************************
  • ttitle left &quot;**********     Tablespace Fragmentation     **********&quot; skip 1
  • clear breaks
  • clear computes
  • clear columns
  • set heading on
  • column tablespace_name heading Tablespace format a19
  • column object_count heading 'Objects|(#)' format 999990
  • column mb heading Mb format 99,990
  • column sum(frags) heading 'Frags|(#)' format 99999
  • column avail heading 'Max|(Mb)' format 99,999.99
  • column free heading 'Free|(%)' format 999.9
  • column bytesize heading 'Size|(Mb)' format 99,999,999
  • column byteused heading 'Used|(Mb)' format 99,999,990
  • column bytefree heading 'Free|(Mb)' format 99,999,990
  • column init_ext heading 'Initial|(K)' format 999999
  • column next_ext heading 'Next|(K)' format 999999
  • column max_ext heading 'Max_Extent|(Number)' format 9999999999
  • column contents heading 'Contents|' Format A9
  • break on report
  • compute sum of object_count bytesize byteused bytefree on report
  • select  tablespace_name,
  •     sum(obj_cnt) object_count,
  •     sum(ini_ext) init_ext,
  •     sum(nex_ext) next_ext,
  •         sum(max_ext) max_ext,
  •         min(contents) contents,
  •     sum(byte)/1048576 bytesize,
  •     (sum(byte)/1048576)- (sum(fbyte)/1048576) byteused,
  •     sum(fbyte)/1048576 bytefree,
  •     sum(frags),
  •     sum(largest)/1048576 avail,
  •     (sum(fbyte)/decode(sum(byte),0,1,sum(byte)))*100 free
  • from
  •     (select tablespace_name,
  •         0 obj_cnt,
  •         0 ini_ext,
  •         0 nex_ext,
  •                 0 max_ext,
  •                 null contents,
  •         0 byte,
  •         sum(bytes) fbyte,
  •         count(*) frags,
  •         max(bytes) largest
  •      from dba_free_space
  •      group by tablespace_name
  •     union
  •      select tablespace_name,
  •         0, 0, 0, 0, Null, sum(bytes), 0, 0, 0
  •      from dba_data_files
  •      group by tablespace_name
  •     union
  •      select tablespace_name, 0,
  •         initial_extent/1024 ini_ext,
  •         decode(next_extent/1024,null,0,next_extent/1024) nex_ext,
  •                 decode(max_extents,null,0,max_extents) max_ext,
  •                 contents,
  •         0,0,0,0
  •      from dba_tablespaces
  •     union
  •      select tablespace_name,
  •         count(*) obj_cnt,
  •         0, 0 , 0, null,0, 0, 0, 0
  •      from dba_segments
  •      group by tablespace_name)
  • group by tablespace_name;
  • clear columns
  • clear computes
  • set heading on
  • set termout on
  • ttitle left &quot;     *****    Database:  &quot;dbname&quot;, Segment DEFRAGMENTATION NEED, AS OF:    &quot; xdate &quot;      *****&quot;
  • select  substr(de.owner,1,8) &quot;Owner&quot;,
  •         substr(de.segment_type,1,8) &quot;Seg Type&quot;,
  •         substr(de.segment_name,1,35) &quot;Table Name (Segment)&quot;,
  •         substr(de.tablespace_name,1,20) &quot;Tablespace Name&quot;,
  •         extents &quot;Frag NEED&quot;
  • from sys.dba_segments de
  • where de.owner  'SYS'
  • and de.segment_type in ('TABLE','INDEX')
  • and extents > 20
  • order by extents desc;
  • ttitle off
  • TTitle left &quot;*** Database:  &quot;dbname&quot;, Rollback Information ( As of:  &quot; xdate &quot;  ) ***&quot; skip 2
  • select  substr(sys.dba_rollback_segs.SEGMENT_ID,1,5) &quot;ID#&quot;,
  •         substr(sys.dba_segments.OWNER,1,8) &quot;Owner&quot;,
  •         substr(sys.dba_segments.TABLESPACE_NAME,1,17) &quot;Tablespace Name&quot;,
  •         substr(sys.dba_segments.SEGMENT_NAME,1,12) &quot;Rollback Name&quot;,
  •         substr(sys.dba_rollback_segs.INITIAL_EXTENT,1,10) &quot;INI_Extent&quot;,
  •         substr(sys.dba_rollback_segs.NEXT_EXTENT,1,10) &quot;Next Exts&quot;,
  •         substr(sys.dba_segments.MIN_EXTENTS,1,5) &quot;MinEx&quot;,
  •         substr(sys.dba_segments.MAX_EXTENTS,1,5) &quot;MaxEx&quot;,
  •         substr(sys.dba_segments.PCT_INCREASE,1,5) &quot;%Incr&quot;,
  •         substr(sys.dba_segments.BYTES,1,15) &quot;Size (Bytes)&quot;,
  •         substr(sys.dba_segments.EXTENTS,1,6) &quot;Extent#&quot;,
  •         substr(sys.dba_rollback_segs.STATUS,1,10) &quot;Status&quot;
  • from sys.dba_segments, sys.dba_rollback_segs
  • where sys.dba_segments.segment_name = sys.dba_rollback_segs.segment_name and
  •       sys.dba_segments.segment_type = 'ROLLBACK'
  • order by sys.dba_rollback_segs.segment_id;
  • ttitle off
  • TTitle left &quot; &quot; skip 2 - left &quot;*** Database:  &quot;dbname&quot;, Rollback Status ( As of:  &quot; xdate &quot; )  ***&quot; skip 2
  • select substr(V$rollname.NAME,1,20) &quot;Rollback_Name&quot;,
  •         substr(V$rollstat.EXTENTS,1,6) &quot;EXTENT&quot;,
  •         v$rollstat.RSSIZE, v$rollstat.WRITES,
  •         substr(v$rollstat.XACTS,1,6) &quot;XACTS&quot;,
  •         v$rollstat.GETS,
  •         substr(v$rollstat.WAITS,1,6) &quot;WAITS&quot;,
  •         v$rollstat.HWMSIZE, v$rollstat.SHRINKS,
  •         substr(v$rollstat.WRAPS,1,6) &quot;WRAPS&quot;,
  •         substr(v$rollstat.EXTENDS,1,6) &quot;EXTEND&quot;,
  •         v$rollstat.AVESHRINK,
  •         v$rollstat.AVEACTIVE
  • from v$rollname, v$rollstat
  • where v$rollname.USN = v$rollstat.USN
  • order by v$rollname.USN;
  • ttitle off
  • TTitle left &quot; &quot; skip 2 - left &quot;*** Database:  &quot;dbname&quot;, Rollback Segment Mapping ( As of:  &quot;  xdate &quot; ) ***&quot; skip 2
  • select  r.name Rollback_Name,
  •       p.pid Oracle_PID,
  •         p.spid OS_PID,
  •         nvl(p.username,'NO TRANSACTION') Transaction,
  •         p.terminal Terminal
  • from v$lock l, v$process p, v$rollname r
  • where   l.addr = p.addr(+)
  •         and trunc(l.id1(+)/65536)=r.usn
  •       and l.type(+) = 'TX'
  •         and l.lmode(+) = 6
  • order by r.name;
  • ttitle off
  • prompt
  • prompt **************************
  • prompt Control file Status
  • prompt **************************
  • col name format a50
  • select * from v$controlfile;
  • prompt
  • prompt *****************************
  • prompt Online Redo Logfiles Status
  • prompt *****************************
  • clear breaks
  • clear computes
  • clear columns
  • column member heading 'Logfile' justify center format a50 word_wrapped
  • column group heading 'Group|Number' justify center format 99
  • column size heading 'Size|in MG.' justify center format 990.99
  • select f.member &quot;member&quot;,
  •        f.group# &quot;group&quot;,
  •        l.bytes/1024/1024 &quot;size&quot;,
  •        l.status
  • from v$logfile f, v$log l
  • where f.group#=l.group#
  • order by f.group#,f.member;
  • prompt
  • prompt ********************************
  • prompt The Parameter has been modified:
  • prompt ********************************
  • clear breaks
  • clear computes
  • clear columns
  • column name heading 'Name' format a35 word_wrapped
  • column pvalue heading 'Value' format a80 word_wrapped
  • select name, rtrim(value) &quot;pvalue&quot;
  • from v$parameter
  • where isdefault = 'FALSE'
  • order by name;
  • prompt
  • prompt ******************************************
  • prompt User usage
  • prompt ******************************************
  • prompt
  • prompt *****************************************
  • Prompt Show the unsuitable Temporary Tablespace
  • prompt *****************************************
  • select a.username , a.temporary_tablespace &quot;Temporary Tablespace&quot; , b.contents
  • from dba_users a , dba_tablespaces b
  • where a.temporary_tablespace=b.tablespace_name
  • and b.contents  'TEMPORARY';
  • col grantee format a20
  • col granted_role format a30
  • col admin_option format a10
  • col privilege format a30
  • prompt
  • prompt **************************************
  • Prompt Show the unsuitable Role and Privilege
  • prompt **************************************
  • select grantee, granted_role, admin_option
  • from   sys.dba_role_privs
  • where  granted_role in ('DBA', 'AQ_ADMINISTRATOR_ROLE',
  •                        'EXP_FULL_DATABASE', 'IMP_FULL_DATABASE',
  •                        'OEM_MONITOR')
  •   and  grantee not in ('SYS', 'SYSTEM', 'OUTLN', 'AQ_ADMINISTRATOR_ROLE',
  •                        'DBA', 'EXP_FULL_DATABASE', 'IMP_FULL_DATABASE',
  •                        'OEM_MONITOR', 'CTXSYS', 'DBSNMP', 'IFSSYS',
  •                        'IFSSYS$CM', 'MDSYS', 'ORDPLUGINS', 'ORDSYS',
  •                        'TIMESERIES_DBA');
  • select grantee, privilege, admin_option
  • from   sys.dba_sys_privs
  • where  (privilege like '% ANY %'
  •   or   privilege in ('BECOME USER', 'UNLIMITED TABLESPACE')
  •   or   admin_option = 'YES')
  • and   grantee not in ('SYS', 'SYSTEM', 'OUTLN', 'AQ_ADMINISTRATOR_ROLE',
  •                        'DBA', 'EXP_FULL_DATABASE', 'IMP_FULL_DATABASE',
  •                        'OEM_MONITOR', 'CTXSYS', 'DBSNMP', 'IFSSYS',
  •                        'IFSSYS$CM', 'MDSYS', 'ORDPLUGINS', 'ORDSYS',
  •                        'TIMESERIES_DBA');
  • prompt
  • prompt **************************************************
  • prompt Object usage
  • prompt **************************************************
  • prompt
  • prompt ***********************************************************************
  • prompt List objects in the SYSTEM tablespace that doesn't belong SYS or SYSTEM
  • prompt ***********************************************************************
  • col SEGMENT_NAME format a30
  • col SEGMENT_TYPE format a15
  • col OWNER format a20
  • select substr(owner,1,20) OWNER, substr(segment_type,1,15) SEGMENT_TYPE,
  •        substr(segment_name,1,30) SEGMENT_NAME
  • from sys.dba_segments
  • where owner not in ('PUBLIC', 'SYS', 'SYSTEM')
  •   and tablespace_name = 'SYSTEM';
  • prompt
  • prompt ***********************************************************************
  • prompt List Invalid objects
  • prompt ***********************************************************************
  • prompt
  • select  substr(obj.owner,1,8) &quot;Owner&quot;,
  •         obj.object_type &quot;Object Type&quot;,
  •         substr(obj.object_name,1,35) &quot;Object Name&quot;,
  •         obj.status &quot;Status&quot;
  • from sys.dba_objects obj
  • where obj.status  'VALID'
  • order by owner, object_type, object_name desc;
  • set heading on
  • set termout on
  • spool off
  • set feedback on




  • -- all indexes
  • select i.owner,i.table_name,i.index_name,i.index_type,c.column_name,i.last_analyzed
  • from  dba_indexes i,dba_ind_columns c
  • where i.index_name=c.index_name
  • and   i.table_name=c.table_name
  • and   i.owner=c.index_owner
  • and   i.owner not in ('SYS','SYSTEM','WMSYS','SCOTT','OUTLN')
  • /

  • -- all partitions

  • select table_owner,table_name,partition_name,subpartition_count,
  •        partition_position,tablespace_name
  • from   dba_tab_partitions
  • /


  

  在sqlplus下用@/home/oracle/***.sql载入运行



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-602319-1-1.html 上篇帖子: Oracle10g登录次数的变化 下篇帖子: Red Hat AS4上安装 Oracle9i
累计签到:2010 天
连续签到:1 天
发表于 2020-8-3 14:39:28 | 显示全部楼层
好资源,必须支持楼主。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表