select * from user_indexes t where t.status!='VALID'
查看失效索引,但是分区索引在这个中间显示的stuts是N/A,很奇怪,
create index DDETAIL_IP3 on T_DDETAIL_N3(DD_IP) nologging parallel 8 local ;
创建分区索引,并行8个,不记录日志
create table T_DDETAIL_N3
(
DD_DATE DATE,
DD_DOMAIN VARCHAR2(512),
DD_IP VARCHAR2(40),
DD_ALL NUMBER,
DD_REMARK VARCHAR2(20)
)
TABLESPACE "DNS" partition by range (DD_DATE)
INTERVAL (NUMTODSINTERVAL(1,'day'))
STORE IN(DNS)
(
partition T_DDETAIL_N3_P1 values less than (to_date('2010-10-20','YYYY-MM-DD'))
tablespace DNS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64
minextents 1
maxextents unlimited
)
);
创建自动分区表,oracle11g带来的新特性不错
analyze table tablename compute statistics
分析表
SELECT SE.SID,
OPNAME,
TRUNC(SOFAR / TOTALWORK * 100, 2) || '%' AS PCT_WORK,
ELAPSED_SECONDS ELAPSED,
ROUND(ELAPSED_SECONDS * (TOTALWORK - SOFAR) / SOFAR) REMAIN_TIME,
SQL_TEXT
FROM V$SESSION_LONGOPS SL, V$SQLAREA SA, V$SESSION SE
WHERE SL.SQL_HASH_VALUE = SA.HASH_VALUE
AND SL.SID = SE.SID
AND SOFAR != TOTALWORK
ORDER BY START_TIME
查看sql执行进度,挺不错的
SELECT a.tablespace_name "表空间名",round(total/1024/1024/1024,4) 表空间大小Gb,round(free/1024/1024/1024,4) 表空间剩余大小Gb,
round((total-free)/1024/1024/1024,4) 表空间使用大小Gb,
ROUND((total-free)/total,4)*100 "使用率 %"
FROM (SELECT tablespace_name,SUM(bytes) free FROM DBA_FREE_SPACE
GROUP BY tablespace_name ) a,
(SELECT tablespace_name,SUM(bytes) total FROM DBA_DATA_FILES
GROUP BY tablespace_name) b
WHERE a.tablespace_name=b.tablespace_name order by 5 desc
查看表空间占用情况的