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!
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
Sean Flanagan33,234 Points
DELETE vs DROP vs TRUNCATE
So have I got this right? DELETE deletes one table row, TRUNCATE deletes every row in a table, and DROP deletes the entire table?
Thanks in advance.
Steven Parker228,119 Points
Close. You're right about TRUNCATE and DROP. Now DELETE can remove a single row, it can also delete every row. For example:
DELETE FROM mytable WHERE id = 21;
...would remove just one row (assuming id is a unique key and there is a row with 21 in it). But just this:
DELETE FROM mytable;
...would remove every row. By using different WHERE conditions you could also delete more than one, but not all rows.