Database Basics MCQs | JoinMyTutor
MCQs on Python database programming basics.
Databases
MCQs on database fundamentals, SQL, and database operations.
-
Which module provides SQLite support?
- A. sqlalchemy
- B. sqlite3
- C. pysql
- D. db
Answer: B — sqlite3 is built-in database module.
-
Which method executes SQL query?
- A. cursor.execute()
- B. db.run()
- C. sql.query()
- D. db.exec()
Answer: A — cursor.execute() is used.
-
Which method fetches all rows?
- A. fetch()
- B. fetchall()
- C. fetchone()
- D. fetchmany()
Answer: B — fetchall() returns all results.
-
Which method fetches single row?
- A. fetch()
- B. fetchone()
- C. fetchall()
- D. get()
Answer: B — fetchone() retrieves one row.
-
Which method commits changes?
- A. db.commit()
- B. cursor.save()
- C. sql.commit()
- D. db.save()
Answer: A — commit() saves changes to DB.
-
Which method reverts uncommitted changes?
- A. rollback()
- B. reset()
- C. undo()
- D. revert()
Answer: A — rollback() cancels uncommitted changes.
-
Which type of SQL injection is prevented by parameterized queries?
- A. Time-based
- B. Union-based
- C. All types
- D. None
Answer: C — Parameterized queries prevent most injections.
-
What is the placeholder symbol for parameters in sqlite3?
- A. ?
- B. %s
- C. :param
- D. $
Answer: A — sqlite3 uses ? placeholders.
-
Which function closes cursor?
- A. cursor.close()
- B. db.close()
- C. end()
- D. terminate()
Answer: A — cursor.close() closes cursor.
-
Which function closes database connection?
- A. end()
- B. db.terminate()
- C. connection.close()
- D. shutdown()
Answer: C — close() method closes connection.
-
Which SQL command creates a table?
- A. MAKE TABLE
- B. CREATE TABLE
- C. NEW TABLE
- D. TABLE()
Answer: B — CREATE TABLE is the correct command.
-
Which SQL command deletes all rows?
- A. DELETE TABLE
- B. DELETE * FROM
- C. DROP
- D. CLEAR
Answer: B — DELETE FROM table removes rows.
-
Which SQL command deletes structure also?
- A. DELETE
- B. DROP TABLE
- C. REMOVE TABLE
- D. CLEAR
Answer: B — DROP TABLE deletes structure.
-
Which isolation level avoids dirty reads?
- A. READ UNCOMMITTED
- B. READ COMMITTED
- C. NONE
- D. SHARED
Answer: B — READ COMMITTED avoids dirty reads.
-
Which method inserts multiple rows efficiently?
- A. cursor.executemany()
- B. cursor.execute()
- C. db.bulk()
- D. sql.multi()
Answer: A — executemany() inserts multiple rows at once.
-
Which module is standard for SQLite in Python?
- A. sqlite
- B. pysqlite
- C. sqlite3
- D. db
Answer: C — sqlite3 is the built-in module for SQLite.
-
Which method executes SQL commands?
- A. execute()
- B. run()
- C. query()
- D. commit()
Answer: A — The execute() method runs SQL statements.
-
Which method saves changes in a database connection?
- A. close()
- B. execute()
- C. commit()
- D. save()
Answer: C — The commit() method saves pending transactions.
-
Which method fetches all rows of a query?
- A. fetchall()
- B. fetch()
- C. fetchone()
- D. fetchmany()
Answer: A — fetchall() retrieves all results from the cursor.
-
Which SQL command is used to create a table?
- A. INSERT
- B. SELECT
- C. CREATE TABLE
- D. UPDATE
Answer: C — CREATE TABLE is used to define a new table.
💡 Tips & Common Mistakes
Remember to review concepts carefully. Fill in custom tips for database-basics here.
📅 Last Updated: November 20, 2026
Vinod Kumar
Senior Full-Stack InstructorPython & JavaScript Tutor at JoinMyTutor
Vinod teaches practical Python and JavaScript—ranging from basics to advanced web apps—with a focus on clear mental models, code readability, and interview preparation. He authors both the Python and JavaScript tracks on JoinMyTutor.