2018.09.13
星期四
雨
1.事务
定义:
事务是由若干条T-SQL指令组成的作为单个逻辑工作单元执行的一系列操作,
这些操作作为一个整体一起向系统提交,要么全 部执行完成,要么全部撤销。
是一个不可分割的工作逻辑单元。
特性:
事务必须具备原子性,一致性,隔离性,永久性。
模式:
显示事务,隐式事务,自动提交事务。
事例:
begin tran abc
declare @x int
set @x=0
update bank set currentmoney=currentmoney-100 where customername='张三'
set @x=@x+@@ERROR
update bank set currentmoney=currentmoney+100 where customername='李四'
set @x=@x+@@ERROR
if(@x=0)
begin