[Postgres] Removing Data with SQL Delete, Truncate, and Drop

Delete:

delete from Users where last_name = clark;

If you wanted to delete everything in our table, I mentioned you could just use the delete command without a condition.

 

However, using truncate is a more performant way to do so.

truncate Users;

Unlike the delete command, it doesn‘t scan over the entire table. We also have the ability to truncate more than one table with just one statement by listing the other tables with commas.

 

Finally, if we‘re trying to remove the table completely from our database, we use the drop command.

drop table Users;

Once we run this command, all of the data is deleted and we cannot query anything from this table.

[Postgres] Removing Data with SQL Delete, Truncate, and Drop

上一篇:手机验证码生成


下一篇:tp6 使用DB:table的一个问题,取到到了上一条查询结果的内容