连接失败后如何访问表 [英] How to access a table after connection failure

查看:52
本文介绍了连接失败后如何访问表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表1包含10亿卢比的记录



Table1 contains 10 crore records

Begin Tran 
Update Table1 set Column1=Column1-Column2





执行上述查询时,服务器连接已断开连接。当重新连接服务器时,我给了''commit tran'',我得到了以下错误。



消息3902,等级16,状态1,行1

COMMIT TRANSACTION请求没有相应的BEGIN TRANSACTION。



现在我无法访问table1数据。如何访问我的表。

即使我执行选择查询,我也无法检索数据。



While executing the above query, server connection has disconnected. when reconnected the server,I gave ''commit tran'' for which i got the following error.

Msg 3902, Level 16, State 1, Line 1
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.

Now I am unable access the table1 data. How to access my table.
Even if I execute select query, I am unable to retreive the data.

推荐答案

如果服务器失败在您提交交易之前,所有更改都将丢失。

这是使用开始和提交一起背后的整个想法。



想象一下这样 - 你有一个插入和一个更新查询,它们都不在begin语句中。

一个查询插入一条记录,获取一个密钥,然后在另一个表中更新此密钥。



现在,如果服务器连接是在第一次插入发生后丢失,第一个和第二个表之间将存在数据不一致。



因此,使用开始/结束事务并且如果是提交失败,你没有不一致的数据。
If the server fails before you commit your transaction, all changes will be lost.
This is the whole idea behind using begin and commit together.

Imagine it this way - you have one insert and one update query neither of which are inside a begin statement.
One query inserts a record, gets a key and then this key is updated in another table.

Now, if the server connection is lost after the first insert happens, there will be data inconsistency between the first and the second table.

Thus, it is useful to use begin / end transaction and if a commit fails in between, you don''t have inconsistent data.


这篇关于连接失败后如何访问表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