UNDO -- Concept

Oracle UNDO 数据管理
本文详细介绍了Oracle数据库中UNDO数据的作用与管理方法,包括UNDO数据如何支持事务回滚、恢复以及读一致性等关键功能,并阐述了如何创建、管理和维护UNDO表空间。

 Undo data
  
Records of the actions of transactions, primarily before they are committed. The database can use undo data to logically reverse the effect of SQL statements. Undo data is stored in undo segments.

回滚数据

  事务活动的被提交前的记录。数据库可以使用回滚数据来逻辑地撤销SQL语句的影响。UNDO数据存储在UNDO段中。

Undo Segments
  Oracle Database maintains records of the actions of transactions, collectively known as undo data. Oracle Database uses undo to do the following:
■Roll back an active transaction
■Recover a terminated transaction
■Provide read consistency
■Perform some logical flashback operations
  Oracle Database stores undo data inside the database rather than in external logs. Undo data is stored in blocks that are updated just like data blocks, with changes to these blocks generating redo. In this way, Oracle Database can efficiently access undo data without needing to read external logs.
Undo data is stored in an undo tablespace. Oracle Database provides a fully automated mechanism, known as automatic undo management mode, for managing undo segments and space in an undo tablespace.

UNDO段
ORACLE数据库管理事务活动的记录,收集位UNDO数据。数据库使用UNDO来实现以下功能:
■回滚一个活动的事务
■恢复一个终止的事务
■提供读一致性
■进行一些逻辑闪回操作
ORACLE数据库把undo数据存储在数据库内部而不是外部日志。UNDO数据是存储在块中的,它的更新是跟数据块一样的,对UNDO块的更新同样会产生日志。在这种方式下,ORACLE数据库可以高效地使用undo数据而不用去读外部日志。
UNDO数据存储在UNDO表空间中。ORACLE数据库提供一种全自动的管理机制,即UNDO自动管理模式,用来管理在一个UNDO表空间中管理UNDO段以及空间。


Undo Segments and Transactions
  When a transaction starts, the database binds (assigns) the transaction to an undo segment, and therefore to a transaction table, in the current undo tablespace. In rare circumstances, if the database instance does not have a designated undo tablespace, then the transaction binds to the system undo segment.
Multiple active transactions can write concurrently to the same undo segment or to different segments. For example, transactions T1 and T2 can both write to undo segment U1, or T1 can write to U1 while T2 writes to undo segment U2.
  Conceptually, the extents in an undo segment form a ring. Transactions write to one undo extent, and then to the next extent in the ring, and so on in cyclical fashion. Figure 12–20 shows two transactions, T1 and T2, which begin writing in the third extent (E3) of an undo segment and continue writing to the fourth extent (E4).

UNDO段和事务
当一个事务开始,数据库在当前的UNDO表空间中绑定(分配)一个UNDO段及一个事务表给事务。在少数环境中,如果数据库实例没有一个指定的UNDO表空间,那么事务会绑定SYSTEM的UNOD段。

多个活动的事务可以并发地写一样的UNDO段或者不同的段。比如说,事务T1和T2可以一起写UNDO段U1,或者T1可以写U1,同时T2写U2。
理论上来说,一个UNDO段里面的区是一个圆环的形式。事务在一个UNDO区中写数据,然后是圆环的下一个,一个一个这样子循环往复。
如表格12-20表现的两个事务T1和T2,它们同时在UNDO段的E3区开始写,然后接下来则到了E4区开始写。

  At any given time, a transaction writes sequentially to only one extent in an undo segment, known as the current extent for the transaction. Multiple active transactions can write simultaneously to the same current extent or to different current extents. Figure 12–20 shows transactions T1 and T2 writing simultaneously to extent E3. Within an undo extent, a data block contains data for only one transaction.
  As the current undo extent fills, the first transaction needing space checks the availability of the next allocated extent in the ring. If the next extent does not contain data from an active transaction, then this extent becomes the current extent. Now all transactions that need space can write to the new current extent. In Figure 12–21, when E4 is full, T1 and T2 continue writing to E1, overwriting the nonactive undo data in E1.

  在任意一个给定的时间,一个事务只在一个UNDO段中的一个区上顺序写,称之为事务的当前区。多个活动事务可以同时在同样的或者不同的当前区中写数据。如图12-20所显示的,事务T1和T2同时在写E3区。
