环境准备
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;
压力测试脚本1
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.'); commit; delete from testpress.tba; end loop; end; /
压力测试脚本2
COUNTER=0 while [ $COUNTER -lt 20000 ] do sqlplus / as sysdba<<EOF create table test_a as select * from dba_objects; exit; EOF sleep 100 sqlplus / as sysdba<<EOF drop table test_a; exit; EOF let COUNTER+=1 done
监测
查看表空间物理文件的名称及大小
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;