• 事物


                               

    事物 :

       一:编程事物

         1:完整性

    ①  显示

    ②  隐式

         2:部分事物,完整,完成

         3:只读事物(影响他人)

         4:独立事物(sqlservet

         5孤独事物(sqlservet

    二:声明式事物:

    布置 xml   71spring   java

      

    ------------------------------------------------1.实体完整性----------------------------------------

    例1

    INSERT INTO Students (name,specialty)

        VALUES('王一','计算机');

    例2

    UPDATE Students SET student_id = NULL WHERE student_id = 10205;

    例7.1_17

    INSERT INTO Students

      VALUES(10205, NULL,'张三', '男', '26-12月-1989','自动化');

    例3

    UPDATE Students

      SET student_id = 10207

        WHERE student_id = 10205;

    ------------------------------------------------参照完整性---------------------------------------

    例1

    DELETE FROM Departments WHERE department_id = 101;

    例2

    UPDATE Departments SET department_id = 105

      WHERE department_id = 102;

    例3

    INSERT INTO Teachers

      VALUES(10805,'李四', '教授', '01-9月-1990',1000,3000,108);

    例4

    UPDATE Teachers SET department_id = 107

      WHERE teacher_id = 10106;

    -----------------------------------------------自定义完整性---------------------------------------

    例1

    INSERT INTO Students (student_id,dob,sex,specialty)

      VALUES(10178,'20-12月-1989','男','计算机');

    例2

    UPDATE Students SET sex='南'

      WHERE student_id = 10205;

    CREATE TABLE Students_computer (

      student_id NUMBER(5)

        CONSTRAINT student_computer_pk PRIMARY KEY,

      monitor_id NUMBER(5),

      name VARCHAR2(10) NOT NULL,

      sex VARCHAR2(6),

      dob DATE,

      specialty VARCHAR2(10)

    );

    例3

    INSERT INTO Students_computer

      (SELECT * FROM Students WHERE specialty = '计算机');

    例4

    UPDATE Teachers SET bonus =

      (SELECT AVG(bonus) FROM Teachers)

        WHERE bonus IS NULL;

    例5

    DELETE FROM Teachers

      WHERE wage >

        (SELECT 1.1*AVG(wage) FROM Teachers);

    ----------------------------数据事物----------------------------------

     

    --1显示事物

    INSERT  INTO departments VALUES(111,"地球物理","X号教学楼");

    COMMIT;

    SELECT * FROM departments;

     

    ---2:全部取消事物

    update departments set address='5号教学楼' where department_id=104;

     select * from departments;

     rollback;

     select *  from departments;

     

    ---3:部分取消

    update departments set address='5号教学楼'

     where department_id=104;

    savepoint spl;

    delete from departments where department_id=104;

    select * from departments;

    rollback to spl;

    select * from departments;

     

    ------------------------------特殊事物------------------

    ----1:只读事物

    set transactton read only;

    select * from departments;

    update departments set address='8号教学楼'

     where department_id=104;

     rollback;

     ------------------------------顺序事物-----------------------

     set transactton isolatton level serlalizable;

     

    .

                                              

  • 相关阅读:
    反垃圾邮件技术已转移到云计算中 狼人:
    被黑客NeoN“附体” QQ为推产品谎报漏洞 狼人:
    360到底如何判断泄密的? 狼人:
    Orkut 也遭到 XSS 攻击,18 万用户受影响 狼人:
    僵尸网络产生的垃圾邮件占全球的40% 狼人:
    Stuxnet病毒全球肆虐 将影响我国众多企业 狼人:
    地狱黑客给你的十大网络安全防范建议 狼人:
    微博疯传电脑提速“秘技” 360安全专家称纯属忽悠 狼人:
    微软称Google的Chrome Frame 让 IE 攻击翻倍 狼人:
    陈天桥:欣赏360保护隐私 用户安全永远第一 狼人:
  • 原文地址:https://www.cnblogs.com/1-9-9-5/p/7574392.html
Copyright © 2020-2023  润新知