zoukankan      html  css  js  c++  java
  • [bbk2515] 第51集 Chapter 13Using Oracle Blokcs Efficeintly[00]

    Objectives

    • After completing this lesson,you should be able to do the following:
    • Use automatic segment space management
    • Use manual segment space management
    • Describe the use of Oracle block parameters
    • Recover space from sparsely populated segments
    • Describe and detect chaining and migration of Oracle blocks
    • Perform index reorganization

    Database Storage Hierarchy

    Allocation of Extents

    To avoid the disadvantages of dynamic extent allocation:

    避免动态分配extent的方法有三:

    • Create locally managed tablespaces.
    • Size the segments appropriately.适当的对segment进行大小规划
    • Monitor segments ready to extend.作为DBA来讲,要实时监控segment的使用情况,对于一些需要调整的segment,可以事先运行一些脚本来进行合理的分配.

    Segment分配的时候,是按照extent来进行的,而不是按照block进行的.

    Avoiding Dynamic Allocation

    • To display segments with less than 10% free blocks
      • blocks->已经使用过的blocks
      • empty_blocks->从未使用过的blocks
      • 第一次查询时,empty_blocks有可能为NULL或者为0,原因是尚未进行analyze table t compute statistics.命令.
    SELECT owner,table_name,blocks,empty_blocks
    
    FROM dba_tables
    
    WHERE empty_blocks / (blocks + empty_blocks) < .1;
    • To avoid dynamic allocaiton:
    SQL>ALTER TABLE HR.employees ALLOCATE EXTENT;
    
    Table altered.
    扩充一个extent
    SQL> alter table MARK.t ALLOCATE EXTENT;
    
    Table altered.
    扩充指定大小的EXTENT
    SQL> alter table MARK.t ALLOCATE EXTENT (size 30M);
    
    Table altered.

    Example:

    create tablespace for lab
    CREATE TABLESPACE tbs1 datafile '/u01/oradata/DB202/tbs1_01.dbf' size 200M
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
    SEGMENT SPACE MANAGEMENT auto;
    create user mark;
    SQL> create user mark identified by mark default tablespace tbs1;
    
    User created.
    
    SQL> grant connect,resource to mark;
    
    Grant succeeded.

    conn as mark

    conn as mark
    [oracle@DG3 ~]$ sqlplus mark/mark
    
    SQL*Plus: Release 11.2.0.1.0 Production on Wed May 8 11:04:08 2013
    
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> create table t(id int,name char(10));
    
    Table created.

    conn as sysdba

    search table t info
    SQL> SELECT blocks,empty_blocks FROM dba_tables WHERE owner='MARK' AND table_name='T';
    
        BLOCKS EMPTY_BLOCKS
    ---------- ------------

    conn as mark

    exec dbms_stats.gather_table_stats procedure
    SQL> exec dbms_stats.gather_table_stats('MARK','T');
    
    PL/SQL procedure successfully completed.

    conn as sysdba

    search table t info again
    SQL> SELECT blocks,empty_blocks FROM dba_tables WHERE owner='MARK' AND table_name='T';
    
        BLOCKS EMPTY_BLOCKS
    ---------- ------------
             0            0

    执行dbms_stats.gather_table_stats后发现,empty_blokcs为0;说明使用此Procedure不能统计出真实的empty_blocks信息,必须使用analyze命令.

    conn as mark

    analyze table t compute statistics;
    SQL> analyze table T compute statistics;
    
    Table analyzed.

    问题出现了,在9i的环境中,执行完上述SQL CODE之后,查询相应的字典信息,均有正确数据(dba_tables,dba_segments,dba_extents),但是在oracle 11gr2中,查询上述数据字典信息,则没有数据.这是为什么?

    search table t info again and again
    SQL> SELECT blocks,empty_blocks FROM dba_tables WHERE owner='MARK' AND table_name='T';
    
        BLOCKS EMPTY_BLOCKS
    ---------- ------------
             0            0
    
    SQL> SELECT bytes,blocks,extents from dba_segments where owner='MARK' and segment_name='T';
    
    no rows selected
    
    SQL> SELECT extent_id,block_id,bytes from dba_extents where owner='MARK' and segment_name='T';
    
    no rows selected
  • 相关阅读:
    大佬讲话听后感
    P1226快速幂取余
    对拍
    P1017 进制转换
    P1092 虫食算 NOIP2002
    P1003 铺地毯
    P1443 马的遍历
    P1032 字串变换
    P1379 八数码问题
    2-MAVEN 基本命令
  • 原文地址:https://www.cnblogs.com/arcer/p/3066418.html
Copyright © 2011-2022 走看看