HireHireInterview Quizzes › Database Administrator (DBA)

Database Administrator (DBA) Interview Questions

Think you're ready? These are the questions that actually decide Database Administrator (DBA) interviews. Warm up on Easy — then face the Hard round, where 95% of candidates crumble. 30 questions across 3 levels, instant score, completely free.

30Questions
3Difficulty levels
95%Fail the hard round
FreeInstant score
Easy
Warm-up · 10 Qs
Medium
Practical · 10 Qs
Hard
Brutal · 10 Qs
⚡ Take the Database Administrator (DBA) quiz — get your score →

The Database Administrator (DBA) interview questions

Below are the real questions, grouped by difficulty. Expand any one to reveal the correct answer and why — or take the timed quiz for a score you can share. Can you clear the Hard round?

Easy round 10 questions

In SQL, which command permanently removes all rows from a table AND resets storage without logging individual row deletions?
  • A. DELETE FROM table
  • B. TRUNCATE TABLE table ✓
  • C. DROP TABLE table
  • D. REMOVE TABLE table
Correct answer: B. TRUNCATE TABLE deallocates data pages and removes all rows with minimal logging, unlike DELETE which logs each row and DROP which removes the table structure entirely.
What does the ACID property 'Durability' guarantee in a database transaction?
  • A. Transactions execute in isolation from each other
  • B. Once committed, changes survive a system crash ✓
  • C. All operations in a transaction succeed or none do
  • D. Data always follows integrity constraints
Correct answer: B. Durability ensures that once a transaction is committed, its changes are permanently persisted and survive power loss or crashes, typically via write-ahead logging.
A query on a large table is slow because it scans every row to filter on the 'email' column. What is the most appropriate first step?
  • A. Add an index on the email column ✓
  • B. Increase the server RAM
  • C. Rewrite the query using a subquery
  • D. Partition the table by date
Correct answer: A. Creating an index on the frequently filtered email column lets the optimizer use an index seek instead of a full table scan, directly addressing the cause.
Which type of database backup captures only the data changed since the last FULL backup?
  • A. Incremental backup
  • B. Transaction log backup
  • C. Differential backup ✓
  • D. Snapshot backup
Correct answer: C. A differential backup contains all changes made since the most recent full backup, whereas incremental backups capture changes since the last backup of any type.
In a database transaction isolation context, which phenomenon occurs when a transaction reads a row, another transaction updates and commits it, and the first transaction reads a different value on re-read?
  • A. Dirty read
  • B. Non-repeatable read ✓
  • C. Phantom read
  • D. Lost update
Correct answer: B. A non-repeatable read happens when the same row returns different committed values within one transaction because another transaction modified and committed it in between.
What is the primary purpose of database normalization?
  • A. To speed up all SELECT queries
  • B. To reduce data redundancy and improve integrity ✓
  • C. To compress data on disk
  • D. To increase the number of tables for backups
Correct answer: B. Normalization organizes data to eliminate redundancy and update anomalies, thereby improving data integrity, even though it may sometimes require more joins.
In a MySQL master-slave (primary-replica) setup, what is the standard role of the replica?
  • A. It accepts all write traffic
  • B. It receives and applies changes from the primary for reads/failover ✓
  • C. It stores only backup files
  • D. It replaces the primary's binary logs
Correct answer: B. A replica continuously receives changes from the primary (via binary logs) and applies them, serving read queries and standing by for failover, while writes go to the primary.
Which SQL clause is used to grant a user permission to perform actions on a database object?
  • A. ALLOW
  • B. GRANT ✓
  • C. PERMIT
  • D. ASSIGN
Correct answer: B. GRANT is the standard SQL DCL statement used to give privileges such as SELECT, INSERT, or UPDATE on objects to users or roles.
A deadlock occurs between two transactions. What does a typical relational database engine do to resolve it?
  • A. Pause both transactions indefinitely
  • B. Choose one transaction as a victim and roll it back ✓
  • C. Merge the two transactions into one
  • D. Commit both transactions immediately
Correct answer: B. The database's deadlock detection selects one transaction (usually the least costly to undo) as the victim and rolls it back so the other can proceed.
In PostgreSQL, what is the purpose of running VACUUM?
  • A. To rebuild all indexes from scratch
  • B. To reclaim storage from dead tuples left by updates/deletes ✓
  • C. To encrypt table data at rest
  • D. To create a full database backup
