59.蛤蟆的Oracle杂记——Oracle办公常用命令
SELECT D.TABLESPACE_NAME,
SPACE || 'M' "SUM_SPACE(M)",
BLOCKS "SUM_BLOCKS",
SPACE - NVL (FREE_SPACE, 0) || 'M' "USED_SPACE(M)",
ROUND ( (1 - NVL (FREE_SPACE, 0) / SPACE) * 100, 2) || '%'
"USED_RATE(%)",
FREE_SPACE || 'M' "FREE_SPACE(M)"
FROM ( SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES) / (1024 *1024), 2) SPACE,
SUM (BLOCKS) BLOCKS
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) D,
( SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES) / (1024 *1024), 2) FREE_SPACE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
UNION ALL
SELECT D.TABLESPACE_NAME,
SPACE || 'M' "SUM_SPACE(M)",
BLOCKS SUM_BLOCKS,
USED_SPACE || 'M' "USED_SPACE(M)",
ROUND (NVL (USED_SPACE, 0) / SPACE * 100, 2) || '%'"USED_RATE(%)",
NVL (FREE_SPACE, 0) || 'M' "FREE_SPACE(M)"
FROM ( SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES) / (1024 *1024), 2) SPACE,
SUM (BLOCKS) BLOCKS
FROM DBA_TEMP_FILES
GROUP BY TABLESPACE_NAME) D,
( SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES_USED) /(1024 * 1024), 2) USED_SPACE,
ROUND (SUM (BYTES_FREE) /(1024 * 1024), 2) FREE_SPACE
FROM V$TEMP_SPACE_HEADER
GROUP BY TABLESPACE_NAME) F
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
ORDER BY 1;
select b.file_name ,b.tablespace_name,b.bytes/1024/1024 M,(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 M,substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) from dba_free_space a,dba_data_files b wherea.file_id=b.file_id group by b.tablespace_name,b.file_name,b.bytes order byb.tablespace_name;
select * from dba_hist_wr_control;
修改策略:
execdbms_workload_repository.modify_snapshot_settings(interval=>30,retention=>9*24*60);
execdbms_workload_repository.modify_snapshot_settings(interval=>0);
EXECdbms_workload_repository.modify_snapshot_settings(interval=>0);
execDBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();
SELECT snap_id, INSTANCE_NUMBER,begin_interval_time, end_interval_time FROM dba_hist_snapshot ORDER BY 1;
execWORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE(low_snap_id => 22, high_snap_id=> 32, dbid => 3310949047);
@$ORACLE_HOME/rdbms/admin/awrrpt.sql
alter system checkpoint;
vm.nr_hugepages = 262144
vm.hugetlb_shm_group = 501
或者
echo 501 >/proc/sys/vm/hugetlb_shm_group
SQL> select table_name,num_rows fromuser_tables;
SQL>select index_name,index_type fromind;
SQL>select tname,tabtype from tab;
SQL> select object_name from user_procedures;
archive log list
SQL> ALTER DISKGROUP DATA ADD DISK'/dev/raw/raw5';
SQL> select sum(bytes)/1024/1024 as MBfrom user_segments;
SET SERVEROUTPUT ON
SET TIMING ON
DECLARE
n NUMBER := 0;
BEGIN
FOR f IN 1..10000000
LOOP
n :=MOD (n,999999) + SQRT (f);
END LOOP;
DBMS_OUTPUT.PUT_LINE ('Res = '||TO_CHAR(n,'999999.99'));
END;
/
输出如下:
Res = 873729.72
PL/SQL procedure successfully completed.
Elapsed: 00:00:07.21