查看錶空間的使用方式
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) DWHERE D.TABLESPACE_NAME = F.TABLESPACE_NAMEORDER BY 1
查看各個資料表空間的資料檔案
select t1.name, t2.name,Round(t2.BYTES / ( 1024 * 1024 ), 2) "大小(M)" from v$tablespace t1, v$datafile t2 where t1.ts# = t2.ts# order by 1,3
查看SYSAUX資料表空間使用方式
SELECT * FROM (SELECT BYTES, segment_name, segment_type, owner FROM dba_segments WHERE tablespace_name = 'SYSAUX' ORDER BY BYTES DESC) WHERE ROWNUM < 10 ```執行以下語句 修改表資料檔案大小
SQL> select dbms_stats.get_stats_history_retention from dual;
GET_STATS_HISTORY_RETENTION--------------------------- 31 ```SQL> exec dbms_stats.alter_stats_history_retention(15); ```PL/SQL procedure successfully completed ```SQL> select min(snap_id),max(snap_id) from dba_hist_snapshot; ```MIN(SNAP_ID) MAX(SNAP_ID)------------ ------------ 35044 35248 ```SQL> exec dbms_workload_repository.drop_snapshot_range(low_snap_id =>35044,high_snap_id => 35044+24); ```PL/SQL procedure successfully completed修改表資料檔案大小 ```SQL> ALTER DATABASE DATAFILE 'D:\APP\ADMINISTRATOR\ORADATA\XUEJIAYUE\SYSAUX01.DBF' RESIZE 2048M;
Database altered
SQL> ALTER DATABASE DATAFILE 'D:\APP\ADMINISTRATOR\ORADATA\XUEJIAYUE\XUEJIAYUE01.DBF' RESIZE 2048M;
SQL>
Database altered
ALTER DATABASE DATAFILE 'D:\APP\ADMINISTRATOR\ORADATA\XUEJIAYUE\UNDOTBS01.DBF' RESIZE 2048M;
看看效率比較低的語句(http://blog.csdn.net/ocean1010/article/details/5947580)
SELECT EXECUTIONS , DISK_READS, BUFFER_GETS, ROUND((BUFFER_GETS-DISK_READS)/BUFFER_GETS,2) Hit_radio, ROUND(DISK_READS/EXECUTIONS,2) Reads_per_run, SQL_TEXT FROM V$SQLAREA WHERE EXECUTIONS>0 AND BUFFER_GETS > 0 AND (BUFFER_GETS-DISK_READS)/BUFFER_GETS < 0.8 ORDER BY 4 DESC;
然後
最佳化相關的表格