zoukankan      html  css  js  c++  java
  • SQL基础整理(事务)

    事务==流程控制 确保流程只能成功或者失败,若出现错误会自动回到原点

    具体的实现代码如下:

     1 begin tran
     2 insert into student values('111','王五','','1999-09-09','95033')
     3 if @@ERROR>0
     4 goto tranrollback--直接到tranrollback
     5 insert into course values('3-102','语文','804')
     6 if @@ERROR>0
     7 goto tranrollback
     8 insert into score values('111','3-102',98)
     9 if @@ERROR>0
    10 begin
    11 tranrollback:---回滚事务
    12 rollback tran
    13 end
    14 else
    15 commit tran--提交事务
    16 
    17 
    18 -------------------格式--------------------
     1 begin  tran
     2 if  @@error>0
     3 goto  tranrollback
     4 ……
     5 if  @@error>0
     6 begin
     7 tranrollback:
     8 rollback  tran
     9 end
    10 else
    11 commit  tran
  • 相关阅读:
    FastAPI(5)- 查询参数 Query Parameters
    FastAPI(4)- 路径参数 Path Parameters
    FastAPI(3)- uvicorn.run()
    Python
    Python
    Python
    Python
    Python
    Python
    Python
  • 原文地址:https://www.cnblogs.com/felix-wang/p/6723949.html
Copyright © 2011-2022 走看看