- 浏览: 92017 次
- 性别:
- 来自: 上海
文章分类
最新评论
A simple rollback or commit erases all savepoints. When you roll back to a savepoint, any savepoints marked after that savepoint are erased. The savepoint to which you roll back remains.
You can reuse savepoint names within a transaction. The savepoint moves from its old position to the current point in the transaction.
If you mark a savepoint within a recursive subprogram, new instances of the SAVEPOINT statement are executed at each level in the recursive descent. You can only roll back to the most recently marked savepoint.
An implicit savepoint is marked before executing an INSERT, UPDATE, or DELETE statement. If the statement fails, a rollback to the implicit savepoint is done. Normally, just the failed SQL statement is rolled back, not the whole transaction; if the statement raises an unhandled exception, the host environment (such as SQL*Plus) determines what is rolled back.
You can reuse savepoint names within a transaction. The savepoint moves from its old position to the current point in the transaction.
If you mark a savepoint within a recursive subprogram, new instances of the SAVEPOINT statement are executed at each level in the recursive descent. You can only roll back to the most recently marked savepoint.
An implicit savepoint is marked before executing an INSERT, UPDATE, or DELETE statement. If the statement fails, a rollback to the implicit savepoint is done. Normally, just the failed SQL statement is rolled back, not the whole transaction; if the statement raises an unhandled exception, the host environment (such as SQL*Plus) determines what is rolled back.
CREATE TABLE emp_name AS SELECT employee_id, last_name, salary FROM employees; CREATE UNIQUE INDEX empname_ix ON emp_name (employee_id); DECLARE emp_id employees.employee_id%TYPE; emp_lastname employees.last_name%TYPE; emp_salary employees.salary%TYPE; BEGIN SELECT employee_id, last_name, salary INTO emp_id, emp_lastname, emp_salary FROM employees WHERE employee_id = 120; UPDATE emp_name SET salary = salary * 1.1 WHERE employee_id = emp_id; DELETE FROM emp_name WHERE employee_id = 130; SAVEPOINT do_insert; INSERT INTO emp_name VALUES (emp_id, emp_lastname, emp_salary); EXCEPTION WHEN DUP_VAL_ON_INDEX THEN ROLLBACK TO do_insert; DBMS_OUTPUT.PUT_LINE('Insert has been rolled back'); END; /
declare e_b exception; begin insert into nbz_run_log (LOG_ID, LOG_TIME) values (552071, sysdate); savepoint my_save; insert into nbz_run_log (LOG_ID, LOG_TIME) values (552073, sysdate); raise e_b; commit; exception when e_b then rollback to my_save; commit; when others then rollback; end;
发表评论
-
oracle赋权
2016-12-07 16:29 0create user seki identified by ... -
mangodb
2015-08-20 10:53 0http://www.cnblogs.com/huangxin ... -
MySQL
2015-06-18 13:52 0函数TimeStampDiff()是MySQL本身提供的可以计 ... -
SQL优化规范
2015-04-17 13:44 389优化规范 1.1 限制输出原则 在OLTP系统中,原则上都 ... -
游标使用
2015-04-16 14:59 436简单游标 declare cursor cur_pol ... -
动态SQL
2015-01-26 15:36 284DECLARE v_sql VARCHAR2(10000) ... -
NoSQL存储
2013-11-30 11:33 422NoSQL不仅仅是No SQL,还是Not only SQL, ... -
NVARCHAR2&VARCHAR2
2013-01-21 14:13 5951、NVARCHAR2(10)是可以存进去10个汉字的,如果用 ... -
PL/SQL多行数据处理
2012-12-28 11:48 6231.游标 申明游标 使用时打开 cursor c_cursor ... -
oracle常见错误
2012-11-26 10:39 610ORA-01476: divisor is equal to ... -
ALTER 操作
2012-11-15 13:40 596--新增列 ALTER TABLE Table_name AD ... -
oracle NULL
2012-02-24 21:29 333当变量赋为NULL时,需特别注意 if v_tmp exp ... -
having&group by
2012-01-18 16:24 663GROUP BY 是分组查询, 一般 GROUP BY 是和聚 ... -
CURSOR
2012-01-11 10:16 796--定义 CURSOR c_mycursor IS sele ... -
oracle表&视图
2012-01-09 19:43 683user_tables用于存储用户分配的表视图 dba_ta ... -
oracle数据导入导出
2012-01-05 15:20 754--将数据库db完全导出 exp user/pwd@db fi ... -
UNION 与 UNION ALL
2011-12-27 21:03 703UNION 与 UNION ALL UNION 有一个内部的 ... -
索引 CREATE INDEX
2011-11-21 13:45 635B-树 数据结构 CREATE INDE ... -
trigger 控制
2011-11-21 13:43 804alter trigger TRI_TABLE__BIU_A ... -
oracle 表解锁
2011-09-20 23:05 1006全部解锁 declare v_sid V$LOCKED ...
相关推荐
使用`Connection`对象的`setSavepoint(String savepointName)`方法可以设置SavePoint,`rollback(Savepoint savepoint)`方法则可以回滚到指定的SavePoint。 例如,以下是一个简单的Java代码示例,展示了如何使用...
ROLLBACK TO SAVEPOINT my_savepoint; ``` 管理锁是事务控制的另一个方面,它们用于控制并发访问数据,防止冲突和数据不一致。Oracle提供了多种类型的锁,如共享锁(读锁)和独占锁(写锁),以实现不同级别的并发...
在 Oracle 中,可以使用 Savepoint、Rollback 和 Commit 三个关键字来控制事务。Savepoint 用于设置事务保存点,Rollback 用于回滚到事务保存点,而 Commit 用于提交事务。 Java 中的事务 在 Java 中,可以使用 ...
如果有任何异常,`try/except` 结构会捕获错误,并通过 `savepoint_rollback` 回滚到保存点,从而撤销所有变更。 ```python def create(self, validated_data): with transaction.atomic(): save_id = ...
* Oracle 提供了许多事务处理控制语句,用户可以用这些语句控制这种行为,主要的事务处理控制语句包括:commit、rollback、savepoint、rollback to savepoint、set transaction 以及 set constraints 语句等。...
- SAVEPOINT 和 ROLLBACK TO SAVEPOINT:设置保存点并回滚到特定点。 - LOCK TABLES 和 UNLOCK TABLES:锁定表以防止并发修改。 - SET TRANSACTION:定义事务的隔离级别。 - XA 事务:支持分布式事务处理。 13.5 ...
4. **事务控制**:Commit、Savepoint和Rollback是控制数据库事务的关键命令。Commit用于保存更改,Savepoint设置恢复点,Rollback则回滚到某个保存点或事务开始时的状态。 5. **权限管理**:Grant和Revoke命令用于...
ROLLBACK TO my_savepoint; ``` #### 七、一致性与事务一致性 一致性是事务控制的核心概念之一。Oracle通过一致性机制确保数据只在事务完全完成后才对用户可见。 - **事务一致性级别**: - 语句级一致性:确保...
不能回滚的语句,隐式提交,SAVEPOINT和ROLLBACK TO SAVEPOINT: 涉及事务的控制和回滚策略。 13.4.5-7. LOCK TABLES, UNLOCK TABLES, SET TRANSACTION, XA事务: 锁定表以防止并发冲突,设置事务隔离级别,以及...
2. **ROLLBACK TO SAVEPOINT**:仅撤销自指定保存点以来的更改,保留之前的修改,并继续事务。 在编程中,正确使用COMMIT和ROLLBACK是确保数据完整性和一致性的重要手段。SAVEPOINT则为事务提供了一种灵活的恢复...
- SAVEPOINT 和 ROLLBACK TO SAVEPOINT:设置保存点并在需要时回滚到保存点。 - LOCK TABLES 和 UNLOCK TABLES:锁定表以防止其他用户修改数据。 - SET TRANSACTION:设置事务的隔离级别。 - XA 事务:分布式事务...
- SAVEPOINT 和 ROLLBACK TO SAVEPOINT:设置和回滚到保存点,细化事务管理。 - LOCK TABLES 和 UNLOCK TABLES:锁定表以防止并发冲突。 - SET TRANSACTION:设置事务隔离级别。 - XA 事务:支持分布式事务处理。 ...
在 Oracle 数据库系统中,事务处理是通过 SQL 语句来实现的,包括 COMMIT(提交)、ROLLBACK(回滚)和 SAVEPOINT(保存点)等操作。 `WPCM_COMMON_PKG.pck` 文件可能是一个 PL/SQL 包(Package),在 Oracle 中,...
值得注意的是,在某些数据库系统中还支持`ROLLBACK TO SAVEPOINT`语句,它可以撤销到某个保存点,而不是撤销整个事务,提供更细粒度的控制能力。 #### SQL回滚的限制与注意事项 尽管SQL回滚提供了强大的功能,但在...
6. **事务和并发控制**:理解ACID属性,使用SAVEPOINT和ROLLBACK操作,以及解决并发冲突的策略,如锁和行版本控制。 7. **数据库备份与恢复**:了解SQL Server的备份类型和恢复模式,执行简单的备份和恢复操作。 ...
- 事务控制语言(TCL):管理数据库事务,如COMMIT、SAVEPOINT和ROLLBACK。 - 数据控制语言(DCL):处理权限和安全性,如GRANT和REVOKE。 2. Oracle数据类型: - 字符数据类型:CHAR、VARCHAR2和LONG。 - CHAR...
ROLLBACK TO savepoint_name; ``` - **示例**: ```sql SQL> insert into t1 values(1); 1 row created. SQL> savepoint sp1; SQL> insert into t1 values(2); 1 row created. SQL> rollback to sp1;...
一旦设置了保存点,如果在事务过程中发生错误或需要部分回滚,可以使用`rollback(Savepoint savepoint)`方法来撤销到该保存点之前的所有操作。例如: ```java try { // 执行一些数据库操作 } catch (SQLException ...
如`ROLLBACK`会回滚整个事务,`ROLLBACK TO SAVEPOINT my_savepoint`则回滚到之前设置的保存点。SET TRANSACTION命令用于改变事务的隔离级别,如`SET TRANSACTION ISOLATION LEVEL SERIALIZABLE`将事务隔离级别设置...
事务控制语言(TCL)如COMMIT、SAVEPOINT和ROLLBACK用于管理数据库事务,确保数据的一致性。数据控制语言(DCL)如GRANT和REVOKE用于权限的授予和撤销,维护数据库的安全性。 在SQL的基本函数中,分为单行函数和...