zoukankan      html  css  js  c++  java
  • 并发管理

    读写冲突通过读一致性解决:

    sys准备工作:

    SQL> create user user01 identified by password;

    SQL> grant dba to user01;

    以下都用user01:

    SQL> conn user01/password

    Connected.

    SQL> create table t1(x int);

    SQL> insert into t1 values (1);

    SQL> commit;

    session1:

    SQL> update t1 set x=11 where x=1;

    SQL> select * from t1;

    session 2:

    SQL> select * from t1;

    session 1:

    SQL> commit;

    session 2:

    SQL> select * from t1;

    测试serializable:

    session1:

    SQL> alter session set isolation_level=serializable;改为可串行化隔离级别

    重复上面的步骤

     

    写与写的冲突通过锁机制解决:

    session 1:

    SQL> update t1 set x=11 where x=1;

    浏览器中查看锁信息

    session 2:

    SQL> update t1 set x=111 where x=1; 被阻塞

    浏览器中查看锁信息

    session 1:

    SQL> rollback;

    浏览器中查看锁信息

     

    死锁:

    session1:

    SQL> select * from t1;

     

             X

    ----------

             1

             2

    SQL> update t1 set x=11 where x=1;

    session2:

    SQL> update t1 set x=22 where x=2;

    session1:

    SQL> update t1 set x=222 where x=2; 阻塞

    session2:

    SQL> update t1 set x=111 where x=1; 死锁

    ERROR at line 1:

    ORA-00060: deadlock detected while waiting for resource

    $ vi /u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log

     

    锁和外键

     

    推荐外键做索引,避免全表扫描被锁定,提高并发

     

     

    查询加锁 select … for update

  • 相关阅读:
    postman:模拟发送一个需要 cookie 认证的请求
    TCP/IP体系结构-测试人员必须理解的
    软件测试基本方法_之验收测试
    软件测试基本方法_之集成测试和系统测试
    聊天类APP功能测试点
    软件测试中的测试数据准备
    兼容性测试
    测试面试题集合
    Python3连接数据库,读取数据
    Python3读取Excel数据
  • 原文地址:https://www.cnblogs.com/shan2017/p/7367423.html
Copyright © 2011-2022 走看看