MCQs on Data Manipulation Language (DML) | Data Operations

Data Manipulation Language (DML)

  1. Which of the following is NOT a part of Data Manipulation Language (DML)?
    • a) INSERT
    • b) DELETE
    • c) COMMIT
    • d) SELECT
  2. In SQL, which command is used to modify data in existing rows?
    • a) SELECT
    • b) UPDATE
    • c) ALTER
    • d) MERGE
  3. DML commands directly affect:
    • a) Database schema
    • b) Data within tables
    • c) User privileges
    • d) Views

Inserting Data into Tables

  1. Which SQL command is used to add new rows to a table?
    • a) INSERT
    • b) CREATE
    • c) UPDATE
    • d) DELETE
  2. If a table has columns name, age, and city, which of the following is the correct way to insert a row?
    • a) INSERT INTO table (name, age, city) VALUES ("Alice", 25, "NY");
    • b) INSERT INTO table VALUES (name="Alice", age=25, city="NY");
    • c) INSERT VALUES INTO table ("Alice", 25, "NY");
    • d) ADD INTO table VALUES ("Alice", 25, "NY");
  3. To insert data into only specific columns of a table, we:
    • a) Leave the column list empty
    • b) Specify only the required columns
    • c) Use the ALTER command
    • d) Leave out the column values
  4. What happens if we omit a NOT NULL column while inserting data?
    • a) It auto-fills with default values
    • b) The insert operation fails
    • c) The column is left blank
    • d) The data gets automatically updated

Updating and Deleting Data

  1. Which SQL command is used to change existing data in a table?
    • a) INSERT
    • b) DELETE
    • c) ALTER
    • d) UPDATE
  2. Which of these commands can remove all records from a table without deleting the table itself?
    • a) DROP TABLE
    • b) DELETE FROM table
    • c) TRUNCATE TABLE
    • d) CLEAR TABLE
  3. If you want to delete records with a specific condition, which SQL keyword should you use?
    • a) WHERE
    • b) IF
    • c) LIKE
    • d) BETWEEN
  4. Which of the following is true about the DELETE command?
    • a) It removes the table structure.
    • b) It can delete specific rows.
    • c) It cannot delete multiple rows at once.
    • d) It is the same as TRUNCATE.
  5. To update the salary of employees in a specific department, which command would you use?
    • a) MODIFY
    • b) UPDATE
    • c) DELETE
    • d) CHANGE

Using Transactions (COMMIT, ROLLBACK, and SAVEPOINT)

  1. Which command is used to save the current state of a transaction permanently?
    • a) ROLLBACK
    • b) COMMIT
    • c) SAVEPOINT
    • d) EXIT
  2. What is the purpose of the ROLLBACK command?
    • a) To save changes permanently
    • b) To delete all records in a table
    • c) To undo changes in the current transaction
    • d) To lock a table
  3. In a transaction, the SAVEPOINT command is used to:
    • a) Permanently save the transaction
    • b) Roll back all changes
    • c) Create a rollback point within the transaction
    • d) Exit the transaction
  4. Which command will undo all changes made since the last COMMIT?
    • a) DELETE
    • b) ROLLBACK
    • c) SAVEPOINT
    • d) TRUNCATE
  5. What will happen if a ROLLBACK command is issued after a SAVEPOINT?
    • a) Changes revert to the SAVEPOINT
    • b) No changes are reverted
    • c) All changes in the transaction are committed
    • d) The transaction ends

Advanced Insert Techniques (Bulk Inserts, MERGE Statements)

  1. Which command is suitable for inserting multiple rows of data in one statement?
    • a) BULK INSERT
    • b) INSERT ONE
    • c) ADD ROWS
    • d) MERGE
  2. Which of the following commands allows conditional insert, update, or delete actions in SQL?
    • a) JOIN
    • b) MERGE
    • c) UNION
    • d) TRUNCATE
  3. What does the MERGE statement typically require?
    • a) A target table and source table
    • b) Only a target table
    • c) Only a source table
    • d) No tables at all
  4. To perform an update if a record exists, or insert if it does not, which command is ideal?
    • a) INSERT
    • b) MERGE
    • c) CREATE
    • d) DELETE
  5. Which clause can be used within a MERGE statement for conditional actions?
    • a) WHERE
    • b) WHEN MATCHED
    • c) SELECT
    • d) HAVING

Subqueries in DML Statements

  1. In SQL, a subquery is also known as:
    • a) Main query
    • b) Inner query
    • c) Update query
    • d) Base query
  2. Which statement is true about subqueries?
    • a) They must be used in the FROM clause only.
    • b) They can be used in WHERE, SELECT, and FROM clauses.
    • c) They are only used in DELETE statements.
    • d) They cannot return a single value.
  3. A subquery used in a WHERE clause is generally known as:
    • a) Inline view
    • b) Correlated subquery
    • c) Derived table
    • d) Predicate query
  4. Which operator is commonly used with subqueries to compare values with multiple results from the subquery?
    • a) IN
    • b) LIKE
    • c) JOIN
    • d) MERGE
  5. In which DML command can subqueries be used to determine values for insertion?
    • a) INSERT
    • b) DROP
    • c) ALTER
    • d) CREATE
  6. Which DML command allows subqueries in both the SET and WHERE clauses?
    • a) DELETE
    • b) UPDATE
    • c) INSERT
    • d) SELECT
  7. What type of subquery returns more than one row of results?
    • a) Scalar subquery
    • b) Row subquery
    • c) Table subquery
    • d) Column subquery
  8. Subqueries that reference a column in the outer query are called:
    • a) Correlated subqueries
    • b) Non-correlated subqueries
    • c) Inline views
    • d) Derived tables

Answer Key:

QnoAnswer
1c) COMMIT
2b) UPDATE
3b) Data within tables
4a) INSERT
5a) INSERT INTO table (name, age, city) VALUES ("Alice", 25, "NY");
6b) Specify only the required columns
7b) The insert operation fails
8d) UPDATE
9c) TRUNCATE TABLE
10a) WHERE
11b) It can delete specific rows
12b) UPDATE
13b) COMMIT
14c) To undo changes in the current transaction
15c) Create a rollback point within the transaction
16b) ROLLBACK
17a) Changes revert to the SAVEPOINT
18a) BULK INSERT
19b) MERGE
20a) A target table and source table
21b) MERGE
22b) WHEN MATCHED
23b) Inner query
24b) They can be used in WHERE, SELECT, and FROM clauses
25b) Correlated subquery
26a) IN
27a) INSERT
28b) UPDATE
29c) Table subquery
30a) Correlated subqueries

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top