收集oracle信息的2个脚本

info_new.sql
 

  
  
  
  
  1. set pages 20000 trims on;  
  2. set linesize 500;  
  3. col "Global Name" format a20;  
  4. col "DB Version" format a20;  
  5. col "Host Name" format a10;  
  6. column today noprint new_value xdate   
  7. select to_char(sysdate,'yyyy-mm-dd') today from dual;   
  8. column name noprint new_value dbname   
  9. select name from v$database;   
  10. spool info_&dbname._&xdate..sql  
  11. 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%';  
  12. col "Parameter Name" format a40;  
  13. col "Value" format a40;  
  14. SELECT parameter "Options" FROM   v$option WHERE  value='TRUE';  
  15. show sga;  
  16. SELECT    name "Name", value/1024 "Size (K)" FROM v$sga ORDER BY name;  
  17. select substr(name,0,512) "Parameter Name",  substr(value,0,512) "Value",  isdefault "Default",  issys_modifiable "Dynamic" from v$parameter order by name;  
  18. select  b.value "Max No. of Processes" from (select count(*) count from v$session) a, (select value from v$parameter where name='processes') b;  
  19. select SESSIONS_HIGHWATER  from v$license;  
  20. col RESOURCE_NAME format a25  
  21. col INIT_ALLOCATION format a10  
  22. col LIMIT_VALUE format a10  
  23. select RESOURCE_NAME, CURRENT_UTILIZATION "CURRENT_UTILIZ" ,  
  24. MAX_UTILIZATION "MAX__UTILIZ", INITIAL_ALLOCATION "INIT_ALLOCATION",  
  25. LIMIT_VALUE from v$resource_limit;  
  26. 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;  
  27. col "Table" format a30  
  28. col "Tablespace" format a10  
  29. col "Table Owner" for a12  
  30. 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;  
  31. col "Schema" format a20  
  32. col "Name" format a40  
  33. select owner "Schema", object_name "Name", object_id "Id #",object_type "Type", status "Status" from dba_objects where status != 'VALID';  
  34. 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);  
  35. select grantee "Username", granted_role "Role",  admin_option "Admin Option", default_role "Default" from sys.dba_role_privs order by grantee;  
  36. col "Name" format a60  
  37. SELECT    name "Name", status "Status" from v$controlfile;  
  38. 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(+);  
  39. col "Name" format a40  
  40. col "Tablespace" format a20  
  41. 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);  
  42. col file_name format a40  
  43. col status format a8  
  44. select a.group"group", b.member "file_name", a.bytes/1024/1024 "size(M)", a.status "status", b.status "status" 
  45. from v$log a, v$logfile b where a.group# = b.grouporder by 1,2;  
  46. col usn format 9999  
  47. col SHRINKS format 9999999  
  48. select usn,EXTENTS,RSSIZE,OPTSIZE,HWMSIZE,SHRINKS,STATUS,CUREXT,WRAPS,WAITS   from v$rollstat;  
  49. col "Segment" format a30  
  50. select segment_name "Segment",segment_type "Segment Type",tablespace_name "Tablespace",extents "# of Extents",max_extents "Max Extents" from dba_segments where max_extents - 10 < extents and max_extents != 0 order by tablespace_name;  
  51. col "Tablespace" format a30  
  52. select t.tablespace_name "Tablespace",owner "Schema", table_name "Table",next_extent "Next Extent" from dba_tables t where t.next_extent > (select max(bytes) from dba_free_space f where t.tablespace_name=f.tablespace_name);  
  53. select t.tablespace_name "Tablespace",owner "Schema",  
  54.  segment_name "Segment",segment_type "Segment Type",  
  55.  next_extent "Next Extent" from dba_segments t   
  56.  where t.next_extent > (select max(bytes) from dba_free_space f   
  57.  where t.tablespace_name=f.tablespace_name);  
  58. col "Datafile" format a50;  
  59. select df.TABLESPACE_NAME  "Tablespace",df.file_name  "Datafile",  
  60. to_char(NVL(i.phyrds ,0),'9G999G999G990')   "Physical reads",  
  61. to_char(NVL(i.phywrts,0),'9G999G999G990')    "Physical writes",  
  62. to_char(NVL(i.phyblkrd,0),'9G999G999G990')  "Physical Blks Read",  
  63. to_char(NVL(i.phyblkwrt,0), '9G999G999G990')  "Physical Blks Wrtn",  
  64. to_char(NVL(readtim,0),'9G999G999G999G990')    "Read Time",  
  65. to_char(NVL(writetim,0),'9G999G999G999G990')   "Write Time",  
  66. to_char(NVL(i.phyblkrd/i.phyrds,0),'9G999G999G990D999'"Blocks per Read",  
  67. to_char(NVL(i.phyblkwrt/nvl(decode(i.phywrts,0,1),1),0),'9G999G999G990D999'"Blocks per Write" from sys.v_$filestat i , sys.dba_data_files df where i.phyrds > 0        
  68.  and df.file_id = i.file# order by df.tablespace_name;  
  69. spool off 
  70.  

health_check.sql

 

  
  
  
  
  1. PROMPT   ****************************************************************************  
  2. PROMPT   ****************                                     ***********************  
  3. PROMPT   **************** Database HealthCheck Report ***********************  
  4. PROMPT   ****************                                     ***********************  
  5. PROMPT   ****************************************************************************  
  6. Script    
  7. break on today   
  8. column today noprint new_value xdate   
  9. select to_char(sysdate,'yyyy-mm-dd') today from dual;   
  10. column name noprint new_value dbname   
  11. select name from v$database;   
  12. set heading on   
  13. set pages 40000 lines 300 trims on 
  14. set feedback off   
  15. spool db_check_&dbname._&xdate..sql  
  16. select substr(to_char(sysdate,'fmMonth DD, YYYY HH:MI:SS P.M.'),1,35) today from dual;   
  17. prompt   
  18. prompt **********************************************************   
  19. prompt *****            Database Information                *****   
  20. prompt **********************************************************   
  21. ttitle left "DATABASE:  "dbname"    (AS OF:  "xdate")"   
  22. select name, created, log_mode from v$database;   
  23. prompt  
  24. prompt **********************************************************   
  25. prompt *****            Database Insatll Option             *****   
  26. prompt **********************************************************   
  27. col parameter format a40  
  28. col value format a10  
  29. select * from v$option where value = 'TRUE';  
  30. clear columns  
  31. prompt   
  32. prompt **********************************************************   
  33. prompt *****            Database Version                    *****   
  34. prompt **********************************************************   
  35. set heading off 
  36. select * from v$version;  
  37. set heading on 
  38. prompt   
  39. prompt **********************************************************   
  40. prompt *****            Database Use Session Status         *****   
  41. prompt **********************************************************   
  42. select SESSIONS_CURRENT , SESSIONS_HIGHWATER  from v$license;  
  43. prompt   
  44. prompt **********************************************************   
  45. ttitle off   
  46. clear breaks   
  47. clear computes   
  48. set feedback off   
  49. set heading on   
  50. set termout on   
  51. column "Physical Reads" format 99,999,999,999   
  52. column "Consistent Gets" format 99,999,999,999   
  53. column "DB Block Gets" format 99,999,999,999   
  54. column "Percent (Above 90% ?)" format 999.99   
  55. TTitle left skip 1 - left "*****  Database:  "dbname", DB Block Buffers Hit Ratio  *****" skip 2  
  56. select phys.value "Physical Reads", con.value "Consistent Gets", cur.value "DB Block Gets",  
  57. 100*(cur.value + con.value - phys.value)/(cur.value + con.value) "Percent (Above 90% ?)" 
  58. from v$sysstat cur,v$sysstat con,v$sysstat phys,v$statname ncu,v$statname nco,v$statname nph  
  59. where cur.statistic# = ncu.statistic#  
  60.     and ncu.name = 'db block gets' 
  61.         and con.statistic# = nco.statistic#  
  62.         and nco.name = 'consistent gets' 
  63.         and phys.statistic# = nph.statistic#  
  64.         and nph.name = 'physical reads';    
  65. set heading off   
  66. set termout off   
  67. ttitle off   
  68. clear breaks   
  69. clear computes   
  70. set heading on   
  71. set termout on   
  72. ttitle left skip 1 - left "**********     Show Sga Size     **********" skip 1   
  73. SELECT    name "Name", value/1024 "Size (K)" FROM v$sga ORDER BY name;  
  74. column "Executions" format 999,999,990   
  75. column "Cache Misses Executing" format 999,999,990   
  76. column "Data Dictionary Gets" format 999,999,999   
  77. column "Get Misses" format 999,999,999   
  78. ttitle left skip 1 - left "**********     Shared Pool Size (Execution Misses)     **********" skip 1   
  79. select sum(pins) "Executions",   
  80.        sum(reloads) "Cache Misses Executing",   
  81.      (sum(reloads)/sum(pins)*100) "% Ratio (STAY UNDER 1%)"   
  82. from v$librarycache;   
  83. ttitle left "**********     Shared Pool Size (Dictionary Gets)     **********"  skip 1   
  84. select sum(gets) "Data Dictionary Gets",   
  85.        sum(getmisses) "Get Misses",   
  86.        100*(sum(getmisses)/sum(gets)) "% Ratio (STAY UNDER 10%)"   
  87. from v$rowcache;   
  88. ttitle off   
  89. ttitle left "**********     Log Buffers     **********" skip 1   
  90. select  substr(name,1,25) Name,   
  91.         substr(value,1,15) "VALUE (Near 0?)"   
  92. from v$sysstat   
  93. where name in ('redo log space requests','redo log space wait time');   
  94. ttitle off   
  95. ttitle left "**********     Latch Information     **********" skip 1   
  96. select  substr(ln.name,1,25) Name,   
  97.         l.gets, l.misses,   
  98.         100*(l.misses/l.gets) "% Ratio (STAY UNDER 1%)"   
  99. from v$latch l, v$latchname ln   
  100. where ln.name in ('cache buffers lru chain')   
  101. and ln.latch# = l.latch#;   
  102. ttitle off   
  103. ttitle left "**********     Sort Information     **********" skip 1   
  104. select a.value "Sort(Disk)", b.value "Sort(Memory)",  
  105. round(100*(a.value/decode((a.value+b.value), 0,1,(a.value+b.value))),2) "% Ratio (STAY UNDER 5%)"    
  106. from v$sysstat a, v$sysstat b  
  107. where a.name = 'sorts (disk)' 
  108. and b.name = 'sorts (memory)';  
  109. ttitle off   
  110. column name noprint new_value xdbname   
  111. select name from v$database;   
  112. prompt  
  113. prompt *******************************  
  114. prompt Show Tablespaces and Datafiles    
  115. prompt *******************************  
  116. clear breaks  
  117. clear computes  
  118. clear columns  
  119. ttitle left "**********     Show Tablespaces and Datafiles    **********" skip 1   
  120. set heading on 
  121. column tablespace_name heading 'Tablespace' justify left format a10 truncated  
  122. column file_id heading 'File|ID' justify center format 999  
  123. column file_name heading 'Datafile' justify center format a55 word_wrapped  
  124. column size Heading 'Size|in MG.' justify center format 99,999,990.99  
  125. break on tablespace_name skip 1 on report skip 2  
  126. compute sum label 'TS SIZE:' of size on tablespace_name  
  127. compute sum label 'DB SIZE:' of size on report  
  128. select tablespace_name,  
  129.        file_id,  
  130.        file_name,  
  131.        bytes/1024/1024 "size" 
  132. from dba_data_files  
  133. order by tablespace_name, file_id, file_name;  
  134. clear breaks   
  135. clear computes   
  136. column "Total Bytes" format 99,999,999,999,999   
  137. column "Bytes Free" format 99,999,999,999   
  138. column "Bytes Used" format 99,999,999,999   
  139. column "% Free" format 9999.999   
  140. column "% Used" format 9999.999   
  141. break on report   
  142. compute sum of "Total Bytes" on report   
  143. compute sum of "SQL Blocks" on report   
  144. compute sum of "VMS Blocks" on report   
  145. compute sum of "Bytes Free" on report   
  146. compute sum of "Bytes Used" on report   
  147. compute avg of "% Free" on report   
  148. compute avg of "% Used" on report   
  149. TTitle left "*******   Database:  "dbname", Current Tablespace Usage    *******" skip 1   
  150. col df.file_name for a52  
  151. select  fs.tablespace_name,   
  152.         df.file_name ,   
  153.         df.bytes "Total Bytes",   
  154.         df.blocks "DB Blocks",   
  155.         sum(fs.bytes) "Bytes Free",   
  156.         (100*((sum(fs.bytes))/df.bytes)) "% Free",   
  157.         df.bytes-sum(fs.bytes) "Bytes Used",   
  158.     (100*((df.bytes-sum(fs.bytes))/df.bytes)) "% Used"   
  159. from sys.dba_data_files df, sys.dba_free_space fs   
  160. where df.file_id(+) = fs.file_id   
  161. group by fs.tablespace_name, df.file_name, df.bytes, df.blocks   
  162. order by fs.tablespace_name, df.file_name;   
  163. clear columns  
  164. ttitle off   
  165. column "File Total" format 9,999,999,990   
  166. ttitle  "        *****   Database:  "dbname", DataFile's Disk Activity   *****"   
  167. select substr(df.file#,1,2) "ID",   
  168.        rpad(substr(name,1,52),52,'.'"File Name",   
  169.        rpad(substr(phyrds,1,10),10,'.'"Phy Reads",   
  170.        rpad(substr(phywrts,1,10),10,'.'"Phy Writes",   
  171.        rpad(substr(phyblkrd,1,10),10,'.'"Blk Reads",   
  172.        rpad(substr(phyblkwrt,1,10),10,'.'"Blk Writes",   
  173.        rpad(substr(readtim,1,9),9,'.'"Read Time",   
  174.        rpad(substr(writetim,1,10),10,'.'"Write Time",   
  175.        (sum(phyrds+phywrts+phyblkrd+phyblkwrt+readtim)) "File Total"   
  176. from v$filestat fs, v$datafile df   
  177. where fs.file# = df.file#   
  178. group by df.file#, df.name, phyrds, phywrts, phyblkrd,   
  179.          phyblkwrt, readtim, writetim   
  180. order by sum(phyrds+phywrts+phyblkrd+phyblkwrt+readtim) desc, df.name;   
  181. ttitle off   
  182. prompt  
  183. prompt ****************************************************  
  184. prompt Tablespace Fragmentation  
  185. prompt ****************************************************  
  186. ttitle left "**********     Tablespace Fragmentation     **********" skip 1   
  187. clear breaks  
  188. clear computes  
  189. clear columns  
  190. set heading on 
  191. column tablespace_name heading Tablespace format a19  
  192. column object_count heading 'Objects|(#)' format 999990  
  193. column mb heading Mb format 99,990  
  194. column sum(frags) heading 'Frags|(#)' format 99999  
  195. column avail heading 'Max|(Mb)' format 99,999.99  
  196. column free heading 'Free|(%)' format 999.9  
  197. column bytesize heading 'Size|(Mb)' format 99,999,999  
  198. column byteused heading 'Used|(Mb)' format 99,999,990  
  199. column bytefree heading 'Free|(Mb)' format 99,999,990  
  200. column init_ext heading 'Initial|(K)' format 999999  
  201. column next_ext heading 'Next|(K)' format 999999  
  202. column max_ext heading 'Max_Extent|(Number)' format 9999999999  
  203. column contents heading 'Contents|' Format A9  
  204. break on report  
  205. compute sum of object_count bytesize byteused bytefree on report  
  206. select  tablespace_name,  
  207.     sum(obj_cnt) object_count,  
  208.     sum(ini_ext) init_ext,  
  209.     sum(nex_ext) next_ext,  
  210.         sum(max_ext) max_ext,  
  211.         min(contents) contents,   
  212.     sum(byte)/1048576 bytesize,   
  213.     (sum(byte)/1048576)- (sum(fbyte)/1048576) byteused,  
  214.     sum(fbyte)/1048576 bytefree,  
  215.     sum(frags),  
  216.     sum(largest)/1048576 avail,  
  217.     (sum(fbyte)/decode(sum(byte),0,1,sum(byte)))*100 free 
  218. from 
  219.     (select tablespace_name,  
  220.         0 obj_cnt,  
  221.         0 ini_ext,  
  222.         0 nex_ext,  
  223.                 0 max_ext,  
  224.                 null contents,  
  225.         0 byte,  
  226.         sum(bytes) fbyte,  
  227.         count(*) frags,  
  228.         max(bytes) largest  
  229.      from dba_free_space  
  230.      group by tablespace_name  
  231.     union 
  232.      select tablespace_name,  
  233.         0, 0, 0, 0, Nullsum(bytes), 0, 0, 0  
  234.      from dba_data_files  
  235.      group by tablespace_name  
  236.     union 
  237.      select tablespace_name, 0,  
  238.         initial_extent/1024 ini_ext,  
  239.         decode(next_extent/1024,null,0,next_extent/1024) nex_ext,  
  240.                 decode(max_extents,null,0,max_extents) max_ext,  
  241.                 contents,  
  242.         0,0,0,0  
  243.      from dba_tablespaces  
  244.     union 
  245.      select tablespace_name,  
  246.         count(*) obj_cnt,  
  247.         0, 0 , 0, null,0, 0, 0, 0  
  248.      from dba_segments  
  249.      group by tablespace_name)  
  250. group by tablespace_name;  
  251. clear columns  
  252. clear computes   
  253. set heading on   
  254. set termout on   
  255. ttitle left "     *****    Database:  "dbname", Segment DEFRAGMENTATION NEED, AS OF:    " xdate "      *****"   
  256. select  substr(de.owner,1,8) "Owner",   
  257.         substr(de.segment_type,1,8) "Seg Type",   
  258.         substr(de.segment_name,1,35) "Table Name (Segment)",   
  259.         substr(de.tablespace_name,1,20) "Tablespace Name",   
  260.         extents "Frag NEED"   
  261. from sys.dba_segments de  
  262. where de.owner <> 'SYS'   
  263. and de.segment_type in ('TABLE','INDEX')   
  264. and extents > 20  
  265. order by extents desc;   
  266. ttitle off   
  267. TTitle left "*** Database:  "dbname", Rollback Information ( As of:  " xdate "  ) ***" skip 2   
  268. select  substr(sys.dba_rollback_segs.SEGMENT_ID,1,5) "ID#",   
  269.         substr(sys.dba_segments.OWNER,1,8) "Owner",   
  270.         substr(sys.dba_segments.TABLESPACE_NAME,1,17) "Tablespace Name",   
  271.         substr(sys.dba_segments.SEGMENT_NAME,1,12) "Rollback Name",   
  272.         substr(sys.dba_rollback_segs.INITIAL_EXTENT,1,10) "INI_Extent",  
  273.         substr(sys.dba_rollback_segs.NEXT_EXTENT,1,10) "Next Exts",  
  274.         substr(sys.dba_segments.MIN_EXTENTS,1,5) "MinEx",  
  275.         substr(sys.dba_segments.MAX_EXTENTS,1,5) "MaxEx",  
  276.         substr(sys.dba_segments.PCT_INCREASE,1,5) "%Incr",   
  277.         substr(sys.dba_segments.BYTES,1,15) "Size (Bytes)",   
  278.         substr(sys.dba_segments.EXTENTS,1,6) "Extent#",   
  279.         substr(sys.dba_rollback_segs.STATUS,1,10) "Status"   
  280. from sys.dba_segments, sys.dba_rollback_segs   
  281. where sys.dba_segments.segment_name = sys.dba_rollback_segs.segment_name and   
  282.       sys.dba_segments.segment_type = 'ROLLBACK'   
  283. order by sys.dba_rollback_segs.segment_id;   
  284. ttitle off   
  285. TTitle left " " skip 2 - left "*** Database:  "dbname", Rollback Status ( As of:  " xdate " )  ***" skip 2   
  286. select substr(V$rollname.NAME,1,20) "Rollback_Name",  
  287.         substr(V$rollstat.EXTENTS,1,6) "EXTENT",  
  288.         v$rollstat.RSSIZE, v$rollstat.WRITES,  
  289.         substr(v$rollstat.XACTS,1,6) "XACTS",  
  290.         v$rollstat.GETS,  
  291.         substr(v$rollstat.WAITS,1,6) "WAITS",  
  292.         v$rollstat.HWMSIZE, v$rollstat.SHRINKS,  
  293.         substr(v$rollstat.WRAPS,1,6) "WRAPS",  
  294.         substr(v$rollstat.EXTENDS,1,6) "EXTEND",  
  295.         v$rollstat.AVESHRINK,  
  296.         v$rollstat.AVEACTIVE  
  297. from v$rollname, v$rollstat  
  298. where v$rollname.USN = v$rollstat.USN  
  299. order by v$rollname.USN;  
  300. ttitle off   
  301. TTitle left " " skip 2 - left "*** Database:  "dbname", Rollback Segment Mapping ( As of:  "  xdate " ) ***" skip 2   
  302. select  r.name Rollback_Name,   
  303.       p.pid Oracle_PID,   
  304.         p.spid OS_PID,   
  305.         nvl(p.username,'NO TRANSACTION'Transaction,   
  306.         p.terminal Terminal   
  307. from v$lock l, v$process p, v$rollname r   
  308. where   l.addr = p.addr(+)   
  309.         and trunc(l.id1(+)/65536)=r.usn   
  310.       and l.type(+) = 'TX'   
  311.         and l.lmode(+) = 6   
  312. order by r.name;   
  313. ttitle off   
  314. prompt  
  315. prompt **************************  
  316. prompt Control file Status   
  317. prompt **************************  
  318. col name format a50   
  319. select * from v$controlfile;  
  320. prompt  
  321. prompt *****************************  
  322. prompt Online Redo Logfiles Status  
  323. prompt *****************************  
  324. clear breaks  
  325. clear computes  
  326. clear columns  
  327. column member heading 'Logfile' justify center format a50 word_wrapped  
  328. column group heading 'Group|Number' justify center format 99  
  329. column size heading 'Size|in MG.' justify center format 990.99  
  330. select f.member "member",  
  331.        f.group"group",  
  332.        l.bytes/1024/1024 "size",  
  333.        l.status  
  334. from v$logfile f, v$log l  
  335. where f.group#=l.group#  
  336. order by f.group#,f.member;  
  337. prompt  
  338. prompt ********************************  
  339. prompt The Parameter has been modified:  
  340. prompt ********************************  
  341. clear breaks  
  342. clear computes  
  343. clear columns  
  344. column name heading 'Name' format a35 word_wrapped  
  345. column pvalue heading 'Value' format a80 word_wrapped  
  346. select name, rtrim(value) "pvalue" 
  347. from v$parameter  
  348. where isdefault = 'FALSE' 
  349. order by name;  
  350. prompt  
  351. prompt ******************************************  
  352. prompt User usage   
  353. prompt ******************************************  
  354. prompt  
  355. prompt *****************************************  
  356. Prompt Show the unsuitable Temporary Tablespace   
  357. prompt *****************************************  
  358. select a.username , a.temporary_tablespace "Temporary Tablespace" , b.contents  
  359. from dba_users a , dba_tablespaces b  
  360. where a.temporary_tablespace=b.tablespace_name  
  361. and b.contents <> 'TEMPORARY';  
  362. col grantee format a20  
  363. col granted_role format a30  
  364. col admin_option format a10  
  365. col privilege format a30  
  366. prompt  
  367. prompt **************************************  
  368. Prompt Show the unsuitable Role and Privilege   
  369. prompt **************************************  
  370. select grantee, granted_role, admin_option  
  371. from   sys.dba_role_privs   
  372. where  granted_role in ('DBA''AQ_ADMINISTRATOR_ROLE',  
  373.                        'EXP_FULL_DATABASE''IMP_FULL_DATABASE',  
  374.                        'OEM_MONITOR')  
  375.   and  grantee not in ('SYS''SYSTEM''OUTLN''AQ_ADMINISTRATOR_ROLE',  
  376.                        'DBA''EXP_FULL_DATABASE''IMP_FULL_DATABASE',  
  377.                        'OEM_MONITOR''CTXSYS''DBSNMP''IFSSYS',  
  378.                        'IFSSYS$CM''MDSYS''ORDPLUGINS''ORDSYS',  
  379.                        'TIMESERIES_DBA');  
  380. select grantee, privilege, admin_option  
  381. from   sys.dba_sys_privs   
  382. where  (privilege like '% ANY %' 
  383.   or   privilege in ('BECOME USER''UNLIMITED TABLESPACE')  
  384.   or   admin_option = 'YES')  
  385.  and   grantee not in ('SYS''SYSTEM''OUTLN''AQ_ADMINISTRATOR_ROLE',  
  386.                        'DBA''EXP_FULL_DATABASE''IMP_FULL_DATABASE',  
  387.                        'OEM_MONITOR''CTXSYS''DBSNMP''IFSSYS',  
  388.                        'IFSSYS$CM''MDSYS''ORDPLUGINS''ORDSYS',  
  389.                        'TIMESERIES_DBA');  
  390. prompt  
  391. prompt **************************************************  
  392. prompt Object usage   
  393. prompt **************************************************  
  394. prompt  
  395. prompt ***********************************************************************  
  396. prompt List objects in the SYSTEM tablespace that doesn't belong SYS or SYSTEM  
  397. prompt ***********************************************************************  
  398. col SEGMENT_NAME format a30  
  399. col SEGMENT_TYPE format a15  
  400. col OWNER format a20  
  401. select substr(owner,1,20) OWNER, substr(segment_type,1,15) SEGMENT_TYPE,   
  402.        substr(segment_name,1,30) SEGMENT_NAME   
  403.  from sys.dba_segments  
  404. where owner not in ('PUBLIC''SYS''SYSTEM')  
  405.   and tablespace_name = 'SYSTEM';  
  406. prompt  
  407. prompt ***********************************************************************  
  408. prompt List Invalid objects   
  409. prompt ***********************************************************************  
  410. prompt  
  411. select  substr(obj.owner,1,8) "Owner",   
  412.         obj.object_type "Object Type",   
  413.         substr(obj.object_name,1,35) "Object Name",   
  414.         obj.status "Status"   
  415. from sys.dba_objects obj  
  416. where obj.status <> 'VALID'   
  417. order by owner, object_type, object_name desc;   
  418. set heading on   
  419. set termout on   
  420. spool off   
  421. set feedback on   
  422.  
  423.  
  424.  
  425.  
  426. -- all indexes  
  427. select i.owner,i.table_name,i.index_name,i.index_type,c.column_name,i.last_analyzed  
  428. from  dba_indexes i,dba_ind_columns c  
  429. where i.index_name=c.index_name  
  430. and   i.table_name=c.table_name  
  431. and   i.owner=c.index_owner  
  432. and   i.owner not in ('SYS','SYSTEM','WMSYS','SCOTT','OUTLN')  
  433. /  
  434.  
  435. -- all partitions  
  436.  
  437. select table_owner,table_name,partition_name,subpartition_count,  
  438.        partition_position,tablespace_name  
  439. from   dba_tab_partitions  
  440. /  
  441.  
  442.  

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

本文出自 “无云安全技术站” 博客,谢绝转载!

你可能感兴趣的:(oracle,职场,休闲,oracle信息收集脚本)