1.shrink
因爲SYSTEM表空間是手動管理,不是ASSM,所以不能shrink
SQL> alter table job$ enable row movement;
SQL> alter table job$ shrink space cascade;
alter table job$ shrink space cascade
*
ERROR at line 1:
ORA-10635: Invalid segment or tablespace type
SQL> alter table job$ shrink space;
alter table job$ shrink space
*
ERROR at line 1:
ORA-10635: Invalid segment or tablespace type
打開行移動成功,執行shrink失敗
2.truncate
SQL> select * from job$;
SQL> truncate table job$;
SQL> select * from dba_jobs;
--現無job,提交一個job
declare jobnum number;
begin
dbms_job.submit(jobnum,'insert into test1 select * from dba_objects;',sysdate,'sysdate+1/1440');
commit;
end;
--提交成功
SQL> select * from dba_jobs;
JOB LOG_USER
---------- --------------------------------------------------------------------------------------------------------------------------------
PRIV_USER
--查詢可以起作用,說明trunc job$,job還是可以正常運行
--trunc有效
3.move
SQL> alter table job$ move;
SQL> declare jobnum number;
2 begin
3 dbms_job.submit(jobnum,'insert into test1 select * from dba_objects;',sysdate,'sysdate+1/1440');
4 commit;
5 end;
6 /
declare jobnum number;
*
ERROR at line 1:
ORA-01502: index 'SYS.I_JOB_JOB' or partition of such index is in unusable state
ORA-06512: at "SYS.DBMS_IJOB", line 382
ORA-06512: at "SYS.DBMS_JOB", line 208
ORA-06512: at line 3
--報錯了
--查看job$上的索引
SQL> select table_name,index_name from dba_indexes where table_name='JOB$';
TABLE_NAME INDEX_NAME
---------- --------------------
JOB$ I_JOB_JOB
JOB$ I_JOB_NEXT
SQL> alter index I_JOB_JOB rebuild online;
SQL> alter index I_JOB_NEXT rebuild online;
--索引重建成功
--插入job
SQL> declare jobnum number;
2 begin
3 dbms_job.submit(jobnum,'insert into test1 select * from dba_objects;',sysdate,'sysdate+1/1440');
4 commit;
5 end;
6
7
8
9 /
SQL>
SQL> select job from dba_jobs;
JOB
----------
1
21
move有些
但是以上只是正對基本job$
注意:
如果是user$,那麼不能打開行移動,不能trunc表,move user$索引直接失效,且不能重建。
所以,基本操作一定要謹慎,不是每個基本都可以這麼幹