From the course: Intermediate SQL: Data Reporting and Analysis
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
DELETE rows from a table - SQL Tutorial
From the course: Intermediate SQL: Data Reporting and Analysis
DELETE rows from a table
- [Teacher] You could easily imagine running a database like Sakila, where a customer wants to close their account and you need to delete their information. Here we look at how to delete data from a table and I introduce you to some of the perils of deleting. The delete command is very straightforward but you should be daunted by just how easy it is to remove all the data or all the tables from your database in one go. Delete from star, for example will remove everything from all tables. Be afraid, be very afraid. If you are not using a where clause with your delete statement ask yourself why. It's best to run a select statement of the same structure before you run the delete so you can see what you are getting rid of. Now, we recently created category two so let's delete from it. There's category two, 16 rows and we're going to say, delete from category two where name is "action". Do you really want to do this? Yes…