最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

HowtomapSCNwithTimestampbefore10g[ID365536.1]

来源:动视网 责编:小采 时间:2020-11-09 11:56:18
文档

HowtomapSCNwithTimestampbefore10g[ID365536.1]

HowtomapSCNwithTimestampbefore10g[ID365536.1]:How to map SCN with Timestamp before 10g [ID 365536.1] Applies to: Oracle Server - Enterprise Edition - Version: 9.2.0.6.0Information in this document applies to any platform. Goal In this note, we will help Database Administrators
推荐度:
导读HowtomapSCNwithTimestampbefore10g[ID365536.1]:How to map SCN with Timestamp before 10g [ID 365536.1] Applies to: Oracle Server - Enterprise Edition - Version: 9.2.0.6.0Information in this document applies to any platform. Goal In this note, we will help Database Administrators


How to map SCN with Timestamp before 10g [ID 365536.1]


Applies to:

Oracle Server - Enterprise Edition - Version: 9.2.0.6.0
Information in this document applies to any platform.

Goal

In this note, we will help Database Administrators with answers to two common questions:
How can I know the time of last transaction (time of last SCN)?
How can I map SCN with Timestamp prior to 10g?

Solution

SCN <-> TIMESTAMP conversion features are available only from Oracle 10g. In 10g, there are two built-in functions to give the timestamp and SCN mapping details--Timestamp_to_scn() and Scn_to_timestamp().

For example: In 10g, you will issue code like,

SQL> select current_scn from v$database;
CURRENT_SCN
---------------------------
1086382

SQL> Select scn_to_timestamp(1086382) from dual;

SCN_TO_TIMESTAMP(1086382)
---------------------------------------------------------------------------
15-DEC-05 09.39.49.000000000 PM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

However, in earlier releases, while there is a system object - SYS.SMON_SCN_TIME that will provide the SCN to TIME mapping information. There is no conversion facility provided.

SYS.SMON_SCN_TIME will have a maximum of 1440 rows and each record will be for a 5 minute period. Oracle maintains this information for maximum of 5 days after which the records will be recycled.

This means that data is stored 12 times per hour * 24 hours * 5 days=1440 rows.

SCN value is stored internally as :
i. SCN_wrap
ii. SCN_base

Whenever the SCN is incremented, the BASE component is incremented first unil it reaches it maximum. Once the BASE reaches the maximum value allowed, it is initialized to zero again after incrementing the WRAP by 1.

Using this logic, we can calculate the timestamp of the SCN as follows:

(SCN_WRP * 4294967296) + SCN_BAS should give us the SCN in the number format

To get the time/date for an SCN value in 9i, use the following example:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- (a) Get the current SCN base.
SQL>select max(scn_bas) SCN_BASE from smon_scn_time;

1603342197

--(b) Get the complete SCN and the timestamp.

SQL> alter session set NLS_DATE_FORMAT='DD-MON-YY HH:MI:SS';

SQL> select time_dp TIMESTAMP, scn_wrp*4294967296+SCN_bas SCN from smon_scn_time where
scn_bas='1603342197';

TIMESTAMP SCN
------------------ ----------
28-JUL-06 05:31:08 8252235517813

文档

HowtomapSCNwithTimestampbefore10g[ID365536.1]

HowtomapSCNwithTimestampbefore10g[ID365536.1]:How to map SCN with Timestamp before 10g [ID 365536.1] Applies to: Oracle Server - Enterprise Edition - Version: 9.2.0.6.0Information in this document applies to any platform. Goal In this note, we will help Database Administrators
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top