ZIPch10-12.zip 3.49KB

redredddd需要积分:1(1积分=1元)

资源文件列表:

ch10-12.zip 大约有12个文件
  1. ch10-key/实践10-3-1.sql 79B
  2. ch10-key/实践10-3-2.sql 219B
  3. ch10-key/实践10-3-3.sql 243B
  4. ch10-key/实践10-3-4.sql 336B
  5. ch10-key/实践10-3-5.sql 234B
  6. ch10-key/实践10-3-6.sql 298B
  7. ch11-key/实践11-3-1.sql 61B
  8. ch11-key/实践11-3-2.sql 222B
  9. ch11-key/实践11-3-3.sql 111B
  10. ch11-key/实践11-3-4.sql 64B
  11. ch11-key/实践11-3-5.sql 470B
  12. ch12-key/实践11-4.sql 1.4KB

资源介绍:

ch10-12.zip
use library go --创建帐户表bank-- if exists(select * from sys.objects where name='bank') drop table bank create table bank( customerName char(10), --顾客姓名 currentMoney money --当前余额 ) go /**//*--添加约束,帐户不能少于元--*/ alter table bank add constraint CK_currentMoney check(currentMoney>=1) /**//*--插入测试数据--*/ insert into bank(customerName,currentMoney) select '张三',1000 union select '李四',1 select * from bank go /**//*--使用事务--*/ use library go --恢复原来的数据 --update bank set currentMoney=currentMoney-1000 where customerName='李' set nocount on --不显示受影响的行数 print '查看转帐事务前的余额' select * from bank go /**//*--开始事务--*/ begin transaction declare @errorSum int --定义变量,用于累计事务执行过程中的错误 /**//*--转帐--*/ update bank set currentMoney=currentMoney-800 where customerName='张三' set @errorSum=@errorSum+@@error --累计是否有错误 update bank set currentMoney=currentMoney+800 where customerName='李四' set @errorSum=@errorSum+@@error --累计是否有错误 print '查看转帐事务过程中的余额' select * from bank /**//*--根据是否有错误,确定事务是提交还是回滚--*/ if @errorSum>0 begin print '交易失败,回滚事务.' rollback transaction end else begin print '交易成功,提交事务,写入硬盘,永久保存!' commit transaction end go print '查看转帐后的余额' select * from bank go
100+评论
captcha
    类型标题大小时间
    ZIPspring-boot-2.2.x源码13.65MB6月前
    ZIP1729217903264_12306题目.zip1.91MB6月前
    ZIPlogback的jar包869.01KB6月前
    ZIPIjkPlayer 0.8.0 版本64位的so文件已上传27.83MB6月前
    ZIP梦幻西游道人20241021f2.41MB6月前
    ZIP基于pygame的简易游戏框架.zip455.96KB6月前
    ZIP446441809262673jspm教案管理系统fuc7d.zip11.39MB6月前
    ZIPmac版本下的nvm包452.35KB6月前