查詢DBA_SEGMENTS,bytes=0

lfree發表於2010-05-21
昨天遇到一個奇怪的問題,查詢DBA_SEGMENTS顯示的bytes=0,系統是開發商安裝的,oracle版本是9.2.0.8 for windows的。

查詢dba_segment 的定義如下:
CREATE OR REPLACE FORCE VIEW SYS.dba_segments (owner,
                                               segment_name,
                                               partition_name,
                                               segment_type,
                                               tablespace_name,
                                               header_file,
                                               header_block,
                                               BYTES,
                                               blocks,
                                               extents,
                                               initial_extent,
                                               next_extent,
                                               min_extents,
                                               max_extents,
                                               pct_increase,
                                               FREELISTS,
                                               freelist_groups,
                                               relative_fno,
                                               BUFFER_POOL
                                              )
AS
   SELECT owner, segment_name, partition_name, segment_type, tablespace_name,
          header_file, header_block,
            DBMS_SPACE_ADMIN.segment_number_blocks (tablespace_id,
                                                    relative_fno,
                                                    header_block,
                                                    segment_type_id,
                                                    buffer_pool_id,
                                                    segment_flags,
                                                    segment_objd,
                                                    blocks
                                                   )
          * BLOCKSIZE,
          DBMS_SPACE_ADMIN.segment_number_blocks (tablespace_id,
                                                  relative_fno,
                                                  header_block,
                                                  segment_type_id,
                                                  buffer_pool_id,
                                                  segment_flags,
                                                  segment_objd,
                                                  blocks
                                                 ),
          DBMS_SPACE_ADMIN.segment_number_extents (tablespace_id,
                                                   relative_fno,
                                                   header_block,
                                                   segment_type_id,
                                                   buffer_pool_id,
                                                   segment_flags,
                                                   segment_objd,
                                                   extents
                                                  ),
          initial_extent, next_extent, min_extents, max_extents, pct_increase,
          FREELISTS, freelist_groups, relative_fno,
          DECODE (buffer_pool_id,
                  0, 'DEFAULT',
                  1, 'KEEP',
                  2, 'RECYCLE',
                  NULL
                 )
     FROM sys_dba_segs;

觀察另外的機器,發現這個定義不對,應該是:

CREATE OR REPLACE FORCE VIEW SYS.dba_segments (owner,
                                               segment_name,
                                               partition_name,
                                               segment_type,
                                               tablespace_name,
                                               header_file,
                                               header_block,
                                               BYTES,
                                               blocks,
                                               extents,
                                               initial_extent,
                                               next_extent,
                                               min_extents,
                                               max_extents,
                                               pct_increase,
                                               FREELISTS,
                                               freelist_groups,
                                               relative_fno,
                                               BUFFER_POOL
                                              )
AS
   SELECT owner, segment_name, partition_name, segment_type, tablespace_name,
          header_file, header_block,
            DECODE
               (BITAND (segment_flags, 131072),
                131072, blocks,
                (DECODE
                    (BITAND (segment_flags, 1),
                     1, DBMS_SPACE_ADMIN.segment_number_blocks
                                                             (tablespace_id,
                                                              relative_fno,
                                                              header_block,
                                                              segment_type_id,
                                                              buffer_pool_id,
                                                              segment_flags,
                                                              segment_objd,
                                                              blocks
                                                             ),
                     blocks
                    )
                )
               )
          * BLOCKSIZE,
          DECODE
             (BITAND (segment_flags, 131072),
              131072, blocks,
              (DECODE
                    (BITAND (segment_flags, 1),
                     1, DBMS_SPACE_ADMIN.segment_number_blocks
                                                             (tablespace_id,
                                                              relative_fno,
                                                              header_block,
                                                              segment_type_id,
                                                              buffer_pool_id,
                                                              segment_flags,
                                                              segment_objd,
                                                              blocks
                                                             ),
                     blocks
                    )
              )
             ),
          DECODE
             (BITAND (segment_flags, 131072),
              131072, extents,
              (DECODE
                   (BITAND (segment_flags, 1),
                    1, DBMS_SPACE_ADMIN.segment_number_extents
                                                             (tablespace_id,
                                                              relative_fno,
                                                              header_block,
                                                              segment_type_id,
                                                              buffer_pool_id,
                                                              segment_flags,
                                                              segment_objd,
                                                              extents
                                                             ),
                    extents
                   )
              )
             ),
          initial_extent, next_extent, min_extents, max_extents, pct_increase,
          FREELISTS, freelist_groups, relative_fno,
          DECODE (buffer_pool_id,
                  0, 'DEFAULT',
                  1, 'KEEP',
                  2, 'RECYCLE',
                  NULL
                 )
     FROM sys_dba_segs;

怎麼會出現這樣的情況下,僅僅發現如下連結:

並沒有給出解決問題的答案。

我的感覺對方是複製安裝的。而且版本不是9.2.0.8.

我開始重新執行catalog.sql,cateproc.sql命令,結果執行中出現如下錯誤:
ORA-00604: 遞迴 SQL 層 1 出現錯誤
ORA-04020: 嘗試鎖定物件 SYS.CDC_ALTER_CTABLE_BEFORE 時檢測到死鎖

關閉再開啟還是依舊,查詢到如下連結:
http://www.itpub.net/thread-1026878-1-1.html

按照如下方法解決:
SolutionSet the following in the INIT.ORA then restart the database:

_system_trig_enabled=false
aq_tm_processes=0
job_queue_processes=0

Then rerun CATALOG.SQL.

完成後在檢視dba_segment檢視,一些OK。





來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-663346/,如需轉載,請註明出處,否則將追究法律責任。

相關文章