CREATETABLESPACE myspace DATAFILE 'E:\myspace\myspace01.DBF' SIZE 15G AUTOEXTEND ON NEXT 1G MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
createuser myuser identified by mypasswd default tablespace myspace temporary tablespace temp quota unlimited on myspace; grantcreate session to myuser; grant Resource to myuser; grantconnectto myuser; grant DBA to myuser;
SELECT sql_text FROM v$sqltext a WHERE (a.hash_value, a.address) IN (SELECT DECODE (sql_hash_value,0, prev_hash_value,sql_hash_value ), DECODE (sql_hash_value, 0, prev_sql_addr, sql_address) FROM v$session b WHERE b.paddr = (SELECT addr FROM v$process c WHERE c.spid='$pid' ) ) ORDERBY piece ASC;
查看资源消耗最多的sql
1 2 3 4 5 6 7
select b.username username,a.disk_reads reads, a.executions exec,a.disk_reads/decode(a.executions,0,1,a.executions) rds_exec_ratio, a.sql_text Statement from v$sqlarea a,dba_users b where a.parsing_user_id=b.user_id and a.disk_reads > 100000 order by a.disk_reads desc;
查看磁盘消耗最多的sql
1 2 3 4 5 6
select disk_reads,sql_text from (select sql_text,disk_reads, dense_rank() over (orderby disk_reads desc) disk_reads_rank from v$sql) where disk_reads_rank <=5;