oracle培訓(xùn)記錄
1、
[html]
select * from t where x <=9
minus
selet * from t where x<5
只須排序5個數(shù)據(jù) 很大節(jié)省了PGA
2、
[html]
rowid >= and rowid <= xxx
3、刪除之前先備份
[sql]
declare
Type v_rowid is table of varchar2(100) index by binary_integer; --定義rowid類型
var_rowid v_rowid; --定義rowid變量
v_monthno NUMBER;
cursor v_cur is select /*+parallel(a,2)*/ROWID from bas01.activeuserslist a where monthno = v_monthno AND mailtype = 'NVL';
BEGIN
v_monthno := 201104;
OPEN v_cur ;
loop
FETCH v_cur BULK COLLECT
INTO var_rowid LIMIT 3000 ;
FORALL i IN 1 .. var_rowid.count
INSERT INTO activeuserslist_monitor SELECT * FROM bas01.activeuserslist WHERE ROWID =var_rowid(i);
FORALL i IN 1 .. var_rowid.count
delete from bas01.activeuserslist where ROWID =var_rowid(i);
COMMIT;
EXIT WHEN v_cur%NOTFOUND OR v_cur%NOTFOUND IS NULL;
END LOOP;
CLOSE v_cur;
end;
4、索引范圍掃描的時候他需要判斷下一個結(jié)果不是我們要的結(jié)果才退出掃描
索引全掃描:整個索引的數(shù)據(jù)的時候
索引唯一掃描
索引范圍掃描
索引快速全掃描
5、組合索引,只要帶上第一個列就會走索引,也有跳躍式索引 窮舉第一列,如下:
[sql]
select * from t where b= 5;
select * from t where a=1 and b=5
union all
all select * from t where a=2 and b=5
union all
select * from t where a=3 and b=5;
6、B*tree