Correct answer: B. VACUUM reclaims space occupied by dead tuples (created by MVCC during updates and deletes) so it can be reused, preventing table bloat and transaction ID wraparound.

Medium round 10 questions

A production query has suddenly become slow. You run EXPLAIN and see a full table scan on a large table where you expected an index to be used. Which is the MOST likely practical cause to investigate first?
  • A. The table's statistics are stale, so the optimizer misestimates row counts ✓
  • B. The database server has run out of disk space
  • C. The primary key was dropped from the table
  • D. The query is using a bind variable instead of a literal
Correct answer: A. Stale statistics commonly cause the optimizer to pick a full scan over an available index, so updating/rebuilding statistics is the first thing to check.
You need to take a backup of a large production database with minimal impact on running transactions and the ability to restore to any point in time. Which backup strategy is most appropriate?
  • A. A nightly full logical export (mysqldump/pg_dump) only
  • B. A full physical backup plus continuous archiving of transaction/redo logs ✓
  • C. Copying the data files while the database is running, without any log archiving
  • D. A weekly cold backup taken while the database is shut down
Correct answer: B. A full physical backup combined with continuous transaction log archiving is what enables point-in-time recovery with low impact.
In a relational database, you want to enforce that every row in an 'orders' table references a valid row in the 'customers' table. Which mechanism enforces this at the database level?
  • A. A CHECK constraint on the orders table
  • B. A UNIQUE index on customers.id
  • C. A FOREIGN KEY constraint on orders.customer_id referencing customers.id ✓
  • D. A trigger that runs only on SELECT
Correct answer: C. A FOREIGN KEY constraint enforces referential integrity by requiring the referenced value to exist in the parent table.
Two transactions are updating the same set of rows in reverse order and the database reports a deadlock, rolling one back. What is the standard, practical way an application should handle this?
  • A. Disable locking on the affected tables
  • B. Increase the deadlock timeout to infinity so it never triggers
  • C. Catch the error and retry the failed transaction, ideally accessing rows in a consistent order ✓
  • D. Switch the database to READ UNCOMMITTED for all sessions
Correct answer: C. Deadlocks are expected under concurrency; the correct handling is to retry the aborted transaction and design consistent lock ordering to reduce recurrence.
A table has columns (a, b, c) and a composite index on (a, b, c). Which of the following WHERE clauses can most effectively use this index?
  • A. WHERE b = 5 AND c = 10
  • B. WHERE a = 1 AND b = 5 ✓
  • C. WHERE c = 10
  • D. WHERE b = 5
Correct answer: B. A composite index is used left-to-right, so predicates on the leading columns (a, then b) can use it, whereas skipping the leading column cannot.
You are asked to grant a reporting user the ability to read data from all current and future tables in a schema, but nothing else. Following the principle of least privilege, which approach is best?
  • A. Grant the user the DBA/superuser role for convenience
  • B. Grant SELECT on the schema's tables and set default privileges so future tables also grant SELECT ✓
  • C. Give the user the application's write account credentials
  • D. Grant ALL PRIVILEGES on the database to the user
Correct answer: B. Granting only SELECT plus default privileges for future tables gives exactly the read access needed without over-permissioning.
A frequently updated table has become bloated and queries are slowing down over time in PostgreSQL. Autovacuum appears to be falling behind. What is the most appropriate action?
  • A. Drop and recreate the table on every deployment
  • B. Tune autovacuum settings (e.g., make it more aggressive) and/or run VACUUM to reclaim space and update visibility ✓
  • C. Disable autovacuum entirely to reduce overhead
  • D. Convert the table to an unlogged table
Correct answer: B. Bloat from dead tuples is addressed by vacuuming; tuning autovacuum to run more aggressively keeps the table healthy without manual intervention.
Your team wants a standby database that automatically stays in sync with the primary and can be promoted if the primary fails. Which feature provides this?
  • A. Scheduled logical dumps restored hourly onto a second server
  • B. Streaming/physical replication from the primary to a standby replica ✓
  • C. A read-only copy refreshed manually once a day
  • D. Partitioning the primary table across two servers
