Oracle Schema Objects

Table Storage

Oracle数据库如何保存表数据?

Oracle Database uses a data segment in a tablespace to hold table data.

Oracle 数据库使用表空间中的数据段保存表数据。

As explained in "User Segments", a segment contains extents made up of data blocks.

如"用户段"所述,段包含由数据块组成的扩展盘区。

The data segment for a table (or cluster data segment, when dealing with a table cluster) is located in either the default tablespace of the table owner or in a tablespace named in the CREATE TABLE statement.

表数据段(或涉及表簇时的簇数据段)位于表所有者的默认空间中,或CREATE TABLE 语句中所指定的表空间中。

表空间、段、区、块的关系

      • 逻辑存储结构包括表空间,段,区,数据块。逻辑结构之间的关系是:多个块组成区,多个区组成段,多个段组成表空间,多个表空间组成逻辑数据库。
        • 表空间(多个表空间组成逻辑数据库)
        • 段(多个段组成表空间)
        • 区(多个区组成段)
        • 数据块(多个数据块组成区)
      • 一个区:一个区只能在一个数据文件中。
      • 段中的各个区:一个段中的各个区可以分别在多个数据文件中。
      • 组成区的块:组成区的块是连续的。
      • 逻辑存储结构是有大小的:由于逻辑的数据块对应磁盘空间中某个固定大小尺寸,所以逻辑存储结构也是有大小的。

表空间tablespace

– 表空间—表(索引,分区..)

      • 物理上

– 表空间—段—extent—block –data file

      • 一个表空间有多个数据文件.
      • 将索引放在索引表空间上;
      • 数据放在数据表空间上;
      • 表空间也是一个存储的管理.

名称

分类

说明

EXAMPLE

非系统表空间

示例表空间,存放示例数据库的方案对象信息及其培训资料

SYSAUX

系统表空间

辅助系统表空间,用于减少system表空间的负荷,提高系统的工作效率。是oracle 10g新增加的表空间

SYSTEM

系统表空间

系统表空间,存放关于表空间名称、控制文件、数据文件等管理信息,存放着方案对象(如表,索引,同义词,序列)的定义信息,存放着所有pl/sql 程序(如过程,函数,包,触发器)的源代码,是oracle数据库中最重要的表空间。它属于SYS和SYSTEM方案,仅被SYS和SYSTEM或其他具有足够权限的用户使用。即使是SYS 和SYSTEM用户也不能删除或重命名该空间。他是用户的默认表空间,即当用户在创建一个对象时,如果没有指定特定的表空间,该对象的数据也会被保存在SYSTEM表空间中。

TEMP

系统表空间

临时表空间,存放临时表和临时数据,用于排序。每个数据库都应该有一个(或创建一个)临时表空间,以便在创建用户时将其分配给用户,否则就会将TEMP表空间作为临时表空间。

UNDOTBS1

非系统表空间

重做表空间,存放数据库的有关重做的相关信息和数据

USERS

非系统表空间

用户表空间,存放永久性的用户对象的数据和私有信息,因此也被称为数据表空间。每个数据库都应该有一个(或创建一个)用户表空间,以便在创建用户时将其分配给用户,否则将会使用SYSTEM表空间来保存数据,而这种做法是不好的。一般讲,系统用户使用SYSTEM表空间,而非系统用户使用USERS表空间

段segment

      • 段( segment )
        • 分配了空间的对象就是段.
        • 段是表的物理化的过程(数据怎么物理存储)
        • 段是表存储的一种方式
        • 只要是分配了存储空间的东西都可以叫做段.
        • 段用于存储表空间中某一种特定的,具有独立存储结构的数据块对象的数据。
        • 段是由一个或多个连续的区组成。
        • 当创建表、索引、簇等对象时,oracle就会为这些对象分配存储空间(即段),以便存储它们的数据。
        • 段随着存储数据的增大而逐渐变大。段的增大过程是通过增加区的个数而实现的(每次增加一个区)。每个区的大小是块的整数倍。
        • segment-->extend-->block-->data file
        • ORACLE存储方面的存储关系
        • ORACLE最底层的叫数据文件。
        • 数据存放的最小的单位为块Blocks,通常ORACLE的块大小为8kb。这个可以修改。
        • 一组blocks组成了extent.
        • 段Segment是由多个Extent构成。

