`
guoyanxi
  • 浏览: 276996 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

BLOCK、EXTENT、SEGMENT、TABLESPACE、Data Dictionary

阅读更多

Block
Block 可以分为 
  Header 
  Table Directory 
  Row Directory 
  Row Data
  Free Space
其中,block header、table directory、row directory 合起来称为 Overhead。

详细解释:


Header (Common and Variable)
  The header contains general block information, such as the block address and the type of segment (for example, data or index).

Table Directory
  This portion of the data block contains information about the table having rows in this block.

Row Directory
  This portion of the data block contains information about the actual rows in the block (including addresses for each row piece in the row data area).this space is not reclaimed when the row is deleted.

Overhead
  The data block header, table directory, and row directory are referred to collectively as overhead. Some block overhead is fixed in size; the total block overhead size is variable. On average, the fixed and variable portions of data block overhead total 84 to 107 bytes.

Row Data
  This portion of the data block contains table or index data. Rows can span blocks.

Free Space
  Free space is allocated for insertion of new rows and for updates to rows that require additional space (for example, when a trailing null is updated to a nonnull value).

Row Chaining(行连接)和 Row Migrating(行迁移)


Row Chaining:
  the row is too large to fit into one data block when it is first inserted. In this case, Oracle stores the data for the row in a chain of data blocks (one or more) reserved for that segment. Row chaining most often occurs with large rows, such as rows that contain a column of datatype LONG or LONG RAW. Row chaining in these cases is unavoidable.

Row Migrating:
  a row that originally fit into one data block is updated so that the overall row length increases, and the block's free space is already completely filled. In this case, Oracle migrates the data for the entire row to a new data block, assuming the entire row can fit in a new block. Oracle preserves the original row piece of a migrated row to point to the new block containing the migrated row. The rowid of a migrated row does not change.


SEGMENT
High Water Mark
The high water mark is the boundary between used and unused space in a segment.

When Extents Are Deallocated?
  当 Extents 分配给某个对象时,一般不会自己回收,除非以下几种情况发生:


1.drop the schema object whose data is stored in the segment (using a DROP TABLE or DROP CLUSTER statement)
2.TRUNCATE...DROP STORAGE statement(用 delete 不会回收)
3.ALTER TABLE table_name DEALLOCATE UNUSED(HWM 之后的空间);
4.Oracle deallocates one or more extents of a rollback segment if it has the OPTIMAL size specified

TRUNCATE 语法:

TRUNCATE TABLE XXX { DROP STORAGE(DEFAULT) | REUSE STORAGE }

TABLESPACE
EXTENT MANAGEMENT LOCAL 的两种 Extents 分配方式:

AUTOALLOCATE (system-managed):you can specify the size of the initial extent and Oracle determines the optimal size of additional extents, with a minimum extent size of 64 KB. This is the default for permanent tablespaces.

UNIFORM SIZE:you can specify an extent size or use the default size, which is 1 MB. Temporary tablespaces that manage their extents locally can only use this type of allocation.

    当使用 Local 管理 Extents 时参数 NEXT, PCTINCREASE, MINEXTENTS, MAXEXTENTS, and DEFAULT STORAGE 不能使用。

SEGMENT SPACE MANAGEMENT 的两种管理方式:

MANUAL 
  Specifying MANUAL tells Oracle that you want to use free lists for managing free space within segments.Free lists are lists of data blocks that have space available for inserting rows. This form of managing space within segments is called manual segment-space management because of the need to specify and tune the PCTUSED, FREELISTS, and FREELISTS GROUPS storage parameters for schema objects created in the tablespace.

AUTO 
  This keyword tells Oracle that you want to use bitmaps to manage the free space within segments. A bitmap, in this case, is a map that describes the status of each data block within a segment with respect to the amount of space in the block available for inserting rows. As more or less space becomes available in a data block, its new state is reflected in the bitmap. Bitmaps allow Oracle to manage free space more automatically, and thus, this form of space management is called automatic segment-space management.It completely eliminates any need to specify and tune the PCTUSED, FREELISTS, and FREELISTS GROUPS storage parameters for schema objects created in the tablespace. If such attributes should be specified, they are ignored.


系统表空间:


  When the SYSTEM tablespace is locally managed, you must define a default temporary tablespace when creating a database. A locally managed SYSTEM tablespace cannot be used for default temporary storage.

UNDO 表空间:


  Through the use of a system parameter (UNDO_RETENTION), you can specify the amount of committed undo information to retain in the database.

The Data Dictionary
参数 O7_DICTIONARY_ACCESSIBILITY 的作用:

  Oracle recommends that you implement data dictionary protection to prevent users having the ANY system privileges from using such privileges on the data dictionary. If you enable dictionary protection (O7_DICTIONARY_ACCESSIBILITY is false), then access to objects in the SYS schema (dictionary objects) is restricted to users with the SYS schema. These users are SYS and those who connect as SYSDBA.

O7_DICTIONARY_ACCESSIBILITY:
说明: 主要用于从 Oracle7 移植到 Oracle8i。如果该值为 TRUE, SYSTEM 权限 (如 SELECT ANY TABLE) 将不限制对 SYS 方案中各对象的访问 (Oracle7 行为)。如果该值为 FALSE, 只有被授予了 SELECT_CATALOG_ROLE, EXECUTE_CATALOG_ROLE 或 DELETE_CATALOG_ROLE 权限的用户才能访问 SYS 方案中的各对象。 
值范围: TRUE | FALSE 
默认值: TRUE

    该参数主要为了兼容 7.0 版本,用来限制其他用户是否可以访问 sys schema 下的对象。以后的版本可以通过 SELECT_CATALOG_ROLE, EXECUTE_CATALOG_ROLE 或 DELETE_CATALOG_ROLE 权限来控制。
    另外,由于 pl/sql 的编译的一些特性,oracle 采取了角色在存储过程、函数、包等在 pl/sql 中不起作用的策略,必须直接授权才生效,所以即使有dba角色在存储过程中也是无效的。(参考:http://www.itpub.net/251232,1.html
DBMS_METADATA
  The DBMS_METADATA package provides interfaces for extracting complete definitions of database objects. The definitions can be expressed either as XML or as SQL DDL.

最简单的使用方法:



SQL> set long 2000
SQL> select dbms_metadata.get_ddl('TABLE','TEST') from dual;


DBMS_METADATA.GET_DDL('TABLE','TEST')
--------------------------------------------------------------------------------


  CREATE TABLE "SYS"."TEST"
   (    "OWNER" VARCHAR2(30),
        "OBJECT_NAME" VARCHAR2(128),
        "SUBOBJECT_NAME" VARCHAR2(30),
        "OBJECT_ID" NUMBER,
        "DATA_OBJECT_ID" NUMBER,
        "OBJECT_TYPE" VARCHAR2(18),
        "CREATED" DATE,
        "LAST_DDL_TIME" DATE,
        "TIMESTAMP" VARCHAR2(19),
        "STATUS" VARCHAR2(7),
        "TEMPORARY" VARCHAR2(1),
        "GENERATED" VARCHAR2(1),
        "SECONDARY" VARCHAR2(1)
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "SYSTEM"

参考:
http://blog.csdn.net/eygle/archive/2004/12/22/225673.aspx
更详细的使用方法:
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_metad2.htm#1024701

分享到:
评论

相关推荐

    CREATE TABLESPACE命令详解

    [DATAFILE datafile_spec1 [, datafile_spec2] [{MINIMUM EXTENT integer [k|m] | BLOCKSIZE integer [k] | logging_clause | FORCE LOGGING | DEFAULT {data_segment_compression} storage_clause | [online | ...

    Oracle 45 道面试题及答案.docx

    table、segment、extent和block之间的关系是:table 创建时,默认创建了一个data segment,每个datasegment含有min extents指定的extents数,每个extent据据表空间的存储参数分配一定数量的blocks。 tablespace和...

    \Oracle 表空间与数据文件

    [EXTENT MANAGEMENT DICTIONARY | LOCAL [AUTOALLOCATE | UNIFORM SIZE size]] [SEGMENT SPACE MANAGEMENT (COMPACT | AUTO)]; ``` 其中,`tablespace_name`是要创建的表空间名称,`datafile_spec`或`temp_file_...

    Oracle体系结构.docx

    Oracle的逻辑结构包括Database、Tablespace、Segment、Extent和Block。Database由多个Tablespace组成,Tablespace又由多个Segment构成,Segment由多个Extent组成,而Extent是一组连续的Blocks。 处理SQL语句的过程...

    oracle面试题(网摘).doc

    2. **Table/Segment/Extent/Block关系**:Table是逻辑概念,Segment是其物理实现,Segment由一个或多个Extent组成,Extent由连续的Block构成,Block是最小I/O单位。 3. **Tablespace和Datafile关系**:Tablespace是...

    手工创建表空间

    [EXTENT MANAGEMENT DICTIONARY|LOCAL [AUTOALLOCATE|UNIFORM SIZE number K | M]] [SEGMENT SPACE MANAGEMENT AUTO|MANUAL]; ``` #### 三、选项解析 **1. TEMPORARY/UNDO选项** - `CREATE TEMPORARY TABLESPACE...

    Oracle 表空间与数据文件

    逻辑结构包括 database、tablespace、segment、extent 和 block。 Oracle 表空间的创建可以使用 CREATE TABLESPACE 语句,包括 BIGFILE、SMALLFILE 和 TEMPORARY 三种类型。创建表空间时需要指定数据文件的路径和...

    Oracle 12c硬核知识点逻辑存储结构深入浅出

    逻辑存储结构主要包括数据块(Data Block)、扩展区(Extent)、段(Segment)以及表空间(Tablespace)。 - **数据块**:这是Oracle数据库中最小的数据存储单位,也是I/O操作的基本单位。 - **扩展区**:一组连续...

    DBA常用SQL语句系列

    #### 二、数据字典视图(Data Dictionary Views) 数据库提供了多种数据字典视图来帮助DBA进行空间管理,这些视图包括但不限于: - **v$datafile**:显示数据文件的信息。 - **v$fixed_table**:列出固定表的名称和...

    表空间--清华大学计算中心ORACLE培训资料.pptx

    - **Data Block**: 数据块是最小的存储单位,它是Oracle数据库内部操作的数据单元。 2. **表空间的属性** - 表空间可以被设置为在线(Online)或脱机(Offline)。系统表空间(SYSTEM)、回滚表空间(UNDOTBS)和...

    Oracle基本概念.ppt

    逻辑结构中,数据库是由表空间(tablespace)组成,表空间又包含段(segment),段由多个区(extent)组成,而区则进一步由Oracle Block(数据块)构成。物理结构涉及数据文件、控制文件和重做日志文件,它们分别...

    数据库建用户

    - **EXTENT MANAGEMENT**:选择表空间的扩展管理方式,DICTIONARY为数据字典管理,LOCAL可以配合AUTOALLOCATE或UNIFORM进行本地化管理。 - **SEGMENT SPACE MANAGMENT AUTO/MANUAL**:设置段空间的管理方式,AUTO...

    oracle学习文档 笔记 全面 深刻 详细 通俗易懂 doc word格式 清晰 连接字符串

    2. 网状结构模型:按照网状数据结构建立的数据库系统称为网状数据库系统,其典型代表是DBTG(Data Base Task Group)。 3. 关系结构模型:关系式数据结构把一些复杂的数据结构归结为简单的二元关系(即二维表格形式)。...

    ora分析脚本

    [-f ] PQ event wait graph using ASH data Arguments are the same as for ash except that the output must be shown with the mxgraph tool - ash_sql <sql_id> Show all ash rows group by sampli_time and ...

Global site tag (gtag.js) - Google Analytics