分享
 
 
 

Oracle10g v$database视图SCN增强

王朝oracle·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

在Oracle10g中,Oracle对v$database视图做出增强,增加了很多字段,其中一个重要字段是:CURRENT_SCN,代表数据库当前的SCN:

SQL> select * from v$version;

BANNER

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

PL/SQL Release 10.2.0.1.0 - ProdUCtion

CORE 10.2.0.1.0 Production

TNS for Linux: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

SQL> desc v$database

Name Null? Type

----------------------------------------- -------- ----------------------------

DBID NUMBER

NAME VARCHAR2(9)

...................

CURRENT_SCN NUMBER

FLASHBACK_ON VARCHAR2(18)

SUPPLEMENTAL_LOG_DATA_FK VARCHAR2(3)

SUPPLEMENTAL_LOG_DATA_ALL VARCHAR2(3)

DB_UNIQUE_NAME VARCHAR2(30)

STANDBY_BECAME_PRIMARY_SCN NUMBER

FS_FAILOVER_STATUS VARCHAR2(21)

FS_FAILOVER_CURRENT_TARGET VARCHAR2(30)

FS_FAILOVER_THRESHOLD NUMBER

FS_FAILOVER_OBSERVER_PRESENT VARCHAR2(7)

FS_FAILOVER_OBSERVER_HOST VARCHAR2(512)

这个字段来自底层基础表x$kccdi ,其中的字段为:DICUR_SCN , DI代表Database Information ,cur_scn 代表 current SCN:

SQL> desc x$kccdi

Name Null? Type

----------------------------------------- -------- -----------------

ADDR RAW(4)

INDX NUMBER

...............

DIPLID NUMBER

DIPLN VARCHAR2(101)

DICUR_SCN VARCHAR2(16)

DIDBUN VARCHAR2(30)

DIFSTS NUMBER

DIFOPR NUMBER

DIFTHS NUMBER

DIFTGT VARCHAR2(30)

DIFOBS VARCHAR2(512)

这个SCN值和9i中引入的dbms_flashback.get_system_change_number获得的值相同:

SQL> select

2 (select dicur_scn from x$kccdi ) a,

3 (select dbms_flashback.get_system_change_number a from dual) b

4 from dual;

A B

---------------- ------------------

8905603606859 8905603606859

v$database在Oracle10g中构建的语句如下,引用供参考:

SELECT di.inst_id, di.didbi, di.didbn,

TO_DATE (di.dicts, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),

TO_NUMBER (di.dirls),

TO_DATE (di.dirlc, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),

TO_NUMBER (di.diprs),

TO_DATE (di.diprc, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),

DECODE (di.dimla, 0, 'NOARCHIVELOG', 1, 'ARCHIVELOG', 'MANUAL'),

TO_NUMBER (di.discn), TO_NUMBER (di.difas),

DECODE (BITAND (di.diflg, 256),

256, 'CREATED',

DECODE (BITAND (di.diflg, 1024),

1024, 'STANDBY',

DECODE (BITAND (di.diflg, 32768),

32768, 'CLONE',

DECODE (BITAND (di.diflg, 4096),

4096, 'BACKUP',

'CURRENT'

)

)

)

),

TO_DATE (di.dicct, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),

di.dicsq, TO_NUMBER (di.dickp_scn),

TO_DATE (di.dickp_tim, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),

DECODE (BITAND (di.diflg, 4),

4, 'REQUIRED',

DECODE (di.diirs, 0, 'NOT ALLOWED', 'ALLOWED')

),

TO_DATE (di.divts, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),

DECODE (di.didor,

0, 'MOUNTED',

DECODE (di.didor, 1, 'READ WRITE', 'READ ONLY')

),

