一个简单的Oracle压力测试程序

大城市里の小女人 提交于 2019-11-30 05:47:10

环境准备

drop tablespace testpress1;
create tablespace testpress1 datafile '+DATA' size 10g autoextend on;
create user testpress identified by testpress default tablespace testpress1;
alter user testpress quota unlimited on testpress1;
grant resource, connect to testpress;

压力测试脚本

set time on
set timing on
set serveroutput on;
drop table testpress.tba;
create table testpress.tba as select * from dba_objects;
declare
v_count integer;
begin
  v_count := 1;  
  for v_count in 1..2000 loop
     insert into testpress.tba select * from dba_objects; 
     insert into testpress.tba select * from dba_objects;   
     insert into testpress.tba select * from dba_objects;   
     insert into testpress.tba select * from dba_objects; 
     insert into testpress.tba select * from dba_objects;  
     dbms_output.put_line(' Insert for the '||v_count||' time.');
     delete from testpress.tba;
   end loop;
end;
/

  
  

监测


查看表空间物理文件的名称及大小 
SELECT tablespace_name,file_id, 
file_name, 
round(bytes / (1024 * 1024), 0) total_space 
FROM dba_data_files 
where tablespace_name=testpress1;

8. 查看表空间的使用情况

数据表空间使用率:
SELECT a.tablespace_name, 
a.bytes/(1024*1024) total_M, 
b.bytes/(1024*1024) used_M, 
c.bytes/(1024*1024) free_M, 
(b.bytes * 100) / a.bytes "% USED ", 
(c.bytes * 100) / a.bytes "% FREE " 
FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c 
WHERE a.tablespace_name = b.tablespace_name 
AND a.tablespace_name = c.tablespace_name;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!