码迷,mamicode.com
首页 > 其他好文 > 详细

Data Block -- Uncompressed

时间:2018-03-03 14:03:40      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:into   ram   pos   官方文档翻译   translate   aaa   类型   art   only   

Overview of Data Blocks
  Oracle Database manages the logical storage space in the data files of a database in units called data blocks, also called Oracle blocks or pages. A data block is the minimum unit of database I/O.

Data Blocks and Operating System Blocks
  At the physical level, database data is stored in disk files made up of operating system blocks. An operating system block is the minimum unit of data that the operating system can read or write. In contrast, an Oracle block is a logical storage structure whose size and structure are not known to the operating system.

数据块概览

  Oracle数据库管理数据文件的逻辑存储空间的单元叫数据块,也叫Oracle块或者页。一个数据块是数据库I/O的最小单元。

数据块和操作系统块的关系

  在物理层面,数据库的数据是存储在由操作系统块组成的磁盘文件中的。

  一个操作系统块是操作系统读写的最小数据单元。

  对应的,Oracle块则是逻辑存储结构,操作系统并不知道它的大小和结构。

 

  Figure 12–5 shows that operating system blocks may differ in size from data blocks. The database requests data in multiples of data blocks, not operating system blocks.

 技术分享图片

  如图片所表示的,操作系统块的大小可能和数据块的不一样。一个数据库可能有对应多个操作系统块。数据库请求数据的对象是数据块,不是操作系统块。

  When the database requests a data block, the operating system translates this operation into a requests for data in permanent storage. The logical separation of data blocks from operating system blocks has the following implications:
  ■Applications do not need to determine the physical addresses of data on disk.
  ■Database data can be striped or mirrored on multiple physical disks.

  当数据库请求一个数据块的时候,操作系统将这个操作转换为从长期存储中请求数据。数据块和操作系统块的逻辑分离有以下意义:

  ■应用不需要决定数据在磁盘上的物理地址

  ■数据库数据可以条带化或者镜像化在多个物理磁盘上

 

Database Block Size
  Every database has a database block size. The DB_BLOCK_SIZE initialization parameter sets the data block size for a database when it is created. The size is set for the SYSTEM and SYSAUX tablespaces and is the default for all other tablespaces.

  The database block size cannot be changed except by re-creating the database.
  If DB_BLOCK_SIZE is not set, then the default data block size is operating system-specific. The standard data block size for a database is 4 KB or 8 KB. If the size differs for data blocks and operating system blocks, then the data block size must be a multiple of the operating system block size.

数据库块大小

  每一个数据库都有一个数据块的大小值。当数据库创建的时候该值由初始参数DB_BLOCK_SIZE决定。

  这个大小是SYSTEM和SYSAUX表空间的块大小值,也是其他表空间的默认值(其他表空间创建的时候可以指定块大小)

  数据库块的大小不能被改变除非重建数据库。

  假如参数DB_BLOCK_SIZE没有设置,那么默认的块大小由操作系统指定。标准的数据库块大小是4KB以及8KB。

  假如数据块的大小和操作系统块的大小不一样,那么数据块的大小一定是操作系统块大小的多倍。

 

Tablespace Block Size
  You can create individual tablespaces whose block size differs from the DB_BLOCK_SIZE setting. A nonstandard block size can be useful when moving a transportable tablespace to a different platform.

表空间块大小

  你可以创建一个块大小的值和参数设置的值不一样的表空间。当你迁移一个可迁移的表空间到一个不同的平台,非标准块大小是一个很有用的设置。

 

Data Block Format
  Every data block has a format or internal structure that enables the database to track the data and free space in the block. This format is similar whether the data block contains table, index, or table cluster data.

Figure 12–6 shows the format of an uncompressed data block -- 非压缩数据块格式

Figure 12–6 Data Block Format

技术分享图片

数据块的结构:

每一个数据块都有一个格式或者说内部结构来让数据库能够追踪到块的数据和空闲空间。不管这个块是包含表,索引还是聚簇表的数据,这个结构都是类似的。

Data Block Overhead
  Oracle Database uses the block overhead to manage the block itself. The block overhead is not available to store user data.

block overhead
  Space in a data block that stores metadata required for managing the block. The overhead includes the block header, table directory, and row directory.

