• 有错误sql命令的事务


    SELECT [stuid]
          ,[stuno]
          ,[name]
          ,[sex]
          ,[age]
          ,[address]
          ,[telphone]
      FROM [UFMeta_001].[dbo].[Student]
    GO


    INSERT INTO student VALUES (101,'zhangsan','zhangsan',0,13,'zhangsan','zhangsan')

    INSERT INTO student VALUES (102,'wangwu','zhangsan',0,13,'zhangsan','zhangsan')

    INSERT INTO student VALUES (103,'lishi','zhangsan',0,13,'zhangsan','zhangsan')

    INSERT INTO student VALUES (104,'maliu','zhangsan',0,13,'zhangsan','zhangsan')

    创建外键引用表

    CREATE TABLE score
    (
             stuid [nvarchar](50) NOT NULL  REFERENCES student(stuid),
             score int
    )

    GO

    set XACT_abort off
    begin transaction ab
    insert into score values('101',100)
    insert into score values('105',100)--不符合外键约束,无法插入。
    insert into score values('102',100)
    insert into score values('103',100)
    insert into score values('104',100)
    commit transaction ab


    select * from score

    执行后:

    stuid  score

    101 100
    102 100
    103 100
    104 100

    有错误操作的事务,事务里面包含的sql命令完整执行的情况。(需要设置XACT_abort )

  • 相关阅读:
    寒假学习日报20
    寒假学习日报19
    Centos firewalld开放端口
    Full GC回收详解
    JVM调优6大步骤
    JVM的方法区和永久带是什么关系?
    sql优化的几种方式
    sentinel-dashboard安装、运行(ubuntu)
    RocketMQ工作原理
    linux:nohup 不生成 nohup.out的方法
  • 原文地址:https://www.cnblogs.com/363546828/p/2225579.html
Copyright © 2020-2023  润新知