Home > Database > Mysql Tutorial > 如何获得当前数据库的SCN值

如何获得当前数据库的SCN值

WBOY
Release: 2016-06-07 14:59:51
Original
2028 people have browsed it

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 主要可以通过两种方式: 1.在Oracle9i及以上版本中 可以使用dbms_flashback.get_system_change_number来获得 SQL select dbms_flashback.get_system_change_number from dual; GET_SYSTEM_CHANGE_NUM

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

主要可以通过两种方式:

1.在Oracle9i及以上版本中

可以使用dbms_flashback.get_system_change_number来获得

SQL> select dbms_flashback.get_system_change_number from dual;
Copy after login
GET_SYSTEM_CHANGE_NUMBER<br>------------------------<br>                 2982184
Copy after login

2.在Oracle9i之前

可以通过查询x$ktuxe获得最接近当前系统scn值

 X$KTUXE-------------[K]ernel [T]ransaction [U]ndo Transa[x]tion [E]ntry (table)

SQL> select max(ktuxescnw*power(2,32)+ktuxescnb) from x$ktuxe;
Copy after login
MAX(KTUXESCNW*POWER(2,32)+KTUXESCNB)<br>------------------------------------<br>                             2980613 
Copy after login

3.通过oradebug获取

以前在l2g32003的站点上看到使用oradebug获取SCN的方法,转引在这里:

[oracle@neirong oracle]$ sqlplus "/ as sysdba"
Copy after login
SQL*Plus: Release 9.2.0.4.0 - Production on Wed Dec 21 21:04:24 2005
Copy after login
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Copy after login
Connected to:<br>Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production<br>With the Partitioning, OLAP and Oracle Data Mining options<br>JServer Release 9.2.0.4.0 - Production
Copy after login
SQL> col a for 999999999999<br>SQL> oradebug setmypid<br>Statement processed.<br>SQL> oradebug DUMPvar SGA kcsgscn_<br>kcslf kcsgscn_ [1200BC68, 1200BC88) = 0000<strong>0003 BA84F392</strong> 00071266 00000000 00000000 00000000 00000000 1200B948<br>SQL> select to_number('3BA84F392','xxxxxxxxxxxx') a from dual;
Copy after login
            A<br>-------------<br>  16014177170
Copy after login
SQL> select dbms_flashback.get_system_change_number a from dual;
Copy after login
            A<br>-------------<br>  16014177255
Copy after login
SQL> 
Copy after login

方法有多种,但是涉及的知识各有巧妙不同,深入研究一下都是很有意思的.

如何获得当前数据库的SCN值

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template