eygle.com   eygle.com
eygle.com  
 

« February 5, 2009 | Blog首页 | February 7, 2009 »



February 6, 2009

数据字典视图之:DBA_LOGSTDBY_LOG结构

作者:eygle

出处:http://blog.eygle.com

DBA_LOGSTDBY_LOG是逻辑Standby数据库中比较重要的一个字典视图,该视图用来记录当前的归档日志应用情况,通过该视图可以查看应用日志的SEQUENCE#,APPLIED状况等。

该视图的构建语法如下(来自Oracle 11gR1数据库):

SELECT thread#, resetlogs_change#, reset_timestamp resetlogs_id, sequence#,
       first_change#, next_change#, first_time, next_time, file_name,
       TIMESTAMP, dict_begin, dict_end,
       (CASE
           WHEN l.next_change# < p.read_scn
              THEN 'YES'
           WHEN ((BITAND (l.CONTENTS, 16) = 16) AND (BITAND (l.status, 4) = 0))
              THEN 'FETCHING'
           WHEN ((BITAND (l.CONTENTS, 16) = 16) AND (BITAND (l.status, 4) = 4))
              THEN 'CORRUPT'
           WHEN l.first_change# < p.applied_scn
              THEN 'CURRENT'
           ELSE 'NO'
        END
       ) applied
  FROM SYSTEM.logmnr_log$ l, dba_logstdby_progress p
 WHERE session# = (SELECT VALUE
                     FROM SYSTEM.logstdby$parameters
                    WHERE NAME = 'LMNR_SID')
   AND (flags IS NULL OR BITAND (l.flags, 16) = 0);

引用Oracle文档说明如下:

DBA_LOGSTDBY_LOG displays information about the logs registered for a logical standby database. This view is for logical standby databases only.

Column Datatype NULL Description
THREAD# NUMBER NOT NULL Thread ID of the archive log. The THREAD number is 1 for a single instance. For Real Application Clusters, this column will contain different numbers.
RESETLOGS_CHANGE# NUMBER NOT NULL Start SCN of the branch
RESETLOGS_ID NUMBER NOT NULL Resetlogs identifier (a numerical form of the timestamp of the branch)
SEQUENCE# NUMBER NOT NULL Sequence number of the archive log file
FIRST_CHANGE# NUMBER NOT NULL System change number (SCN) of the current archive log
NEXT_CHANGE# NUMBER   SCN of the next archive log
FIRST_TIME DATE   Date of the current archive log
NEXT_TIME DATE   Date of the next archive log
FILE_NAME VARCHAR2(513)   Name of the archive log
TIMESTAMP DATE   Time when the archive log was registered
DICT_BEGIN VARCHAR2(3)   Indicates whether the beginning of the dictionary build is in this archive log (YES) or not (NO)
DICT_END VARCHAR2(3)   Indicates whether the end of the dictionary build is in this archive log (YES) or not (NO)
APPLIED VARCHAR2(8)   Indicates primarily whether a given foreign archived log has been applied fully by SQL Apply:
  • YES - SQL Apply has fully applied the foreign archived log and no longer needs it

  • CURRENT - SQL Apply is currently applying changes contained in the foreign archived log

  • NO - SQL Apply has not started applying any changes contained in the foreign archived log

  • FETCHING - SQL Apply encountered a corruption while reading redo records from this foreign archived log, and is currently using the automatic gap resolution to refetch a new copy of the log from the primary database

  • CORRUPT - SQL Apply encountered a corruption while reading redo records from this foreign archived log, and refetching a new copy of the archived log did not resolve the problem. SQL Apply will not refetch a new copy of this archived log automatically, and will require user intervention to manually register a new copy of the foreign archived log.


Note:

The SCN values in this view correlate to the SCN values shown in the DBA_LOGSTDBY_PROGRESS view.

Posted by eygle at 4:09 PM | Comments (0)


使用Oracle Database 11g创建Interval分区表

作者:eygle

出处:http://blog.eygle.com

使用Oracle Database 11g可以创建新类型的Interval分区表,Interval类型分区表,可以根据加载数据,自动创建指定间隔的分区。
比如创建按月分区的分区表:
Create table intervalpart
(c1 number, c2 varchar2(10) , c3 date)
partition by range (c3)
interval(numtoyminterval(1,'MONTH'))
(
partition part1 values less than (to_date('09/15/2007','MM/DD/YYYY')),
partition part2 values less than (to_date('10/15/2007','MM/DD/YYYY')),
partition part3 values less than (to_date('11/15/2007','MM/DD/YYYY'))
)
/

