Browse stackoverflow today and find an interesting question: whichwasmorepreferableasperformancewiseandwithouterrorcausetodeletealltherowfromtableinsqliteinandroid. DELETEQUERYORDROPTABLEANDRE-GENERATETHETABLE? And remove sqlite
Today, I found an interesting problem through stackoverflow: which was more preferable as performance wise and without error cause to delete all the row from table in sqlite in android. delete query or drop table and re-generate the table? And remove sqlite
Today, stackoverflow found an interesting problem:
Which was more preferable as performance wise and without error cause to delete all the row from table in sqlite in android.
Delete query or drop table and re-generate the table?
And to delete all data in sqlite, it is more efficient to use drop and re-build the data in sqlite than delete all.
it is more efficient to drop table and re-create it; and yes, You can use "IF EXISTS" in this caseDELETE FROM will cause SQLite to visit inpidual rows unless those rows have triggers, so it's generally reasonably efficient.edited after 1 answer postAs the Droping the table using drop table query then internally delete query was used? As in one answer post
"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 inpidually. this "truncate" optimization makes the delete run much faster. prior to SQLite version 3.6.5, the truncate optimization also meant that the sqlite3_changes () and between () interfaces and the count_changes pragma will not actually return the number of deleted rows. that problem has been fixed as of version 3.6.5."
When the DELETE statement is ignored, the deletion of the table is not triggered. SQLite uses an optimization function to DELETE the entire table without having to access each row of the table separately. This "truncation" optimization makes deletion faster. 3.6.5 before SQLite, truncation optimization also means that the sqlite3_changes () and sqlite3_total_changes () interfaces and count_changes compilation instructions do not actually return the number of lines to be deleted. This issue is fixed in version 3.6.5 ."
SQLite: Default build. If a DELETE statement does not have a WHERE clause or operate a table, the deletion is optimized and the table is re-created. Deleting and recreating a table is usually much higher than deleting the table row by row. This is "truncation optimization"
That is, delete reads a row and deletes a row. It is more efficient to create a row after drop.