2011-09-13 48 views
3

這是更好的表現明智,沒有錯誤原因刪除android中的sqlite表中的所有行。刪除所有查詢或丟棄查詢

DELETE查詢或DROP TABLE和重新生成表

我發現這個從這個post

it is more efficient to drop table and re-create it; and yes, You can use "IF EXISTS" in this case 

DELETE FROM will cause SQLite to visit individual rows unless those rows have triggers, so it's generally reasonably efficient. 


edited after 1 answer post 

As the Droping the table using drop table query then internally delete query was used? As in one answer post 

回答

3

根據sqlite查詢我找到了答案。在sqlite中,他們使用了截斷優化,所以當「where」子句被省略時,他們刪除表並重新創建表,這比刪除所有行快得多。

這裏是該

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

http://www.sqlite.org/compile.html#omit_truncate_optimization

+0

是鏈接。 它說: SQLite的默認構建,如果DELETE語句沒有WHERE子句並在沒有觸發器的表上操作,則會發生優化,通過刪除和重新創建表導致DELETE發生。刪除和重新創建表格通常比逐行刪除表格內容要快得多。這是「截斷優化」。 –

0

按我的知識刪除查詢是因爲掉落更好option.why表內部使用刪除查詢。如果使用刪除查詢,則必須重新生成表格。這是一個額外的過程。