注意如果你的INTERVAL指定错误,则数据库会报出如下错误:
ORA-14752: Interval expression is not a constant of the correct type

下面创建一个以天为间隔的分区表:

SQL> create table sales
  2  (
  3  sales_id    number,
  4  sales_dt    date
  5  )
  6  partition by range (sales_dt)
  7  INTERVAL (NUMTODSINTERVAL(1,'day'))
  8  (
  9  partition p090101 values less than (to_date('2009-01-01','yyyy-mm-dd'))
10  );

Table created.

SQL> select table_name,partition_name from user_tab_partitions;

TABLE_NAME                    PARTITION_NAME
------------------------------ ------------------------------
SALES                          P090101
SYS_FBA_HIST_16585            HIGH_PART

插入测试数据:
SQL> begin     
  2  for i in 1 .. 35 loop
  3  insert into sales values(i,trunc(sysdate,'YYYY')+i);
  4  end loop;
  5  commit;
  6  end;
  7  /

PL/SQL procedure successfully completed.

观察自动创建的分区:
SQL> select table_name,partition_name from user_tab_partitions;

TABLE_NAME                    PARTITION_NAME
------------------------------ ------------------------------
SALES                          SYS_P47
SALES                          SYS_P48
SALES                          SYS_P49
SALES                          SYS_P50
SALES                          SYS_P51
SALES                          SYS_P52
SALES                          SYS_P53
SALES                          SYS_P54
SALES                          SYS_P55
SALES                          P090101
SALES                          SYS_P21

TABLE_NAME                    PARTITION_NAME
------------------------------ ------------------------------
SALES                          SYS_P22
SALES                          SYS_P23
SALES                          SYS_P24
SALES                          SYS_P25
SALES                          SYS_P26
SALES                          SYS_P27
SALES                          SYS_P28
SALES                          SYS_P29
SALES                          SYS_P30
SALES                          SYS_P31
SALES                          SYS_P32

TABLE_NAME                    PARTITION_NAME
------------------------------ ------------------------------
SALES                          SYS_P33
SALES                          SYS_P34
SALES                          SYS_P35
SALES                          SYS_P36
SALES                          SYS_P37
SALES                          SYS_P38
SALES                          SYS_P39
SALES                          SYS_P40
SALES                          SYS_P41
SALES                          SYS_P42
SALES                          SYS_P43

TABLE_NAME                    PARTITION_NAME
------------------------------ ------------------------------
SALES                          SYS_P44
SALES                          SYS_P45
SALES                          SYS_P46
SYS_FBA_HIST_16585            HIGH_PART

37 rows selected.

SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

Session altered.

SQL> select * from sales partition (sys_p44) ;

  SALES_ID SALES_DT
---------- -------------------
        24 2009-01-25 00:00:00

SQL> select * from sales partition (sys_p33);

  SALES_ID SALES_DT
---------- -------------------
        13 2009-01-14 00:00:00

SQL> select * from sales partition (sys_p46);

  SALES_ID SALES_DT
---------- -------------------
        26 2009-01-27 00:00:00

这一特性极大简化了分区表的维护工作。

Posted by eygle at 11:06 AM | Comments (0)


北京住房公积金提取 - 需要知道的几个电话

作者:eygle

出处:http://blog.eygle.com

前几天,跑了几个地方,终于将自己仅存的一点住房公积金提取了出来。

跑了些弯路,记录几天对自己有用的信息,供同道中人参考。
今天提醒自己:花费了时间精力的事情,就必要记录下来与人分享,节约时间,美化生活!

首先,北京建行北京海淀支行北大南街分理处,地址是 北京市海淀区海淀路48号,其实看地址晕人,那地方就在四环边上,海龙对面那里,很容易找。
但是去之前最好打个电话问清楚,网上找到的电话都不太靠谱,朋友告诉了我一个:62624685,管用,一打就通,问清楚材料再去。

不过我去了,人家告诉我,你从公司离职,公积金已经转移到共管户里面了,那地方在 东大桥,蓝岛大厦附近,中认大厦 ,这个地方我熟悉,也好找。
当然还是提前电话问清楚,中央国家机关住房资金管理中心电话:65993015,65993025。

问清楚,带好材料,过去很快就办好了,人很少!
供参考,备忘!

-The End-

Posted by eygle at 9:51 AM | Comments (13)



CopyRight © 2004-2008 eygle.com, All rights reserved.