What is cursor in mysql
Published: 2020-09-27 03:16:54

<p>A database cursor is a manipulate shape that permits traversal over the archives in a database.Cursor in MySQL is nearly the identical as a cursor in different databases. MySQL cursor is a form of loop facility given to traverse in the end result of SQL one by means of one. We can function on each end result by means of the usage of the cursor in MySQL. Cursors are supported in saved procedures, functions, and triggers only. MySQL cursor is reachable from model 5 or greater. If you are looking MySQL Interview Questons then you can visit here. This will help you to crack your interviews.</p>
<h2>MySQL cursor is read-only, non-scroll able and sensitive.</h2>
<h3>Non-scrollable</h3>
<p>you can only fetch rows in the order decided with the aid of the SELECT statement. You can&#39;t fetch rows in the reversed order. In addition, you can&#39;t omit rows or soar to a precise row in the end result set.</p>
<h3>Read-only</h3>
<p>you can&#39;t replace statistics in the underlying desk thru the cursor.</p>
<h3>A sensitive</h3>
<p>there are two sorts of cursors: a touchy cursor and an insensitive cursor. Insensitive cursor factors to the genuine data, whereas an insensitive cursor makes use of transient replica of the data. An insensitive cursor performs quicker than an insensitive cursor due to the fact it does no longer have to make a brief reproduction of data. However, any exchange that made to the facts from different connections will have an effect on the records that is being used through an a touchy cursor, therefore, it is safer if you do now not replace the records that is being used by using an sensitive cursor. MySQL cursor is a sensitive.</p>
<h2>Advantages of the use of Cursor</h2>
<ul>
    <li>Cursors can furnish the fest few rows earlier than the total result set is assembled. Without the use of cursors, the complete end result set need to be delivered earlier than any rows are displayed with the aid of the application. So the usage of cursor, higher response time is achieved.</li>
    <li>Using Cursor we can function row by way of row processing so we can function row smart validation or operations on every row.</li>
    <li>Cursors can be quicker than a whilst loop however at the fee of greater overhead.</li>
    <li>If we make updates to our except the usage of cursors in your software then we ought to ship separate SQL statements to the database server to practice the changes. This can move the opportunity of concurrency troubles if the end result set has modified on the grounds that it was once queried via the client. In turn, this raises the opportunity of misplaced updates. So the usage of cursor, higher concurrency Control can be achieved.</li>
</ul>
<h2>Disadvantages of the use of Cursor</h2>
<ul>
    <li>Each time when a row is fetched from the cursor it might also end result in a community spherical trip. This makes use of lots greater community bandwidth than the execution of a single SQL declaration like SELECT or DELETE and so on that makes solely one spherical trip.</li>
    <li>Cursor in SQL is transient work place created in the device memory, accordingly it occupies memory from your machine that may also be handy for different processes. So occupies extra sources and transient storage.</li>
    <li>Repeated community spherical journeys can degrade the pace of the operation the usage of the cursor.</li>
</ul>
<p><b>Visit-:</b> <a href="https://www.remittancesol.com/"><b>Remittance Sol</b></a></p>