在一个UNDO区里面,一个数据块里面的数据只是一个事务的。
当目前的UNDO区填满后,第一个需要空间的事务会检查圆圈的下一个区的可用性。假如下个区不包含活动事务的数据,那么这个区就将变为当前区。然后所有需要空间的事务都会往当前空间里写数据。
在图12-21中,当E4满了后,T1跟T2开始往E1里面写,覆盖掉E1里面的非活动的UNDO数据。

  At any given time, a transaction writes sequentially to only one extent in an undo segment, known as the current extent for the transaction. Multiple active transactions can write simultaneously to the same current extent or to different current extents. Figure 12–20 shows transactions T1 and T2 writing simultaneously to extent E3. Within an undo extent, a data block contains data for only one transaction.
  As the current undo extent fills, the first transaction needing space checks the availability of the next allocated extent in the ring. If the next extent does not contain data from an active transaction, then this extent becomes the current extent. Now all transactions that need space can write to the new current extent. In Figure 12–21, when E4 is full, T1 and T2 continue writing to E1, overwriting the nonactive undo data in E1.

在任意一个给定的时间,一个事务只在一个UNDO段中的一个区上顺序写,称之为事务的当前区。多个活动事务可以同时在同样的或者不同的当前区中写数据。如图12-20所显示的,事务T1和T2同时在写E3区。
在一个UNDO区里面,一个数据块里面的数据只是一个事务的。
当目前的UNDO区填满后,第一个需要空间的事务会检查圆圈的下一个区的可用性。假如下个区不包含活动事务的数据,那么这个区就将变为当前区。然后所有需要空间的事务都会往当前空间里写数据。
在图12-21中,当E4满了后,T1跟T2开始往E1里面写,覆盖掉E1里面的非活动的UNDO数据。

  If the next extent does contain data from an active transaction, then the database must allocate a new extent. Figure 12–22 shows a scenario in which T1 and T2 are writing to E4. When E4 fills up, the transactions cannot continue writing to E1 because E1 contains active undo entries. Therefore, the database allocates a new extent (E5) for this undo segment. The transactions continue writing to E5.

如果下一个区包含活动事务的数据,那么数据库必须分配一个新的区。图12-22显示的场景里,T1和T2正在写E4,当E4满了厚,事务没办法继续写E1,因为E1包含了活动UNDO的记录。所以,数据库分配了一个新的区E5给这个UNDO段,然后事务继续在E5里面写。

Transaction Rollback
  When a ROLLBACK statement is issued, the database uses undo records to roll back changes made to the database by the uncommitted transaction. During recovery, the database rolls back any uncommitted changes applied from the online redo log to the data files. Undo records provide read consistency by maintaining the before image of the data for users accessing data at the same time that another user is changing it.

事务回滚

  当一个“ROLLBACK"语句发出的时候,数据库使用undo记录来回滚未提交的事务变更。在恢复期间,数据库通过应用在线重做日志来回滚任何未提交的变更。UNDO保持数据的前镜像来让用户群获取到正在被其他用户修改的数据,通过这种方式实现了读一致性。

 

 

Managing Undo Tablespaces
This section describes the various steps involved in undo tablespace management and contains the following sections:
■ Creating an Undo Tablespace
■ Altering an Undo Tablespace
■ Dropping an Undo Tablespace
■ Switching Undo Tablespaces
■ Establishing User Quotas for Undo Space
■ Undo Space Data Dictionary Views

管理undo表空间
这一章节描述undo表空间管理的多个步骤,包含以下章节:
■ 创建undo表空间
■ 修改undo表空间
■ 删除undo表空间
■ 切换undo表空间
■ 设置用户undo表空间配额
■ undo空间数据字典视图

Creating an Undo Tablespace
Although Database Configuration Assistant (DBCA) automatically creates an undo tablespace for new installations of Oracle Database Release 11g, there may be occasions when you want to manually create an undo tablespace.
There are two methods of creating an undo tablespace. The first method creates the undo tablespace when the CREATE DATABASE statement is issued. This occurs when you are creating a new database, and the instance is started in automatic undo management mode (UNDO_MANAGEMENT = AUTO). The second method is used with an
existing database. It uses the CREATE UNDO TABLESPACE statement.
You cannot create database objects in an undo tablespace. It is reserved for system-managed undo data.
Oracle Database enables you to create a single-file undo tablespace. Single-file, or bigfile

