gpt4 book ai didi

database - 删除表 vs 删除其内容 sqlite

转载 作者:IT王子 更新时间:2023-10-29 06:30:57 24 4
gpt4 key购买 nike

在我的应用程序中,我必须删除表格的全部内容并多次重新填充它

在那种情况下,我有两个解决方案:

1- 放下,重新创建并填充表格

"DROP TABLE IF EXISTS TABLE_NAME"

2- 移除所有内容并重新填充

"DELETE FROM TABLE_NAME"

现在哪个解决方案更有效?

最佳答案

来自 http://www.sqlite.org/lang_delete.html :

The Truncate Optimization

When the WHERE is omitted from a DELETE statement and the table being deleted has no triggers, SQLite uses an optimization to erase the entire table content without having to visit each row of the table individually. This "truncate" optimization makes the delete run much faster.

关于database - 删除表 vs 删除其内容 sqlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16570719/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com