数据块天花板

  Oracle数据库使用块天花板来管理块本身。块的天花板不可以用来存储用户数据。

  块的天花板是数据块里面存储用来管理数据块的元数据,它包括块头,表目录,行目录。

As shown in Figure 12–6, the block overhead includes the following parts:

■Block header
  This part contains general information about the block, including disk address and segment type. For blocks that are transaction-managed, the block header contains active and historical transaction information.
  A transaction entry is required for every transaction that updates the block. Oracle Database initially reserves space in the block header for transaction entries.

  In data blocks allocated to segments that support transactional changes, free space can also hold transaction entries when the header space is depleted.

  The space required for transaction entries is operating system dependent. However, transaction entries in most operating systems require approximately 23 bytes.

块头

  这个部分包含关于块的一般信息,比如磁盘地址,段类型。对于数据块的事务管理,数据块头部包含活动的和历史的事务信息。

  每一个事务在更新数据块的时候都要请求一个事务记录。Oracle数据库最初会在数据块头部为事务记录保留空间。

  在分配给支持事务变更的段的数据块上,当头部空间已经耗完的情况下,空间空间也可以用来保留事务记录。

  事务记录请求的空间是依赖于操作系统的。不过,事务记录在大多数操作系统上大约请求23byte 的空间。

 

■Table directory
  For a heap-organized table, this directory contains metadata about tables whose rows are stored in this block. Multiple tables can store rows in the same block.

表目录

  对于一个堆组织结构的表,这个目录包含关于表的元数据,即哪些行存储在这个块中。多个表可以在同一个块中存储行数据。

 Note:堆组织表是指表里的数据没有按特殊顺序存储在磁盘中的表,默认下CREATE TABLE创建的就是堆组织表。

■Row directory
  For a heap-organized table, this directory describes the location of rows in the data portion of the block.
  After space has been allocated in the row directory, the database does not reclaim this space after row deletion.

  Thus, a block that is currently empty but formerly had up to 50 rows continues to have 100 bytes allocated for the row directory. The database reuses this space only when new rows are inserted in the block.

 行目录

  对于一个堆组织表来说,这个目录描述的是指行在块中数据部分中的位置。在空间被分配到行目录后,数据库并不会在该行被删除后回收这一部分空间。

  因此,一个当前是空的数据块,但是之前曾经最多存储过50行数据的,将仍然有100bytes被分配到行目录中。只有当新的行插入到这个数据块的时候,数据库会重用这一部分空间。

 

Some parts of the block overhead are fixed in size, but the total size is variable. On average, the block overhead totals 84 to 107 bytes.

块天花板的一部分是固定大小的,但总的大小是可变的。平均来说,块天花板总共是84到107bytes。

 

Row Format
  The row data part of the block contains the actual data, such as table rows or index key entries.Just as every data block has an internal format, every row has a row format that enables the database to track the data in the row.
  Oracle Database stores rows as variable-length records. A row is contained in one or more row pieces. Each row piece has a row header and column data.

行格式

  数据块的行数据部分包含实际的数据,比如说表的行或者索引键的记录。因为每个数据块都有一个内部格式,每一行有一个行格式来让数据库追踪到行内的数据。

  Oracle数据库每一行可以存储不同长度的记录。一行可以包含在一个或多个行片段中,每一个行片段有一个行头部和列数据。

Figure 12–7 shows the format of a row.

技术分享图片

 Row Header
Oracle Database uses the row header to manage the row piece stored in the block. The row header contains information such as the following:
■Columns in the row piece
■Pieces of the row located in other data blocks
If an entire row can be inserted into a single data block, then Oracle Database stores the row as one row piece. However, if all of the row data cannot be inserted into a single block or an update causes an existing row to outgrow its block, then the database stores the row in multiple row pieces.A data block usually contains only one row piece per row.

 行头部

  Oracle 数据库使用行头部来管理存储在块中的行片段。行头部包含以下信息:

行片段里面的列信息

存储在其他数据块中的行片段

 如果行数据一整行都可以被插入到一个数据块里面,那么数据库就会把这一行数据存储在一个行片段里面。然而,假如没办法把一整行数据都插入到一个数据块,或者因为更新导致行数据超出了数据块,那么数据库会把这行数据存储在不同的行片段中。一个数据块一般只把一行数据存储在一个行片段中。