段类型

名称

段类型

名称

Index partition

索引分区段

Deferred rollback

延迟回退段

Table partition

表分区段

Undo

撤销段(还原段)

Table

表段(数据段)

Temporary

临时段

Cluster

簇段

Cache

高速缓存段

Index

索引段

Lob

二进制大对象段

Rollback

回退段

Lobindex

二进制大对象索引段

      • 段( segment )例子:
        • 产生4个段
        • Table lob_table
          • 本身表分配了一个段.
        • Index on my|_column
          • 只要是指定某个字段为主键,ORACLE就会自动创建一个索引,ORACLE又给索引分配了一个段.
        • CLOB:
        • Index on CLOB
          • 在CLOB字段上建立的索引也会分配一个段.

区extent

    • 区(extent)
      • 区是由物理上连续存放的块所组成的。
      • 区是oracle存储分配的最小单位。
      • 一个或多个块组成区,一个或多个区组成段。
      • 一个区只能属于一个数据文件。
      • 一个段中的各个区可以分别在多个数据文件中。
      • 当数据库中创建带有实际存储结构的方案对象时(如表、索引),oracle将为方案对象分配若干个区,以便组成一个对应的段,来为该方案对象提供初始的存储空间。
      • 当段中已分配的区都写满,oracle就要在该方案对象所在的表空间中为该段分配下一个新的空白区,以便容纳更多的数据。

块block

    • 块(block)
      • 块是最小的数据管理单位,即oracle的所有存储的i/o操作都是以块为单位的。操作系统执行i/o的最小单位是操作系统块。
      • 块的大小是操作系统块的大小的整数倍。
      • 块的大小是一个表空间的属性。
      • SYSTEM系统表空间和SYSAUX辅助系统表空间具有相同的标准的块大小,这个大小是在创建数据库时(会同时创建者两个表空间)由DB_BLOCK_SIZE初始化参数制定的,但创建数据库之后这个参数值不能改变。

Table Organization表组织

表如何组织数据?

——堆

堆组织表?

——无序的行的集合

添加行时,数据的位置?

——放置在数据段中第一个可用空间空间.

By default, a table is organized as a heap, which means that the database places rows where they fit best rather than in a user-specified order.

默认情况下,表按 堆的形式来组织数据,这意味着数据库将行存放在最适合他们的位置,而不是按用户指定的顺序来存放。

Thus, a heap-organized table is an unordered collection of rows. 因此,堆组织表是一个无序的行的集合。

As users add rows, the database places the rows in the first available free space in the data segment. Rows are not guaranteed to be retrieved in the order in which they were inserted.

当用户往其中添加行时,数据库将行置于在数据段中第一个可用的空闲空间。不能保证行按照插入它们的顺序进行检索。

Column order?

——列顺序对行都是相同的

例外?

The column order is the same for all rows in a table.

列的顺序对于表中的所有行都是相同的。

The database usually stores columns in the order in which they were listed in the CREATE TABLE statement, but this order is not guaranteed. For example, if a table has a column of type LONG, then Oracle Database always stores this column last in the row. Also, if you add a new column to a table, then the new column becomes the last column stored.

通常,数据库按它们被列在CREATE TABLE 语句中的列顺序来存储列,但这个顺序是不保证的。

例如,如果表中有 LONG 类型的列,那么数据库总是将其存储到行中的最后一列。此外,如果向表中添加一个新列,则新列将被存储为最后一列

Virtual column

虚拟列

A table can contain a virtual column, which unlike normal columns does not consume space on disk.

与常规列不同,表可以包含 虚拟 列,它不占用磁盘上的空间

