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$索引直接失效,且不能重建。
所以,基本操作一定要谨慎,不是每个基本都可以这么干