A row fully contained in one block has at least 3 bytes of row header.

完全存储在一个数据块中的一行记录至少有3bytes的行头部。

Column Data
  After the row header, the column data section stores the actual data in the row. The row piece usually stores columns in the order listed in the CREATE TABLE statement, but this order is not guaranteed. For example, columns of type LONG are created last.
  As shown in Figure 12–7, for each column in a row piece, Oracle Database stores the column length and data separately. The space required depends on the data type. If the data type of a column is variable length, then the space required to hold a value can grow and shrink with updates to the data.
  Each row has a slot in the row directory of the data block header. The slot points to the beginning of the row.

 列数据

在行头部后面,列数据存储列的世纪数据。行片段通常会按创建表的时候的列名顺序来存储列,但这个顺序不是一定的,比如说,长类型的列会最后创建。

在12-7的图中,对于行片段中的每一列,Oracle会把列的长度跟数据分离。需要的空间大小由数据类型决定,如果一个类的数据类型是可变长度的,那么请求的空间会随着数据的更新增长或者缩减。

每一行在数据块头部的行目录都有一个插槽。这个插槽会指向行的开头。

 

Rowid Format

Oracle Database uses a rowid to uniquely identify a row. Internally, the rowid is a structure that holds information that the database needs to access a row. A rowid is not physically stored in the database, but is inferred from the file and block onwhich the data is stored.
An extended rowid includes a data object number. This rowid type uses a base 64 encoding of the physical address for each row. The encoding characters are  A-Z ,  a-z ,
0-9 ,  + , and  / .

Rowid格式

Oracle数据库使rowid来唯一指向对应的一行。rowid是数据库用来找到某一行数据的必要结构。rowid并不是物理存储在数据库中的,而是由数据存储的文件和块自动推断出的。

一个扩展的rowid包括一个数据对象数字。这个rowid类型使用一个64位编码的行物理地址。这个编码字符包含A-Z,a-z,0-9,+,/。

Example 12–1 queries the  ROWID pseudocolumn to show the extended rowid of the row in the  employees table for employee 100.

Example 12–1 ROWID Pseudocolumn
SQL> SELECT ROWID FROM employees WHERE employee_id = 100;
ROWID
------------------
AAAPecAAFAAAABSAAA

Figure 12–8 illustrates the format of an extended rowid.

技术分享图片

 

 An extended rowid is displayed in a four-piece format,  OOOOOOFFFBBBBBBRRR , with the
format divided into the following components:
■ OOOOOO
The data object number identifies the segment (data object  AAAPec in
Example 12–1). A data object number is assigned to every database segment.
Schema objects in the same segment, such as a table cluster, have the same data
object number.

前六位是数据对象数字


■ FFF
The tablespace-relative data file number identifies the data file that contains the
row (file  AAF in Example 12–1).

7-9位数字是数据文件数字


■ BBBBBB
The data block number identifies the block that contains the row (block  AAAABS in
Example 12–1). Block numbers are relative to their data file, not their tablespace.
Thus, two rows with identical block numbers could reside in different data files of
the same tablespace.

10-15位是指数据块的数字,和数据文件相关联

■ RRR
The row number identifies the row in the block (row  AAA in Example 12–1).

 最后三位数字指明在块中的行的数字

After a rowid is assigned to a row piece, the rowid can change in special circumstances.

For example, if row movement is enabled, then the rowid can change because of partition key updates, Flashback Table operations, shrink table operations, and so on. If row movement is disabled, then a rowid can change if the row is exported and imported using Oracle Database utilities.

在rowid被分配到某一个行片段后,在一些特殊环境rowid是可以改变的。

比如说,假如行迁移是启用的,那么rowid可以因为分区键的更新,闪回表操作,收缩表操作以及类似的操作而变化。如果行迁移是禁用的,那么当导入导出的时候,rowid是可以改变的。

 

--根据11g官方文档翻译,若有翻译不当或错误,请不吝指正,谢谢

 

Data Block -- Uncompressed

标签:into   ram   pos   官方文档翻译   translate   aaa   类型   art   only   

原文地址:https://www.cnblogs.com/ryanw/p/8493572.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!