SQL Data Manipulation Language (DML) 3 — Questions and Answers
Question 1: Which statement undoes uncommitted DML changes?
- ROLLBACK (Correct answer)
- COMMIT
- UNDO
- RESET
Correct answer: ROLLBACK
ROLLBACK reverts changes made since the last commit.
Question 2: To update multiple columns in one UPDATE, you separate assignments with what?
- Commas (Correct answer)
- Semicolons
- Pipes
- AND
Correct answer: Commas
Multiple column assignments in SET are separated by commas.
Question 3: What does INSERT INTO table DEFAULT VALUES do?
- Inserts a row using each column's default value (Correct answer)
- Deletes default rows
- Resets all defaults
- Raises an error
Correct answer: Inserts a row using each column's default value
DEFAULT VALUES inserts a row where every column takes its default.
Question 4: Which keyword in an UPDATE specifies the new value for a column?
- SET (Correct answer)
- VALUES
- ASSIGN
- PUT
Correct answer: SET
SET assigns new values to columns in an UPDATE.
Question 5: A DELETE statement with a subquery in WHERE is used to do what?
- Delete rows based on values from another query (Correct answer)
- Create a new table
- Copy rows
- Sort the table
Correct answer: Delete rows based on values from another query
A subquery in WHERE lets DELETE target rows matching a related query's results.
Question 6: Which DML operation typically locks affected rows until the transaction ends?
- UPDATE (Correct answer)
- SELECT without FOR UPDATE
- CREATE
- DESCRIBE
Correct answer: UPDATE
UPDATE locks the rows it modifies until the transaction commits or rolls back.
Question 7: What does the RETURNING clause (in supported databases) provide after an INSERT?
- The values of the affected rows (Correct answer)
- The table schema
- An error log
- The index definition
Correct answer: The values of the affected rows
RETURNING outputs column values from the rows affected by the statement.
Which statement undoes uncommitted DML changes?