1.Easy
What does a UNIQUE constraint on a column guarantee?
- AThe column values are sorted
- BThe column cannot be changed after insert
- CNo two rows have the same non-NULL value in that column
- DThe column automatically becomes the primary key of the table
2.Easy
GRANT and REVOKE belong to which part of SQL?
- AData Definition Language (DDL)
- BData Manipulation Language (DML)
- CData Control Language (DCL)
- DData Query Language (DQL)
3.Easy
Which keyword gives a column or table a temporary alternative name in a query?
- AAS
- BRENAME
- CNAME
- DALIAS
4.Medium
A foreign key is declared with ON DELETE CASCADE. What happens when a parent row is deleted?
- AThe foreign key in the child rows is set to NULL automatically
- BThe child rows that reference it are deleted automatically
- CThe delete is always rejected
- DThe parent row is copied to an archive table
5.Medium
Which query lists customers who have never placed an order?
- ASELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
- BSELECT c.name FROM customers c INNER JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
- CSELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id = NULL
- DSELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NOT NULL
6.Medium
When is WHERE EXISTS (subquery) true for a row?
- AWhen the subquery returns at least one row
- BWhen the subquery returns exactly one row
- CWhen the subquery returns a number greater than zero
- DWhen the subquery returns no NULL values
7.Hard
An app runs UPDATE item SET qty = 4, version = 8 WHERE id = 1 AND version = 7, and reports a conflict if no row was updated. What technique is this?
- AStrict two-phase locking with row locks
- BDatabase sharding
- COptimistic concurrency control
- DWrite-ahead logging
8.Hard
Two doctors on call each check that the other is still on call, then both sign off at the same time. Which anomaly can snapshot isolation still allow here?
- ADirty write
- BWrite skew
- CNon-repeatable read within one transaction
- DDirty read
Answer key
- 1. C · No two rows have the same non-NULL value in that column
- 2. C · Data Control Language (DCL)
- 3. A · AS
- 4. B · The child rows that reference it are deleted automatically
- 5. A · SELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
- 6. A · When the subquery returns at least one row
- 7. C · Optimistic concurrency control
- 8. B · Write skew
Full step-by-step solutions: practise this topic on examproblems.com.