The database derives the values in a virtual column on demand by computing a set of user-specified expressions or functions. You can index virtual columns, collect statistics on them, and create integrity constraints. Thus, virtual columns are much like nonvirtual columns.

数据库通过计算一组用户指定的表达式或函数,在虚拟列中按需派生一个值。您可以对虚拟列创建索引、 收集统计数据、并创建完整性约束。因此,虚拟列非常像非虚拟列。

Row Storage行存储

Row是如何存储的?

——行存储在数据块block中.

行片?Row pieces?

——用于存储少于256个列的行.

The database stores rows in data blocks. Each row of a table containing data for less than 256 columns is contained in one or more row pieces.

数据库将行存储在数据块中。在表中,少于 256 个列的行,被存储在一个多个 行片中。

If possible, Oracle Database stores each row as one row piece.

数据库尽可能将每一行作为一个行片来存储。

However, if all of the row data cannot be inserted into a single data block, or if an update to an existing row causes the row to outgrow its data block, then the database stores the row using multiple row pieces (see "Data Block Format").

但是,如果所有的行数据不能插入到一个单一数据块中,或者对现有的行的更新导致行溢出,则数据库使用多个行片来存储此行(参见"数据块格式")。

Rows in a table cluster contain the same information as rows in nonclustered tables. Additionally, rows in a table cluster contain information that references the cluster key to which they belong.

表簇中的行除了包含非聚集表中的行相同的信息,还包含对其所属簇键的用信息

Rowids of Row Pieces

行片的行id

——行的一个10字节的物理地址.

——行id用来构建索引

A rowid is effectively a 10-byte physical address of a row.

rowid 实际上是行的一个 10 字节的物理地址。

As explained in "Rowid Data Types", every row in a heap-organized table has a rowid unique to this table that corresponds to the physical address of a row piece. For table clusters, rows in different tables that are in the same data block can have the same rowid.

如"Rowid 数据类型"中所述,堆组织表中的每一行都有一个在该表中唯一的 rowid,与一个行片的物理地址相对应。对于表簇,处于同一个数据块的不同表中的行可以有相同的rowid。

Oracle Database uses rowids internally for the construction of indexes.

Oracle 数据库在内部使用 rowids来构建索引。

For example, each key in a B-tree index is associated with a rowid that points to the address of the associated row for fast access (see "B-Tree Indexes"). Physical rowids provide the fastest possible access to a table row, enabling the database to retrieve a row in as little as a single I/O.

例如,在 B 树索引中的每个键与一个指向关联行地址的 rowid 相关联,以便快速访问(请参阅"B 树索引")。物理 rowids 提供对表行尽可能最快的访问,使数据库几乎只需单次I/O就可以检索到行。

Storage of Null Values

空值的存储

A null is the absence of a value in a column. Nulls indicate missing, unknown, or inapplicable data.

空值是指在某个列中值的缺失。空值表示缺少、 未知、或不适用的数据。

Nulls are stored in the database if they fall between columns with data values.

在数据库中,如果在空值的前后都有数据值,则空值会被存储。

In these cases, they require 1 byte to store the length of the column (zero). Trailing nulls in a row require no storage because a new row header signals that the remaining columns in the previous row are null. For example, if the last three columns of a table are null, then no data is stored for these columns.

在这些情况下,他们需要 1 个字节来存储列的长度(零)。尾随的空值在行中不需要存储,因为新的行头标志着前一行中的剩余列都为空。例如,如果表的最后三列为空,则不为这些列存储数据。

