SQL Data Manipulation Language (DML) 2 — Questions and Answers
Question 1: Which DML statement adds new rows to a table?
- INSERT (Correct answer)
- UPDATE
- CREATE
- ALTER
Correct answer: INSERT
INSERT adds new rows of data into a table.
Question 2: What does the WHERE clause do in an UPDATE statement?
- Sorts the results
- Restricts which rows are updated (Correct answer)
- Groups the rows
- Joins two tables
Correct answer: Restricts which rows are updated
WHERE limits an UPDATE to only the rows matching its condition.
Question 3: Which statement removes all rows but is technically DDL, not DML?
- DELETE
- TRUNCATE (Correct answer)
- INSERT
- MERGE
Correct answer: TRUNCATE
TRUNCATE removes all rows but is classified as DDL because it is not row-by-row logged like DML.
Question 4: What happens if you run DELETE without a WHERE clause?
- Nothing changes
- Only one row is deleted
- All rows in the table are deleted (Correct answer)
- An error is raised
Correct answer: All rows in the table are deleted
DELETE without WHERE removes every row in the table.
Question 5: Which clause lets you insert results from a query into a table?
- INSERT INTO ... SELECT (Correct answer)
- INSERT VALUES ONLY
- SELECT INTO WHERE
- UPDATE FROM SELECT
Correct answer: INSERT INTO ... SELECT
INSERT INTO ... SELECT inserts rows produced by a SELECT query.
Question 6: Which DML statement combines INSERT, UPDATE, and DELETE logic in one operation?
- MERGE (Correct answer)
- UPSERT only
- REPLACE
- ALTER
Correct answer: MERGE
MERGE performs insert, update, or delete based on whether rows match a source.
Question 7: After a DML change, what statement makes it permanent?
- COMMIT (Correct answer)
- SAVE
- FLUSH
- CLOSE
Correct answer: COMMIT
COMMIT permanently saves the changes made in the current transaction.
Which DML statement adds new rows to a table?