Using CREATE DATABASE to Create an Undo Tablespace
You can create a specific undo tablespace using the UNDO TABLESPACE clause of the CREATE DATABASE statement.
The following statement illustrates using the UNDO TABLESPACE clause in a CREATE DATABASE statement. The undo tablespace is named undotbs_01 and one data file,
/u01/oracle/rbdb1/undo0101.dbf, is allocated for it.
CREATE DATABASE rbdb1
CONTROLFILE REUSE
.
.
.
UNDO TABLESPACE undotbs_01 DATAFILE '/u01/oracle/rbdb1/undo0101.dbf';

If the undo tablespace cannot be created successfully during CREATE DATABASE, the entire CREATE DATABASE operation fails. You must clean up the database files, correct the error and retry the CREATE DATABASE operation.
The CREATE DATABASE statement also lets you create a single-file undo tablespace at database creation. This is discussed in "Supporting Bigfile Tablespaces During Database Creation" on page 2-20.
Using the CREATE UNDO TABLESPACE Statement
The CREATE UNDO TABLESPACE statement is the same as the CREATE TABLESPACE statement, but the UNDO keyword is specified. The database determines most of the
attributes of the undo tablespace, but you can specify the DATAFILE clause.
This example creates the undotbs_02 undo tablespace with the AUTOEXTEND option:

创建undo表空间
虽然在11G的时候使用dbca创建新数据库的时候会自动创建一个undo表空间,某些情况下你仍然可能需要手动创建undo表空间。
有两种方式可以创建undo表空间。
第一种方式是在通过CREATE DATABASE语句创建数据库的时候创建。这发生在你创建新数据库的时候,实例以自动undo管理模式启动(UNDO_MANAGEMENT = AUTO)。
第二种方式是在现有的数据库中通过create undo tablespace来创建。
你不能在undo表空间中创建数据库对象。它是保留用于系统管理undo数据的。
oracle数据库允许你创建单文件undo表空间。单文件,或者bigfile。


























转载于:https://www.cnblogs.com/ryanw/p/8530066.html

多角色体系 支持管理员、商家、消费者三种角色,权限分级管控: 管理员:负责平台整体配置、用户审核、数据监控等全局操作。 商家:管理店铺信息、发布商品、处理订单、回复评价等。 消费者:浏览商品、加入购物车、下单支付、评价商品等。 实现用户注册(手机号 / 邮箱验证)、登录(支持密码 / 验证码 / 第三方登录)、个人信息管理(头像、收货地址、密码修改)。 权限精细化控制 商家仅能管理自家店铺及商品,消费者仅能查看和购买商品,管理员拥有全平台数据访问权限。 二、商品管理功能 商品信息维护 商家可发布商品:填写名称、分类(如服饰、电子产品)、子类别(如手机、笔记本)、规格(尺寸、颜色、型号)、价格、库存、详情描述(图文)、物流信息(运费、发货地)等。 支持商品上下架、库存调整、信息编辑,系统自动记录商品状态变更日志。 商品分类与搜索 按多级分类展示商品(如 “数码产品→手机→智能手机”),支持自定义分类体系。 提供智能搜索功能:按关键词(名称、品牌)搜索,支持模糊匹配和搜索联想;结合用户浏览历史对搜索结果排序(优先展示高相关度商品)。 商品推荐 基于用户浏览、收藏、购买记录,推荐相似商品(如 “浏览过该商品的用户还买了…”)。 首页展示热门商品(销量 TOP10)、新品上架、限时折扣等推荐列表。 三、订单与交易管理 购物车与下单 消费者可将商品加入购物车,支持修改数量、选择规格、移除商品,系统自动计算总价(含运费、折扣)。 下单流程:确认收货地址→选择支付方式(在线支付、货到付款)→提交订单→系统生成唯一订单号。 订单处理流程 订单状态跟踪:待支付→已支付→商家发货→物流运输→消费者收货→订单完成,各状态变更实时通知用户。 商家端功能:查看新订单提醒、确认发货(填写物流单号)、处理退款申请(需审核理由)。 消费者端功能:查看订单详情、追踪物流、申请退款 / 退货、确认收货。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值