-----------------------------------------
2.1 查看高版本的自动调整
-----------------------------------------
select count(*) from dba_objects where owner = 'SYS' and
object_name ='DBMS_SCN' and object_type='PACKAGE BODY';
1
set serverout on
declare
v_autorollover_date date;
v_target_compat number;
v_RSL number;
v_hr_in_scn number;
v_hr_in_sec number;
v_t4 number;
v_max_cmpat number;
v_isenabled boolean;
v_current_compat number;
begin
dbms_scn.GETCURRENTSCNPARAMS(v_RSL,v_hr_in_scn,v_hr_in_sec,v_current_compat,v_max_cmpat);
dbms_scn.GETSCNAUTOROLLOVERPARAMS(
v_autorollover_date,v_target_compat,v_isenabled);
dbms_output.put_line('Current SCN
compatibility:'||v_current_compat);
dbms_output.put_line('Current SCN
RATE:'||round((v_hr_in_scn/v_hr_in_sec)/1024)||'k');
if (v_isenabled) then
dbms_output.put_line('AUTO SCN compatibility rollover is
ENABLED!!!');
dbms_output.put_line('AUTO rollover
time:'||to_char(v_autorollover_date,'YYYY/MM/DD'));
dbms_output.put_line('AUTO rollover target
value:'||v_target_compat );
else
dbms_output.put_line('AUTO SCN compatibility rollover is
DISABLED!!!');
end if;
end;
Current SCN compatibility:1
Current SCN RATE:16k
AUTO SCN compatibility rollover is ENABLED!!!
AUTO rollover time:2019/06/23
AUTO rollover target value:3
PL/SQL procedure successfully completed.
-----------------------------------------
2.2 查看最大scn
-----------------------------------------
col scn for 999,999,999,999,999,999
select (
(
(
(
(
(
to_char(sysdate,'YYYY')-1988
)*12+
to_char(sysdate,'mm')-1
)*31+to_char(sysdate,'dd')-1
)*24+to_char(sysdate,'hh24')
)*60+to_char(sysdate,'mi')
)*60+to_char(sysdate,'ss')
) * to_number('ffff','XXXXXXXX')/4 scn from dual;
SCN
------------------------
16,348,925,389,118
1 row selected.
select current_scn from v$database -- 21632993888
-----------------------------------------
2.3 禁用高版本的自动调整
-----------------------------------------
如果你的环境绝大部分都是低版本,只有个别的高版本,可以考虑将高版本的SCN自动调整禁用掉:
begin
DBMS_SCN.DISABLEAUTOROLLOVER;
end;
/
如果是在2019年6月以后安装的新的高版本,默认就是SCN COMPATIBILITY 为
3,这就需要在mount状态调低兼容性:
ALTER DATABASE SET SCN COMPATIBILITY 1;