Data Manipulation Language (DML)
- Which of the following is NOT a part of Data Manipulation Language (DML)?
- a) INSERT
- b) DELETE
- c) COMMIT
- d) SELECT
- In SQL, which command is used to modify data in existing rows?
- a) SELECT
- b) UPDATE
- c) ALTER
- d) MERGE
- DML commands directly affect:
- a) Database schema
- b) Data within tables
- c) User privileges
- d) Views
Inserting Data into Tables
- Which SQL command is used to add new rows to a table?
- a) INSERT
- b) CREATE
- c) UPDATE
- d) DELETE
- 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");
- 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
- 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
- Which SQL command is used to change existing data in a table?
- a) INSERT
- b) DELETE
- c) ALTER
- d) UPDATE
- 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
- If you want to delete records with a specific condition, which SQL keyword should you use?
- a) WHERE
- b) IF
- c) LIKE
- d) BETWEEN
- 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.
- 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)
- Which command is used to save the current state of a transaction permanently?
- a) ROLLBACK
- b) COMMIT
- c) SAVEPOINT
- d) EXIT
- 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
- 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
- Which command will undo all changes made since the last COMMIT?
- a) DELETE
- b) ROLLBACK
- c) SAVEPOINT
- d) TRUNCATE
- 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)
- Which command is suitable for inserting multiple rows of data in one statement?
- a) BULK INSERT
- b) INSERT ONE
- c) ADD ROWS
- d) MERGE
- Which of the following commands allows conditional insert, update, or delete actions in SQL?
- a) JOIN
- b) MERGE
- c) UNION
- d) TRUNCATE
- 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
- 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
- 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
- In SQL, a subquery is also known as:
- a) Main query
- b) Inner query
- c) Update query
- d) Base query
- 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.
- A subquery used in a
WHERE clause is generally known as:
- a) Inline view
- b) Correlated subquery
- c) Derived table
- d) Predicate query
- Which operator is commonly used with subqueries to compare values with multiple results from the subquery?
- a) IN
- b) LIKE
- c) JOIN
- d) MERGE
- In which DML command can subqueries be used to determine values for insertion?
- a) INSERT
- b) DROP
- c) ALTER
- d) CREATE
- Which DML command allows subqueries in both the
SET and WHERE clauses?
- a) DELETE
- b) UPDATE
- c) INSERT
- d) SELECT
- What type of subquery returns more than one row of results?
- a) Scalar subquery
- b) Row subquery
- c) Table subquery
- d) Column subquery
- 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:
| Qno | Answer |
|---|
| 1 | c) COMMIT |
| 2 | b) UPDATE |
| 3 | b) Data within tables |
| 4 | a) INSERT |
| 5 | a) INSERT INTO table (name, age, city) VALUES ("Alice", 25, "NY"); |
| 6 | b) Specify only the required columns |
| 7 | b) The insert operation fails |
| 8 | d) UPDATE |
| 9 | c) TRUNCATE TABLE |
| 10 | a) WHERE |
| 11 | b) It can delete specific rows |
| 12 | b) UPDATE |
| 13 | b) COMMIT |
| 14 | c) To undo changes in the current transaction |
| 15 | c) Create a rollback point within the transaction |
| 16 | b) ROLLBACK |
| 17 | a) Changes revert to the SAVEPOINT |
| 18 | a) BULK INSERT |
| 19 | b) MERGE |
| 20 | a) A target table and source table |
| 21 | b) MERGE |
| 22 | b) WHEN MATCHED |
| 23 | b) Inner query |
| 24 | b) They can be used in WHERE, SELECT, and FROM clauses |
| 25 | b) Correlated subquery |
| 26 | a) IN |
| 27 | a) INSERT |
| 28 | b) UPDATE |
| 29 | c) Table subquery |
| 30 | a) Correlated subqueries |
Post Views: 74