随笔:93 文章:11 评论:22 引用:0
首页 发新随笔
发新文章 联系 聚合管理

2013年4月16日

--查询表空间、表空间大小及表空间对应物理路径

select a.tablespace_name,b.file_name,a.block_size,a.block_size,b.bytes/1024

/1024 "Sum MB" from dba_tablespaces a,dba_data_files b where a.tablespace_name=b.tablespace_name;

--查询表空间使用情况

  SELECT UPPER(F.TABLESPACE_NAME) "表空间名",

  D.TOT_GROOTTE_MB "表空间大小(M)",

  D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",

  TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') || '%' "使用比",

  F.TOTAL_BYTES "空闲空间(M)",

  F.MAX_BYTES "最大块(M)"

  FROM (SELECT TABLESPACE_NAME,

  ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,

  ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES

  FROM SYS.DBA_FREE_SPACE

  GROUP BY TABLESPACE_NAME) F,

  (SELECT DD.TABLESPACE_NAME,

   ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB

  FROM SYS.DBA_DATA_FILES DD

  GROUP BY DD.TABLESPACE_NAME) D

  WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME

  ORDER BY 1;

--查询表空间的free space

  select tablespace_name,

  count(*) as extends,

  round(sum(bytes) / 1024 / 1024, 2) as MB,

  sum(blocks) as blocks

  from dba_free_space

group by tablespace_name;

 

--查询表空间的总容量

  select tablespace_name, sum(bytes) / 1024 / 1024 as MB

  from dba_data_files

  group by tablespace_name;

 

 

--查询表空间使用率

  select total.tablespace_name,

  round(total.MB, 2) as Total_MB,考试大论坛

  round(total.MB - free.MB, 2) as Used_MB,

  round((1 - free.MB / total.MB) * 100, 2) || '%' as Used_Pct

  from (select tablespace_name, sum(bytes) / 1024 / 1024 as MB

  from dba_free_space

  group by tablespace_name) free,

  (select tablespace_name, sum(bytes) / 1024 / 1024 as MB

  from dba_data_files

  group by tablespace_name) total

  where free.tablespace_name = total.tablespace_name;

 

 

1.查找当前表级锁的SQL如下:

select sess.sid,

    sess.serial#,

    lo.oracle_username,

    lo.os_user_name,

    ao.object_name,

    lo.locked_mode

    from v$locked_object lo,

    dba_objects ao,

    v$session sess

where ao.object_id = lo.object_id and lo.session_id = sess.sid;

 

2.杀掉锁表进程:

alter system kill session '436,35123';

 

3.RAC环境中锁查找:

SELECT inst_id,DECODE(request,0,'Holder: ','Waiter: ')||sid sess,

        id1, id2, lmode, request, type,block,ctime

FROM GV$LOCK

WHERE (id1, id2, type) IN

       (SELECT id1, id2, type FROM GV$LOCK WHERE request>0)

ORDER BY id1, request;

  

 

 

4.监控当前数据库谁在运行什么SQL语句

select osuser, username, sql_text 

from  v$session a, v$sqltext b

where  a.sql_address =b.address order by address, piece;

 

 

 

5.找使用CPU多的用户session

select a.sid,spid,status,substr(a.program,1,40) prog, a.terminal,osuser,value/60/100 value

from  v$session a,v$process b,v$sesstat c

where  c.statistic#=12 and 

       c.sid=a.sid and 

       a.paddr=b.addr 

       order by value desc;

 

 

6.查看死锁信息

SELECT (SELECT username

          FROM v$session

         WHERE SID = a.SID) blocker, a.SID, 'is blocking',

       (SELECT username

          FROM v$session

         WHERE SID = b.SID) blockee, b.SID

  FROM v$lock a, v$lock b

 WHERE a.BLOCK = 1 AND b.request > 0 AND a.id1 = b.id1 AND a.id2 = b.id2;

 

 

7.具有最高等待的对象

