MySQL Transaction - Reading during Transaction

Martin Blore

If I start a transaction in MySQL and update a row like so:

UPDATE table SET SomeValue ...... WHERE Id = 1;

Am I ok to immediately do this:

SELECT SomeValue FROM table WHERE Id = 1;

...during the same connection/session whilst the transaction is still not yet committed, assuming now that I'm getting the updated SomeValue, and safe to assume that nothing can update that SomeValue until I've committed the transaction?

Thanks.

Bill Karwin

No other session can update that row until you commit.

You can test this for yourself, by opening two terminal windows, run the mysql shell, and try starting a transaction and updating in one window, but do not commit. Then try updating in the second window. It hangs, until the first window commits, or the innodb lock wait timeout is reached.

SELECTing from the table has no effect on locks one way or the other.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL Transaction - Reading during Transaction

From Dev

Reading data during ORMLite transaction

From Dev

Reading from transaction tables

From Dev

Laravel Transaction Not Reading parameters

From Dev

Place a lock on a record when inserting in mysql during a transaction

From Dev

Arithmetic overflow during SQL transaction

From Dev

autocommit=true during spring transaction

From Dev

In MS SQL Server, how I can unlock the reading lock during a transaction in case of ReadCommitted?

From Dev

Reading query within a database transaction

From Dev

PDO transaction functions vs MySQL transaction statements?

From Dev

MySQL Transaction Timing

From Dev

Mysql transaction : commit and rollback

From Dev

Mysql transaction not working as expected

From Dev

Transaction is not working - PHP and MySql

From Dev

Updates in mysql transaction - isolation

From Dev

MySQL Transaction Timing

From Dev

MySQL multiquery / transaction limitations

From Dev

Transaction in PHP with MySQL?

From Dev

Mysql error "Lock wait timeout exceeded; try restarting transaction" during run LargeHadronMigrator add_column

From Dev

Firebase java: during transaction errors, should I return Transaction.abort() vs Transaction.success(...)?

From Dev

DeferRefresh is not allowed during an AddNew or EditItem transaction

From Dev

Duplicate entry '...' for key 'PRIMARY' during the transaction

From Dev

How to disable a specific validation rule during a transaction?

From Dev

Read and write during a SQLite transaction on Android

From Dev

Waiting for another process during a DB transaction

From Dev

Errors during currency conversion on multiple line transaction

From Dev

How to run query affecting entities during a transaction

From Dev

Do you need a database transaction for reading data?

From Dev

Modifying and reading entity inside ndb transaction

Related Related

  1. 1

    MySQL Transaction - Reading during Transaction

  2. 2

    Reading data during ORMLite transaction

  3. 3

    Reading from transaction tables

  4. 4

    Laravel Transaction Not Reading parameters

  5. 5

    Place a lock on a record when inserting in mysql during a transaction

  6. 6

    Arithmetic overflow during SQL transaction

  7. 7

    autocommit=true during spring transaction

  8. 8

    In MS SQL Server, how I can unlock the reading lock during a transaction in case of ReadCommitted?

  9. 9

    Reading query within a database transaction

  10. 10

    PDO transaction functions vs MySQL transaction statements?

  11. 11

    MySQL Transaction Timing

  12. 12

    Mysql transaction : commit and rollback

  13. 13

    Mysql transaction not working as expected

  14. 14

    Transaction is not working - PHP and MySql

  15. 15

    Updates in mysql transaction - isolation

  16. 16

    MySQL Transaction Timing

  17. 17

    MySQL multiquery / transaction limitations

  18. 18

    Transaction in PHP with MySQL?

  19. 19

    Mysql error "Lock wait timeout exceeded; try restarting transaction" during run LargeHadronMigrator add_column

  20. 20

    Firebase java: during transaction errors, should I return Transaction.abort() vs Transaction.success(...)?

  21. 21

    DeferRefresh is not allowed during an AddNew or EditItem transaction

  22. 22

    Duplicate entry '...' for key 'PRIMARY' during the transaction

  23. 23

    How to disable a specific validation rule during a transaction?

  24. 24

    Read and write during a SQLite transaction on Android

  25. 25

    Waiting for another process during a DB transaction

  26. 26

    Errors during currency conversion on multiple line transaction

  27. 27

    How to run query affecting entities during a transaction

  28. 28

    Do you need a database transaction for reading data?

  29. 29

    Modifying and reading entity inside ndb transaction

HotTag

Archive