首页 > 数据库技术 > 详细

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

时间:2020-08-28 23:11:42      阅读:76      评论:0      收藏:0      [点我收藏+]

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

原文:https://www.cnblogs.com/Answer1215/p/13579585.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!