ApexSQL Log中的Redo Script跟原始SQL不一致问题
最近遇到一个误更新数据的问题,使用ApexSQL Log做挖掘事务日志的时候,发现ApexSQL Log生成的Redo Script跟原始SQL是有区别的。它们并不是完全一致的。只是逻辑上等价而已。如下所示,我们做一个测试,如下所示,创建一个表后,并模拟忘记添加条件,出现误删除数据的情况
SELECT * INTO KERRY_TEST FROM SYS.OBJECTS;
DELETE FROM KERRY_TEST
然后我们用ApexSQL Log挖掘事务日志,你会看到有很多对应的Delete记录,而且对应的Redo Script跟原始SQL是不一样的。如下所示,
下面是其中两个Redo Script(为了方便查看,对脚本进行了格式化)
--DELETE (0003F73C:000065FC:000D) done at 2019-06-13 10:35:56.876 by xxx\xxxx in transaction 0000:0ADF73EA (Committed)
BEGIN TRANSACTION;
DELETE FROM [dbo].[KERRY_TEST]
WHERE /*** WARNING: WHERE CLAUSE FOR THIS STATEMENT WAS GENERATED FOR A TABLE WITH NO PRIMARY KEY AND NO CLUSTERED INDEX ***/
[name] = N'sysfgfrag' COLLATE Chinese_PRC_CI_AS
AND [object_id] = 19
AND [principal_id] IS NULL
AND [schema_id] = 4
AND [parent_object_id] = 0
AND [type] = N'S ' COLLATE Latin1_General_CI_AS_KS_WS
AND [type_desc] = N'SYSTEM_TABLE' COLLATE Latin1_General_CI_AS_KS_WS
AND [create_date] = '20160101 10:46:55.060'
AND [modify_date] = '20160101 10:46:55.100'
AND [is_ms_shipped] = 1
AND [is_published] = 0
AND [is_schema_published] = 0;
IF @@ROWCOUNT <= 1
COMMIT TRANSACTION;
ELSE
BEGIN
ROLLBACK TRANSACTION;
PRINT 'ERROR: STATEMENT AFFECTED MORE THAN ONE ROW. ALL THE CHANGES WERE ROLLED BACK.';
END;
--DELETE (0003F73C:000065FC:000A) done at 2019-06-13 10:35:56.876 by xxx\xxx in transaction 0000:0ADF73EA (Committed)
BEGIN TRANSACTION;
DELETE FROM [dbo].[KERRY_TEST]
WHERE /*** WARNING: WHERE CLAUSE FOR THIS STATEMENT WAS GENERATED FOR A TABLE WITH NO PRIMARY KEY AND NO CLUSTERED INDEX ***/
[name] = N'sysseobjvalues' COLLATE Chinese_PRC_CI_AS
AND [object_id] = 9
AND [principal_id] IS NULL
AND [schema_id] = 4
AND [parent_object_id] = 0
AND [type] = N'S ' COLLATE Latin1_General_CI_AS_KS_WS
AND [type_desc] = N'SYSTEM_TABLE' COLLATE Latin1_General_CI_AS_KS_WS
AND [create_date] = '20160101 10:47:02.050'
AND [modify_date] = '20160101 10:47:02.057'
AND [is_ms_shipped] = 1
AND [is_published] = 0
AND [is_schema_published] = 0;
IF @@ROWCOUNT <= 1
COMMIT TRANSACTION;
ELSE
BEGIN
ROLLBACK TRANSACTION;
PRINT 'ERROR: STATEMENT AFFECTED MORE THAN ONE ROW. ALL THE CHANGES WERE ROLLED BACK.';
END;
如果有聚集索引,你会看到没有WHERE条件的UPDATE、DELETE操作都会生成很多个对应的Redo Script,对应的WHERE条件则是聚集索引字段。如下测试所示:
SELECT *
INTO KERRY_TEST2
FROM sys.objects;
CREATE CLUSTERED INDEX PK_KERRY_TEST2 ON KERRY_TEST2(OBJECT_ID);
UPDATE KERRY_TEST2
SET NAME = 'KERRY';
DELETE FROM KERRY_TEST2;
下面是对应的UPDATE、DELETE操作的redo script
--UPDATE (0003F73C:0000700A:001F) done at 2019-06-13 11:27:26.036 by xxx\xxx in transaction 0000:0ADF7404 (Committed)
BEGIN TRANSACTION;
UPDATE [dbo].[KERRY_TEST2]
SET [name] = N'KERRY' COLLATE Chinese_PRC_CI_AS
WHERE [object_id] = 3;
IF @@ROWCOUNT <= 1
COMMIT TRANSACTION;
ELSE
BEGIN
ROLLBACK TRANSACTION;
PRINT 'ERROR: STATEMENT AFFECTED MORE THAN ONE ROW. ALL THE CHANGES WERE ROLLED BACK.';
END;
-- DELETE (0003F73C:00007482:00D9) done at 2019-06-13 11:27:35.406 by xxx\xxx in transaction 0000:0ADF7405 (Committed)
BEGIN TRANSACTION;
DELETE FROM [dbo].[KERRY_TEST2]
WHERE [object_id] = 836302139;
IF @@ROWCOUNT <= 1
COMMIT TRANSACTION;
ELSE
BEGIN
ROLLBACK TRANSACTION;
PRINT 'ERROR: STATEMENT AFFECTED MORE THAN ONE ROW. ALL THE CHANGES WERE ROLLED BACK.';
END;
这里只是简单记录一下这个事情,千万不要以为Redo Script跟原始SQL是完全一致的。如果遇到这种问题,如何判断呢?可以查看Transaction ID,以及对应的Begin Time , End Time,如下所示,你会发现它们是一致的
ApexSQL Log中的Redo Script跟原始SQL不一致问题的更多相关文章
- 说说MySQL中的Redo log Undo log都在干啥
在数据库系统中,既有存放数据的文件,也有存放日志的文件.日志在内存中也是有缓存Log buffer,也有磁盘文件log file,本文主要描述存放日志的文件. MySQL中的日志文件, ...
- 【转】说说MySQL中的Redo log Undo log都在干啥
阅读目录(Content) 1 undo 1.1 undo是啥 1.2 undo参数 1.3 undo空间管理 2 redo 2.1 redo是啥 2.2 redo 参数 2.3 redo 空间管理 ...
- MySQL中的redo log和undo log
MySQL中的redo log和undo log MySQL日志系统中最重要的日志为重做日志redo log和归档日志bin log,后者为MySQL Server层的日志,前者为InnoDB存储引擎 ...
- ApexSql Log 数据库操作的后悔药
ApexSQL Log破解版是一款功能强大的SQL数据恢复工具,支持SQL2005/2008/2012.很多时候我们存放在服务器中的SQL数据库会因黑客破坏或误操作造成数据库文件丢失的你问题,当数据库 ...
- ApexSQL Log 从意外UPDATE和DELETE操作中恢复SQL Server数据
下载地址:https://www.apexsql.com/download.aspx 如何从意外UPDATE和DELETE操作中恢复SQL Server数据 ApexSQL Log 从意外UPDATE ...
- MySQL中的 redo 日志文件
MySQL中的 redo 日志文件 MySQL中有三种日志文件,redo log.bin log.undo log.redo log 是 存储引擎层(innodb)生成的日志,主要为了保证数据的可靠性 ...
- gradle中的build script详解
目录 简介 project和task 一个例子 task详细讲解 task脚本 task依赖 动态task 默认task build script的外部依赖 gradle中的build script详 ...
- 从log中分析Android wif连接状态的方法
1.这里是从log中通过搜索关键字wpa_supplicant: wlan0: State过滤之后的log: Line 1: 11-25 20:10:14.968120 1104 1104 D w ...
- ApexSql Log 2014.04.1133破解版&补丁
已上传最新的2016版本,请移步: http://www.cnblogs.com/gsyifan/p/ApexSql_Log_2016_Crack.html 状态不好,鬼使补差的跑到服务器上updat ...
随机推荐
- JIRA 破解文件研究(Win 7环境)
最近再次回来研究 Win 7 下的 JIRA,按网上的很多方法去尝试,竟然无法正常安装! 经过几次的弯路尝试,终究还是成功了. 嗯,有必要总结一下: 发觉网上的很多破解方法都太老!不管是什么原因,在6 ...
- [提高班] 2017 Summer Training Day1补题
题目地址:https://vjudge.net/contest/175939#overview A.数据范围是10^9,所以需要一个巧思路.对于一个数n,如何去判定比它的所有数是否是二进制形式.比n小 ...
- SendMail发送回执及读取收件箱
一.SendMail发送有回执提示 1.邮件发送配置 Properties props = new Properties(); String smtp = "smtp.qq.com" ...
- David Malan teaching CS75 lecture 9, Scalability
https://youtu.be/-W9F__D3oY4 Storage PATA, SATA, SAS (15,000 rpm), SSD, RAID0 : striping, double thr ...
- GridSplitter用法
1.GridSplitter的ShowsPreview设置为True时拖动报null错误 解决方法在Grid外面包装一个装饰器:AdornerDecorator,至于为什么这么做,暂时还不知道 2.当 ...
- day1 java基础回顾- Properties类与配置文件
Properties配置文件说明 Properties类对应.properties文件.文件内容是键值对,键值对之间使用"="或空格隔开.开头是"#"的表示注释 ...
- 日期组件wdatepicker
导入WdataPicker文件包到项目的js文件夹下: 在用户管理中的添加.编辑jsp页面对生日表单项引入日期组件: <script type="text/javascript&quo ...
- c程序十六进制字符串转换为整数与反转
字符串转整数使用sscanf ; char *buf = "1d5ce"; sscanf (buf, "%x", &value); printf (&q ...
- Consuming JSON Strings in SQL Server
https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/ Consuming JS ...
- 数据库路由中间件MyCat - 源代码篇(9)
此文已由作者张镐薪授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 3. 连接模块 3.5 后端连接 3.5.1 后端连接获取与负载均衡 上一节我们讲了后端连接的基本建立和响应 ...