40 Lecture
CS304
Midterm & Final Term Short Notes
CURSORS
In database management systems, a cursor is a pointer that enables traversal over a set of rows in a result set. Cursors are used to manipulate the data retrieved from a database, allowing for selective processing and updating of records. Cursor
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
- What is a cursor in a database management system?
A) A database object that stores data
B) A pointer that enables traversal over a set of rows in a result set
C) A file that stores database information
D) A function that returns a value
Answer: B
What is the purpose of a cursor in SQL?
A) To insert data into a database
B) To retrieve data from a database
C) To update data in a database
D) To delete data from a database
Answer: B
What are the types of cursors in SQL?
A) Static, dynamic, and keyset-driven
B) Primary, secondary, and tertiary
C) Logical, physical, and virtual
D) Simple, complex, and compound
Answer: A
Which SQL keyword is used to define a cursor?
A) DECLARE
B) CREATE
C) INSERT
D) SELECT
Answer: A
What is the purpose of the OPEN statement in SQL cursors?
A) To define the cursor
B) To fetch the next row from the cursor
C) To close the cursor
D) To execute a stored procedure
Answer: B
Which SQL keyword is used to fetch the next row from a cursor?
A) FETCH
B) SELECT
C) UPDATE
D) DELETE
Answer: A
What is the purpose of the CLOSE statement in SQL cursors?
A) To define the cursor
B) To fetch the next row from the cursor
C) To close the cursor
D) To execute a stored procedure
Answer: C
What is the purpose of the DEALLOCATE statement in SQL cursors?
A) To define the cursor
B) To fetch the next row from the cursor
C) To close the cursor
D) To free up memory used by the cursor
Answer: D
Which type of cursor is more efficient in terms of performance?
A) Static cursor
B) Dynamic cursor
C) Keyset-driven cursor
D) There is no difference in performance between cursor types
Answer: A
Can cursors be used in all programming languages?
A) Yes
B) No, only in SQL and related languages
C) No, only in procedural languages
D) No, only in object-oriented languages
Answer: B
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is a cursor in a database management system? Answer: A cursor is a database object that allows the traversal of a set of rows retrieved from a query result set. How do you declare a cursor in SQL? Answer: To declare a cursor in SQL, you use the DECLARE statement followed by the cursor name and query that will be used to populate the cursor. What are the types of cursors available in SQL? Answer: The types of cursors in SQL are static, dynamic, and keyset-driven. How do you fetch data from a cursor in SQL? Answer: To fetch data from a cursor in SQL, you use the FETCH statement, which retrieves the next row from the result set associated with the cursor. How do you close a cursor in SQL? Answer: To close a cursor in SQL, you use the CLOSE statement followed by the cursor name. What is the purpose of a cursor in database programming? Answer: Cursors allow you to manipulate individual rows of data returned from a query, making it possible to perform complex data operations that are not possible with simple SQL statements. What is a forward-only cursor? Answer: A forward-only cursor is a type of cursor that can only be scrolled forward through the rows of the result set. What is a keyset-driven cursor? Answer: A keyset-driven cursor is a type of cursor that is based on a unique key value or set of values, making it possible to quickly search through the result set. What is a dynamic cursor? Answer: A dynamic cursor is a type of cursor that allows you to change the underlying query associated with the cursor while it is still open. Can cursors be used in all database management systems? Answer: No, cursors are not available in all database management systems and their usage and implementation may vary between systems that support them.