DECODE (BITAND (di.diflg, 65536),

65536, 'MAXIMUM PROTECTION',

DECODE (BITAND (di.diflg, 128),

128, 'MAXIMUM AVAILABILITY',

DECODE (BITAND (di.diflg, 134217728),

134217728, 'RESYNCHRONIZATION',

DECODE (BITAND (di.diflg, 8),

8, 'UNPROTECTED',

'MAXIMUM PERFORMANCE'

)

)

)

),

DECODE (di.diprt,

1, 'MAXIMUM PROTECTION',

2, 'MAXIMUM AVAILABILITY',

3, 'RESYNCHRONIZATION',

4, 'MAXIMUM PERFORMANCE',

5, 'UNPROTECTED',

'UNKNOWN'

),

DECODE (di.dirae,

0, 'DISABLED',

1, 'SEND',

2, 'RECEIVE',

3, 'ENABLED',

'UNKNOWN'

),

TO_NUMBER (di.diacid), TO_NUMBER (di.diacid),

DECODE (BITAND (di.diflg, 33554432),

33554432, 'LOGICAL STANDBY',

DECODE (BITAND (di.diflg, 1024),

1024, 'PHYSICAL STANDBY',

'PRIMARY'

)

),

TO_NUMBER (di.diars),

DECODE (BITAND (difl2, 1), 1, 'ENABLED', 'DISABLED'),

DECODE (di.disos,

0, 'IMPOSSIBLE',

1, 'NOT ALLOWED',

2, 'SWITCHOVER LATENT',

3, 'SWITCHOVER PENDING',

4, 'TO PRIMARY',

5, 'TO STANDBY',

6, 'RECOVERY NEEDED',

7, 'SESSIONS ACTIVE',

8, 'PREPARING SWITCHOVER',

9, 'PREPARING DICTIONARY',

10, 'TO LOGICAL STANDBY',

'UNKNOWN'

),

DECODE (di.didgd, 0, 'DISABLED', 'ENABLED'),

DECODE (BITAND (di.diflg, 1048576),

1048576, 'ALL',

DECODE (BITAND (di.diflg, 2097152),

2097152, 'STANDBY',

'NONE'

)

),

DECODE (BITAND (diflg, 1073741824),

1073741824, 'YES',

DECODE (BITAND (diflg, 131072 + 262144 + 524288),

0, DECODE (BITAND (difl2, 2), 0, 'NO', 'IMPLICIT'),

'IMPLICIT'

)

),

DECODE (BITAND (di.diflg, 131072), 131072, 'YES', 'NO'),

DECODE (BITAND (di.diflg, 262144), 262144, 'YES', 'NO'),

DECODE (BITAND (di.diflg, 268435456), 268435456, 'YES', 'NO'),

di.diplid, di.dipln, di2.di2rdi, di2.di2inc, TO_NUMBER (di.dicur_scn),

DECODE (BITAND (di2.di2flag, 1),

1, 'YES',

DECODE (di2.di2rsp_oldest, 0, 'NO', 'RESTORE POINT ONLY')

),

DECODE (BITAND (diflg, 524288), 524288, 'YES', 'NO'),

DECODE (BITAND (difl2, 2), 2, 'YES', 'NO'), di.didbun,

TO_NUMBER (di2.di2actiscn),

DECODE (di.difsts,

0, 'DISABLED',

1, 'BYSTANDER',

2, 'SYNCHRONIZED',

3, 'UNSYNCHRONIZED',

4, 'SUSPENDED',

5, 'STALLED',

6, 'LOADING DICTIONARY',

7, 'PRIMARY UNOBSERVED',

8, 'REINSTATE REQUIRED',

9, 'REINSTATEIN PROGRESS',

10, 'REINSTATE FAILED',

''

),

di.diftgt, di.difths,

DECODE (di.difopr, 1, 'YES', 2, 'NO', 3, 'UNKNOWN', ''), di.difobs

FROM x$kccdi di, x$kccdi2 di2

此前获取SCN可以通过如下方法:

http://www.eygle.com/faq/How.To.Get.Current.SCN.of.Database.htm

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有