From the course: Database Foundations: Database Management

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Delete data with TRUNCATE

Delete data with TRUNCATE

From the course: Database Foundations: Database Management

Start my 1-month free trial

Delete data with TRUNCATE

- [Instructor] Earlier in this series, we learned that you can remove data rows from a table with a DELETE command. For instance, let's review the beauty_products table that we just created in a prior movie in the Postgres SQL database. This table currently contains seven rows of data. Now, if I wanted to remove the first row, the one with the sku OGEC004, I can write out the command like this. We'll DELETE FROM the inventory.beauty_products table WHERE the sku = OGEC004. If I run this command and then take a look at the table's contents again, we'll see that we're down to six rows of information. The WHERE clause in a DELETE statement is incredibly important. That's because if you omit it and just said DELETE FROM inventory.beauty_products, that command would go through and delete every row from the table. The end result would be an empty table with just the column structure left in tact. But what if that is your goal? What if you do want to completely clear out all data from a…

Contents