Oracle Schema Objects——Tables——TableStorage的更多相关文章

  1. Oracle Schema Objects——Tables——Oracle Data Types

    Oracle Schema Objects Oracle Data Types 数据类型 Data Type Description NUMBER(P,S) Number value having a ...

  2. Oracle Schema Objects——Tables——TableType

    Oracle Schema Objects Object Tables object type An Oracle object type is a user-defined type with a ...

  3. Oracle Schema Objects——Tables——Overview of Tables

    Oracle Schema Objects Overview of Tables A table is the basic unit of data organization in an Oracle ...

  4. Oracle Schema Objects——Tables——Table Compression

    Oracle Schema Objects Table Compression 表压缩 The database can use table compression to reduce the amo ...

  5. Oracle Schema Objects(Schema Object Storage And Type)

    One characteristic of an RDBMS is the independence of physical data storage from logical data struct ...

  6. Oracle Schema Objects——伪列ROWID Pseudocolumn(ROWNUM、ROWID)

    Oracle Schema Objects Oracle Schema Objects——Tables——Oracle Data Types Oracle伪列 在Oracle数据库之中为了实现完整的关 ...

  7. Oracle Schema Objects——PARTITION

    Oracle Schema Objects 表分区 表- - 分区( partition )TABLE PARTITION 一段时间给出一个分区,这样方便数据的管理. 可以按照范围range分区,列表 ...

  8. Oracle Schema Objects——Index

    索引主要的作用是查询优化. Oracle Schema Objects 查看执行计划的权限:查看执行计划plustrace:set autotrace trace exp stat(SP2-0618. ...

  9. Oracle Schema Objects——Synonyms

    Oracle Schema Objects 同义词 同义词 = 表的别名. 现在假如说有一张数据表的名称是“USER1.student”,而现在又为这张数据表起了一个“USER1”的名字,以后就可以直 ...

随机推荐

  1. atitit.面向过程的编程语言异常处理 c语言 asp vbs 的try catch 实现

    atitit.面向过程的编程语言异常处理 c语言 asp vbs 的try catch 实现 1. 返回值法.and全局ERROR 变量法 1 2. 抛出异常Err.Raise 1 3. 实现try  ...

  2. Atitit.mysql oracle with as模式临时表模式 CTE 语句的使用,减少子查询的结构性 mssql sql server..

    Atitit.mysql  oracle with as模式临时表模式 CTE 语句的使用,减少子查询的结构性 mssql sql server.. 1. with ... as (...) 在mys ...

  3. vim -d file01 file02 diff file01 file02 对比两文件的不同

    [root@86 vhosts]# vim -d defaul.conf.bak zabbix.xinxianm.com.conf server { | server { listen 80; | l ...

  4. stl遍历map

    MapInfo* CGameConfig::getMapInfoById( int nId ) { for (map<int, MapInfo>::iterator it = m_mapM ...

  5. Java Main如何被执行?

    java应用程序的启动在在/hotspot/src/share/tools/launcher/java.c的main()函数中,而在虚拟机初始化过程中,将创建并启动Java的Main线程.最后将调用J ...

  6. 每日英语:The First Day On A Job Is Tough Work

    Why is the first day on the job often the worst? New employees tend to be greeted with stacks of ben ...

  7. love2d--glsl02变量和语句

    Shader分为顶点着色器和片段着色器,GPU先处理顶点再处理片段,大概可以这么理解, 顶点着色器处理模型里的点,输出处理后的数据,这些数据经过GPU其它模块处理后传入 片段着色器,经片段着色器综合后 ...

  8. Groovy学习()Groovy是啥?

    Groovy是啥? groovy是英文中的一个单词,有marvelous.wonderful和excellen的意思. groovy是轻量级的,动态的,面向对象的,并且运行在JVM上的. groovy ...

  9. linux进程同步机制_转

    转自:Linux进程同步机制 具体应用可参考:线程同步       IPC之信号量 为了能够有效的控制多个进程之间的沟通过程,保证沟通过程的有序和和谐,OS必须提供一 定的同步机制保证进程之间不会自说 ...

  10. Linux解决删除文件后空间没有释放问题_端口占用问题

    使用命令 (1) losf | grep deleted 查询所有已经删除但是还未释放空间的进程,找到容量最大的线程,kill -9 pid 然后等待容量释放 (2) netstat -ano | g ...