AMP

Chapter 15: Data Manipulation Through SQL — Online MCQ Test

COMPUTER SCIENCE · CLASS 12th · Tamil Nadu State Board
Practice Chapter 15: Data Manipulation Through SQL with a free chapter-wise online MCQ test. This chapter covers: This chapter covers executing SQL queries dynamically within Python scripts using sqlite3 modules. It details database connections cursor objects record fetching aggregate function.... AI-generated questions from basic to board-exam level, with instant results and explanations.

Start Exam on Full Site →

Chapter 15: Data Manipulation Through SQL — Important Questions & Answers

Which Python module is used to interact with SQLite databases?
  • A. sqlite3
  • B. mysql
  • C. pymysql
  • D. sqlalchemy
Answer: A. sqlite3
The sqlite3 module provides the interface to work with SQLite databases in Python. It is the module prescribed for database access in this chapter.
What does the execute() method of a cursor object do?
  • A. Deletes the database
  • B. Runs an SQL statement
  • C. Creates a table automatically
  • D. Closes the connection
Answer: B. Runs an SQL statement
The execute() method is used to send and run SQL commands such as SELECT, INSERT, UPDATE, and DELETE through a cursor object.
Which of the following is the correct order to work with an SQLite database in Python?
  • A. Open cursor, create connection, execute query, fetch result
  • B. Create connection, create cursor, execute query, fetch result
  • C. Execute query, create connection, create cursor, fetch result
  • D. Fetch result, execute query, create cursor, create connection
Answer: B. Create connection, create cursor, execute query, fetch result
First a connection is created to access the database, then a cursor is created to execute SQL commands, and finally results are fetched.
A programmer wants to increase the salary of employee number 10 by 2000 in an existing table. Which query is correct?
  • A. UPDATE employee SET salary = salary + 2000 WHERE empno = 10;
  • B. INSERT INTO employee salary = salary + 2000 WHERE empno = 10;
  • C. SELECT salary + 2000 FROM employee WHERE empno = 10;
  • D. DELETE FROM employee WHERE empno = 10;
Answer: A. UPDATE employee SET salary = salary + 2000 WHERE empno = 10;
UPDATE with a SET clause changes the value in the salary column, and WHERE ensures only employee 10 is affected.
Which statement about sqlite3 cursor objects is NOT correct?
  • A. A cursor is used to execute SQL commands
  • B. A cursor can fetch rows from a query result
  • C. A cursor stores the database permanently
  • D. A cursor is created from a connection object
Answer: C. A cursor stores the database permanently
A cursor is only a control object for executing queries and fetching results. The database is stored in the connection/database file, not in the cursor.