SELECT   o.OWNER,o.object_name, o.object_type, a.event,

         SUM (a.wait_time + a.time_waited) total_wait_time

    FROM v$active_session_history a, dba_objects o

   WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE

     AND a.current_obj# = o.object_id

GROUP BY o.OWNER,o.object_name, o.object_type, a.event

ORDER BY total_wait_time DESC;

 

 

SELECT   a.session_id, s.osuser, s.machine, s.program, o.owner, o.object_name,

         o.object_type, a.event,

         SUM (a.wait_time + a.time_waited) total_wait_time

    FROM v$active_session_history a, dba_objects o, v$session s

   WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE

     AND a.current_obj# = o.object_id

     AND a.session_id = s.SID

GROUP BY o.owner,

         o.object_name,

         o.object_type,

         a.event,

         a.session_id,

         s.program,

         s.machine,

         s.osuser

ORDER BY total_wait_time DESC;

 

 

 

8.查询当前连接会话数

select s.value,s.sid,a.username

from

v$sesstat S,v$statname N,v$session A

where

n.statistic#=s.statistic# and

name='session pga memory'

and s.sid=a.sid

order by s.value;

 

 

 

9.等待最多的用户

SELECT   s.SID, s.username, SUM (a.wait_time + a.time_waited) total_wait_time

    FROM v$active_session_history a, v$session s

   WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE

GROUP BY s.SID, s.username

ORDER BY total_wait_time DESC;

 

 

 

10.等待最多的SQL

SELECT   a.program, a.session_id, a.user_id, d.username, s.sql_text,

         SUM (a.wait_time + a.time_waited) total_wait_time

    FROM v$active_session_history a, v$sqlarea s, dba_users d

   WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE

     AND a.sql_id = s.sql_id

     AND a.user_id = d.user_id

GROUP BY a.program, a.session_id, a.user_id, s.sql_text, d.username;

 

 

 

11.查看消耗资源最多的SQL

SELECT hash_value, executions, buffer_gets, disk_reads, parse_calls

FROM V$SQLAREA

WHERE buffer_gets > 10000000 OR disk_reads > 1000000

ORDER BY buffer_gets + 100 * disk_reads DESC;

 

 

 

12.查看某条SQL语句的资源消耗

SELECT hash_value, buffer_gets, disk_reads, executions, parse_calls

FROM V$SQLAREA

WHERE hash_Value = 228801498 AND address = hextoraw('CBD8E4B0');

 

 

13.查询会话执行的实际SQL

SELECT   a.SID, a.username, s.sql_text

    FROM v$session a, v$sqltext s

   WHERE a.sql_address = s.address

     AND a.sql_hash_value = s.hash_value

     AND a.status = 'ACTIVE'

ORDER BY a.username, a.SID, s.piece;

 

 

14.显示正在等待锁的所有会话

SELECT * FROM DBA_WAITERS;

 

DDL

--------------------------------------------------------------

/*注意点:

 

1.如果在PL/SQL 等工具里打开的话,直接修改下面的代码中[斜体加粗部分]执行

 

2.确保路径存在,比如【D:\oracle\oradata\Oracle9i\】也就是你要保存文件的路径存在

 

/*分为四步 */

 

/*第1步:创建临时表空间  */

 

create temporary tablespace user_temp 

 

tempfile 'D:\oracle\oradata\Oracle9i\user_temp.dbf'

 

size 50m 

 

autoextend on 

 

next 50m maxsize 20480m 

 

extent management local; 

 

 

 

/*第2步:创建数据表空间  */

 

create tablespace user_data 

 

logging 

 

datafile 'D:\oracle\oradata\Oracle9i\user_data.dbf'

 

size 50m 

 

autoextend on 

 

next 50m maxsize 20480m 

 

extent management local; 

 

 

 

/*第3步:创建用户并指定表空间  */

 

create user username identified by password 

 

default tablespace user_data 

 

temporary tablespace user_temp; 

 

 

 

/*第4步:给用户授予权限  */

 

grant connect,resource,dba to username; 