Correct answer: B. Streaming replication continuously ships changes to a standby that can be promoted, providing high availability and failover capability.
You need to add a NOT NULL column with a default value to a very large, busy table in production. What is the safest practical concern to plan around?
  • A. NOT NULL columns cannot have defaults, so the operation will fail
  • B. The ALTER may acquire locks and/or rewrite the table, potentially blocking writes for a long time ✓
  • C. Adding a column always drops all existing indexes
  • D. The change can only be performed while the database is in single-user mode
Correct answer: B. On large tables an ALTER that rewrites data or holds a strong lock can block concurrent access, so DBAs plan for locking and downtime or use online techniques.
A developer reports that a batch job intermittently reads rows another transaction has inserted but not yet committed, causing incorrect totals. Which isolation-related fact is correct?
  • A. READ UNCOMMITTED prevents this by blocking all reads
  • B. Reading uncommitted data is a dirty read, avoided by using READ COMMITTED or higher ✓
  • C. SERIALIZABLE is the only level that allows dirty reads
  • D. Dirty reads only occur when autocommit is enabled
Correct answer: B. Reading another transaction's uncommitted changes is a dirty read, and READ COMMITTED (or stricter) isolation prevents it.

Hard round 10 questions

A PostgreSQL query that ran in 20ms yesterday now takes 8 seconds. EXPLAIN ANALYZE shows the planner chose a nested-loop join with an inner sequential scan, and the plan node reports `rows=1` estimated vs `rows=480000` actual on the driving table after a large bulk load. Which action most directly addresses the root cause?
  • A. Add a covering index on the join column so the nested loop can seek instead of scan
  • B. Run ANALYZE on the affected table so the planner has fresh cardinality statistics ✓
  • C. Increase work_mem so the hash join spills less to disk
  • D. Set enable_nestloop = off for the session to force a hash join
Correct answer: B. A 1-vs-480000 estimate error after a bulk load is a stale-statistics symptom, so running ANALYZE restores accurate cardinality and lets the optimizer pick the correct join method.
On SQL Server you observe a stored procedure that is fast for most inputs but occasionally times out after a plan recompiles. The cached plan was compiled for a highly selective parameter value but is being reused for a value that matches millions of rows, causing an index seek + key lookup instead of a scan. Which technique specifically neutralizes this parameter-sniffing regression without disabling reuse entirely?
  • A. Add OPTION (RECOMPILE) or OPTIMIZE FOR UNKNOWN to the statement ✓
  • B. Update statistics with FULLSCAN on the underlying table
  • C. Rebuild the nonclustered index to remove fragmentation
  • D. Wrap the query in a transaction at SERIALIZABLE isolation
Correct answer: A. OPTION (RECOMPILE) recompiles per execution using the actual parameter, and OPTIMIZE FOR UNKNOWN uses average density, both directly countering a skewed sniffed plan.
Two application transactions repeatedly deadlock in production. Session A updates rows in table `orders` then `inventory`; session B updates `inventory` then `orders`. Retrying reduces symptoms but the deadlocks recur under load. What is the most robust permanent fix?
  • A. Lower the isolation level of both transactions to READ COMMITTED
  • B. Enforce a consistent lock-acquisition order (always orders then inventory) in both code paths ✓
  • C. Add NOLOCK hints to the SELECT statements inside both transactions
  • D. Increase the deadlock_timeout so the detector waits longer before aborting
Correct answer: B. Deadlocks from a lock cycle are eliminated by imposing a global ordering on resource acquisition so a circular wait can never form; retry logic only masks the recurrence.
In PostgreSQL, `pg_stat_activity` shows an idle-in-transaction session open for 6 hours. Autovacuum is running but dead tuples on a hot table keep climbing and the table is bloating. Why can't autovacuum reclaim the space, and what is the correct immediate action?
  • A. Autovacuum is blocked by a lock; run VACUUM FULL to force reclaiming
  • B. The long transaction holds back the xmin horizon so dead tuples remain visible; terminate that transaction ✓
  • C. Autovacuum cost limits are too low; raise autovacuum_vacuum_cost_limit to catch up
  • D. The table needs a REINDEX because index bloat prevents tuple removal
