zoukankan      html  css  js  c++  java
  • 有错误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 )

  • 相关阅读:
    python 的rjust函数
    二叉树
    实验四 系统调用
    实验三:跟踪分析Linux内核的启动过程
    ZigZag Conversion1
    Oracle数据文件管理
    Java中hashcode,equals和==
    浅析Java中HashMap的实现
    迷宫(栈,堆,队列)
    TCP/IP的三次握手协议
  • 原文地址:https://www.cnblogs.com/363546828/p/2225579.html
Copyright © 2011-2022 走看看