posted @ 2014-03-03 15:48 redcoatjk 阅读(334) | 评论 (0)编辑 收藏
 
摘自: http://www.douban.com/note/235086917/
http://jackleechina.iteye.com/blog/1595397

为什么一般要采用事件监听而不是直接对元素的事件属性(如:onclick、onmouseover)赋值?

原来用事件属性只能赋值一种方法,即:

button1.onclick = function() { alert(1); };
button1.onclick = function() { alert(2); };

这样后面的赋值语句就将前面的onclick属性覆盖了

而使用添加事件监听的方式就可以实现并行。特别是当团队合作时,事件并行的需求增多,比如:监听document对象的鼠标事件或者window对象的载入事件等。使用事件属性则很容易造成事件覆盖掉

使用事件监听有两种方式:attachEvent和addEventListener

attachEvent与addEventListener区别
适应的浏览器版本不同,同时在使用的过程中要注意
attachEvent方法 按钮onclick
addEventListener方法 按钮click
attachEvent方法, (ie系列)
addEventListener方法 Mozilla系列

例子如下:
 1<!DOCTYPE html>
 2<html>
 3
 4<SCRIPT LANGUAGE="JavaScript">
 5function method1(){
 6    alert("method1");
 7}

 8function method2(){
 9    alert("method2");
10}

11function method3(){
12    alert("method3");
13}

14
</SCRIPT>
15<body>
16<input type="button"  value="dom 元素事件属性绑定的按钮" id="button1"/>
17<input type="button"  value="IE浏览器: attachEvent进行事件绑定的按钮" id="btn1"/>
18<input type="button"  value="火狐浏览器: addEventListener进行事件绑定的按钮" id="btn2"/>
19
20<SCRIPT LANGUAGE="JavaScript">
21     /**方法一: 使用元素的事件属性. [这种方式事件只可绑定一次,最后绑定的执行]**/
22     button1.onclick = function() { alert("1-1"); };
23     button1.onclick = function() { alert("1-2"); };
24     /**方法二: 使用attachEvent注册事件. 格式如下object.attachEvent(event,function);**/
25   var btn1Obj = document.getElementById("btn1");
26    btn1Obj.attachEvent("onclick", method1);
27   btn1Obj.attachEvent("onclick", method2);
28    btn1Obj.attachEvent("onclick", method3);
29     /**方法三: addEventListener. 格式如下element.addEventListener(type,listener,useCapture);**/
30    var btn2Obj = document.getElementById("btn2");
31    btn2Obj.addEventListener("click",method1,false);
32    btn2Obj.addEventListener("click",method2,false);
33    btn2Obj.addEventListener("click",method3,false);
34    //执行顺序为method1->method2->method3
35
</SCRIPT>
36<br/>attachEvent按照注册倒叙执行:    执行顺序为method3->method2->method1 
37<br/>addEventListener按照注册顺序执行:    执行顺序为method1->method2->method3 
38</body>
39</html>

相关衍生阅读:

JavaScript欲速则不达——基本处理事件详解和阻止事件传播

posted @ 2013-11-04 14:22 redcoatjk 阅读(424) | 评论 (0)编辑 收藏
 
     摘要: 摘自http://zhangjunhd.blog.51cto.com/113473/20629/ 1.Servlet过滤器 1.1 什么是过滤器 过滤器是一个程序,它先于与之相关的servlet或JSP页面运行在服务器上。过滤器可附加到一个或多个servlet或JSP页面上,并且可以检查进入这些资源的请求信息。在这之后,过滤器可以作如下的选择: ①以常规的方式调用资源(即,调...  阅读全文
posted @ 2013-04-16 17:28 redcoatjk 阅读(252) | 评论 (0)编辑 收藏
CALENDER
<2013年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(3)

随笔分类(22)

随笔档案(76)

文章分类(12)

文章档案(17)

搜索

  •  

积分与排名

  • 积分 - 249984
  • 排名 - 227

最新评论

评论排行榜


Powered By: 博客园
模板提供沪江博客