Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3692849
  • 博文数量: 715
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(715)

文章存档

2023年(75)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

分类: 数据库开发技术

2023-11-15 15:20:03

查看dm.ini

  1. ps -ef|grep dms|grep -v grep|awk '{print $9}'

  2. ps -ef|grep dms|grep -v grep|awk '{print $9}'|awk -F"=" '{print $2}'

  1. --表空间使用
  2. set pagesize 100

  3. SELECT F.TABLESPACE_NAME,round(T.TOTAL_SPACE / 1024,1) TOTAL_G,
  4. round((T.TOTAL_SPACE - F.FREE_SPACE) / 1024,1) USED_G,round(F.FREE_SPACE / 1024,1) FREE_G,
  5. ROUND(((T.TOTAL_SPACE - F.FREE_SPACE) / T.TOTAL_SPACE) * 100) "PER_USED%"
  6. FROM (SELECT TABLESPACE_NAME,ROUND(SUM(BLOCKS *
  7. (SELECT PARA_VALUE / 1024 FROM V$DM_INI
  8. WHERE PARA_NAME = 'GLOBAL_PAGE_SIZE') / 1024)) FREE_SPACE
  9. FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) F,
  10. (SELECT TABLESPACE_NAME, ROUND(SUM(BYTES / 1048576)) TOTAL_SPACE
  11. FROM DBA_DATA_FILES GROUP BY TABLESPACE_NAME) T
  12. WHERE F.TABLESPACE_NAME = T.TABLESPACE_NAME ORDER BY 5 DESC;

  13. --监控运行时错误历史
  14. select * from V$RUNTIME_ERR_HISTORY;

  15. --死锁历史信息记录
  16. select * from V$DEADLOCK_HISTORY;
  17. --查看数据库是否存在阻塞
  18. WITH TRX_TAB AS
  19. (SELECT O1.NAME,L1.TRX_ID FROM V$LOCK L1,SYSOBJECTS O1 WHERE L1.TABLE_ID=O1.ID AND O1.ID<>0),
  20. TRX_SESS AS (
  21. SELECT L.TRX_ID WT_TRXID, L.ROW_IDX BLK_TRXID,L.BLOCKED,(SELECT NAME TABLE_NAME FROM TRX_TAB A WHERE A.TRX_ID=L.TRX_ID) WT_TABLE,
  22. S1.SESS_ID WT_SESS,S2.SESS_ID BLK_SESS,
  23. S1.USER_NAME WT_USER_NAME,S2.USER_NAME BLK_USER_NAME,S1.SQL_TEXT,S1.CLNT_IP,DATEDIFF(SS, S1.LAST_SEND_TIME, SYSDATE) SS
  24. FROM V$LOCK L,V$SESSIONS S1,V$SESSIONS S2
  25. WHERE L.TRX_ID=S1.TRX_ID AND L.ROW_IDX=S2.TRX_ID)
  26. SELECT SYSDATE STATTIME,* FROM TRX_SESS where BLOCKED=1;


  27. --按小时统计arch
  28. select to_char(CREATE_TIME,'yy-mm-dd hh24') xiaoshi,round(sum(free)/1024/1024) mb,count(0) cnt from v$arch_file group by to_char(CREATE_TIME,'yy-mm-dd hh24') order by 1;



  29. --最慢的 20 条 SQL
  30. SELECT TOP 20 START_TIME,TIME_USED/1000 TIME_USED,TOP_SQL_TEXT FROM V$SQL_HISTORY ORDER BY TIME_USED DESC;
  31. SELECT top 20 * FROM V$SYSTEM_LONG_EXEC_SQLS ORDER BY EXEC_TIME DESC;
  32. --高内存的 20 条 SQL 信息
  33. select top 20 * from V$SYSTEM_LARGE_MEM_SQLS order by mem_used_by_k desc;

  34. --查看所有作业信息
  35. SELECT A.ID,A.NAME,A."ENABLE",A.USERNAME,A.CREATETIME,A.MODIFYTIME,A.DESCRIBE,
  36. B.LAST_DATE||' '||B.LAST_SEC LAST_TIME,B.NEXT_DATE||' '||B.NEXT_SEC NEXT_TIME,B.WHAT
  37. FROM SYSJOB.SYSJOBS A,SYSJOB.USER_JOBS B
  38. WHERE A.ID=B.JOB;


  39. --用户权限
  40. SELECT * FROM (
  41. SELECT GRANTEE,GRANTED_ROLE PRIVILEGE,'ROLE_PRIVS' PRIVILEGE_TYPE,CASE ADMIN_OPTION WHEN 'Y' THEN 'YES' ELSE 'NO' END ADMIN_OPTION FROM DBA_ROLE_PRIVS
  42. UNION SELECT GRANTEE,PRIVILEGE,'SYS_PRIVS' PRIVILEGE_TYPE,ADMIN_OPTION FROM DBA_SYS_PRIVS
  43. UNION SELECT GRANTEE,PRIVILEGE||' ON '||OWNER||'.'||TABLE_NAME PRIVILEGE,'TABLE_PRIVS' PRIVILEGE_TYPE,GRANTABLE FROM DBA_TAB_PRIVS
  44. )
  45. WHERE GRANTEE IN (SELECT USERNAME FROM ALL_USERS WHERE USERNAME NOT IN ('SYS','SYSDBA','SYSSSO','SYSAUDITOR') )
  46. ORDER BY GRANTEE,PRIVILEGE_TYPE,PRIVILEGE;

阅读(344) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~