Correct answer: B. An old open transaction pins the global xmin horizon, so VACUUM cannot remove tuples still potentially visible to it; ending that transaction lets cleanup proceed.
You must choose an isolation level for a financial ledger that debits one account and credits another, where the invariant is that total balance across a set of accounts never goes negative even under concurrent transfers. Under PostgreSQL, which level prevents the write-skew anomaly that lets two concurrent transactions each pass the check and jointly violate the invariant?
  • A. READ COMMITTED with SELECT ... FOR UPDATE on both rows
  • B. REPEATABLE READ (snapshot isolation)
  • C. SERIALIZABLE ✓
  • D. READ COMMITTED with an advisory lock on the account pair
Correct answer: C. Write skew is a snapshot-isolation anomaly that REPEATABLE READ permits; only SERIALIZABLE (SSI) detects the dangerous read/write dependency and aborts one transaction, though explicit row locking can also work it is not the isolation-level answer asked for.
After an automated standby promotion, application reads begin failing with errors like 'cannot execute UPDATE in a read-only transaction' intermittently, while other reads succeed. The connection string points to a DNS name fronting both nodes. What is the most likely root cause?
  • A. Replication lag on the new primary is serving stale reads
  • B. The old primary was not fully demoted and connections are load-balanced across a still-read-only node ✓
  • C. The new primary's statistics are stale after promotion
  • D. Synchronous commit is waiting on a standby that no longer exists
Correct answer: B. The 'read-only transaction' error means some connections still land on a node in recovery/standby mode, indicating split routing where the old node wasn't demoted or removed from the pool.
An overnight alert fires: the primary's data volume hit 100% and writes are failing. You have a synchronous standby that is healthy. Ordering the response, which sequence best balances availability and data safety?
  • A. Immediately run VACUUM FULL on the largest table to reclaim space on the primary
  • B. Delete old WAL segments manually with rm to free space, then continue
  • C. Fail over to the healthy standby to restore writes, then root-cause the primary's disk (WAL accumulation, unrotated logs, bloat) offline ✓
  • D. Extend the volume online and take no further action since space is restored
Correct answer: C. Failing over restores service safely without risky in-place operations on a full disk, and manually deleting WAL can corrupt recovery/replication; root-cause and retention fixes follow.
A gp3 EBS volume backs an RDS PostgreSQL instance. Monitoring shows disk queue depth climbing and read latency spiking during a nightly batch, yet CPU is at 30% and the buffer cache hit ratio is 99%. You provisioned 12000 IOPS but throughput sits pinned at 125 MiB/s. What is the actual bottleneck?
  • A. The instance is CPU-starved and needs a larger instance class
  • B. The IOPS ceiling is being hit and more provisioned IOPS is required
  • C. gp3's default throughput (125 MiB/s) is saturated; provision higher throughput separately from IOPS ✓
  • D. The buffer cache is too small, forcing physical reads
Correct answer: C. gp3 decouples IOPS from throughput, and the default 125 MiB/s cap is a common hidden ceiling for large sequential batch I/O even when IOPS headroom remains.
You are designing HA/DR for a system with RPO = 0 and RTO = 60 seconds. Which architecture satisfies both constraints?
  • A. Asynchronous cross-region replica with automated failover
  • B. Synchronous replication to a standby in another AZ with automatic failover and split-brain fencing ✓
  • C. Nightly full backups plus WAL archiving to object storage for PITR
  • D. Semi-synchronous replication to a cross-region replica
Correct answer: B. RPO=0 mandates synchronous commit (no acknowledged-but-lost writes), and a same-region cross-AZ synchronous standby with fast fenced failover meets the 60-second RTO, whereas async/PITR permit data loss.
In an Oracle RAC cluster, AWR shows high 'gc buffer busy acquire' and 'gc cr block busy' waits concentrated on one hot index's right-most leaf block during heavy concurrent inserts of sequential keys. Which change most directly reduces the interconnect contention?
  • A. Increase the interconnect MTU (jumbo frames)
  • B. Convert the index to a reverse-key or hash-partitioned global index to spread inserts across blocks ✓
  • C. Raise the buffer cache size on all instances
  • D. Increase the ASM rebalance power limit
Correct answer: B. Sequential-key inserts create a right-hand-index hot block pinging across the interconnect; a reverse-key or hash-partitioned index distributes inserts across many blocks, eliminating the single hot leaf.

Prep for another role

Questions are original, written and independently verified for HireHire's role interview quizzes. They reflect the kind of knowledge Database Administrator (DBA) interviews test, not any specific company's questions. HireHire maps live tech & IT jobs across India, updated regularly. Last updated: July 2026.