dongqie5529 2015-11-25 21:15
浏览 104

在MySQL中获取未提交的数据

In SQL Server we can write below SQL Queries to get Un-Committed data in database . This means the data that is still under transaction and Transaction is not complete.

SQL Server Query

Select * from TableName With(NoLock);

Is there any equivalence in MySQL database to get data even if table is locked ? I am trying this in PHP CodeIgnitor

  • 写回答

5条回答 默认 最新

  • douheng8629 2015-11-25 21:40
    关注

    Only the InnoDB storage engine fully supports transactions. It also implements Oracle/PostgreSQL-style MVCC that prevents implicit row locks from blocking reads. To get Read-Uncommitted in InnoDB, issue a SET TRANSACTION LEVEL READ UNCOMMITTED before issuing the query.

    The syntax for doing so in PHP would look something like this:

    $dbh->exec('SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED');
    $dbh->beginTransaction();
    

    This sets the isolation level until the next COMMIT or ROLLBACK. To make the level change persist for the duration of the session, use

    SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
    

    instead.

    As for overriding a non-sharing read lock on a table or row, I'm not sure that's possible, nor can I think of a situation where it would be desirable. Non-sharing locks are usually non-sharing for a reason.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作