w3resource

SQL Data Manipulation Language (DML) Exercises with Solutions and Explanations


SQL Data Manipulation Language (DML) exercises with solutions [15 exercises with solution]

1. Insert a Single Record

Write a SQL query to insert a single record into a table.

Click me to see the solution

2. Insert Multiple Records

Write a SQL query to insert multiple records into a table in a single operation.

Click me to see the solution

3. Update a Single Record

Write a SQL query to update a single record in a table based on a specific condition.

Click me to see the solution

4. Update Multiple Records

Write a SQL query to update multiple records in a table based on a specific condition.

Click me to see the solution

5. Delete a Single Records

Write a SQL query to delete a single record from a table based on a specific condition.

Click me to see the solution

6. Delete Multiple Records

Write a SQL query to delete multiple records from a table based on a specific condition.

Click me to see the solution

7. Insert with Default Values

Write a SQL query to insert a record into a table with default values for unspecified columns.

Click me to see the solution

8. Update using Subquery

Write a SQL query to update records in a table using a subquery to determine the condition.

Click me to see the solution

9. Delete using Subquery

Write a SQL query to delete records from a table using a subquery to determine the condition.

Click me to see the solution

10. Insert from another Table

Write a SQL query to copy data from one table into another table.

Click me to see the solution

11. Update with CASE Statement

Write a SQL query to update records in a table using conditional logic with a CASE statement.

Click me to see the solution

12. Delete All Records

Write a SQL query to delete all records from a table.

Click me to see the solution

13. Insert with Auto-Increment

Write a SQL query to insert a record into a table where the primary key is auto-generated.

Click me to see the solution

14. Update and Reset a Column

Write a SQL query to reset the value of a specific column to NULL for all rows in a table.

Click me to see the solution

15. Delete with JOIN

Write a SQL query to delete records from one table based on a condition derived from a related table using a JOIN.

Click me to see the solution

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.



Follow us on Facebook and Twitter for latest update.