×
☰ See All Chapters

MySQL SET TRANSACTION

Using SET TRANSACTION command you can initialize the transaction with desired characteristics. You can specify a transaction to be read-only or read/write:

SET TRANSACTION READ WRITE;

SET TRANSACTION READ ONLY;

  • Database will not ensure isolation property. There can be one or more transactions running concurrently which may access the same data at the same time. Multiple transactions can run without knowing each other. Each transaction has no lock on the database objects, and the changes made by one transaction may not reflect in other transaction. READ WRITE is used for transactions that are allowed to query and manipulate data in the database. If a transaction is READ WRITE, the database must create locks on database objects to maintain data integrity if multiple transactions are happening concurrently.  

  • READ ONLY is used for transactions that require query-only access. If a transaction is READ ONLY, no locks are established by the database, thereby increasing the speed at which transactions are accomplished. READY ONLY access should be used if you are sure that no other transactions run concurrently otherwise data is inconsistent.   


All Chapters
Author