Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


SQL Playground: "Remove all reviews": DELETE or UPDATE?

Course: Modifying Data w/ SQL

Section: Deleting Data From a Database

Playground: -- We've removed the reviews section from our website. Please remove all reviews.

This is within the DELETE section of the course, but to satisfy the above request, I was able to successfully remove the reviews using an UPDATE query, not DELETE.

UPDATE reviews
SET review = NULL; 

SELECT review FROM reviews ; 

Question: Can this action in fact be executed using DELETE?

2 Answers

My SQL is a bit rusty so hopefully a SQL guru can come in here and correct or confirm this but I believe what you by using update is just set all those reviews to empty values (null), but they still actually exist.

Delete would actually remove the entry entirely.

sailor winkelman
sailor winkelman
2,603 Points

If you want to empty the rows in the review column, it works to use:

UPDATE reviews SET review = NULL;

If you want to delete the rows in the "reviews" table entirely, you can use:

DELETE FROM reviews;