What happens if you execute DROP DATABASE sales_db; while users are connected…

2025

What happens if you execute DROP DATABASE sales_db; while users are connected to the database?

  1. A.

    The database is dropped, and all users are automatically disconnected.

  2. B.

    Only tables are dropped; the database structure remains.

  3. C.

    SQL prevents the drop until all connections are terminated.

  4. D.

    The drop fails silently without changes.

Attempted by 159 students.

Show answer & explanation

Correct answer: C

When you execute DROP DATABASE sales_db; while users are actively connected, the database engine explicitly blocks the command and raises an error. Relational database management systems treat active client sessions as open states that could be performing read or write operations. To prevent sudden application failures, data corruption, or broken transactions, the system holds a lock on the database and mandates that all active connections must be cleared out before a destructive schema change can happen.

Explore the full course: Niacl Ao It Specialist