When deleting database content, many people are confused about whether to use delete or update? After some small tests, the editor of Foxin has obtained the following results. Next, we will see whether it is better to use delete or update to delete the database records.
I personally think it is better to use Update.
After some tests, it was found that after almost all databases use delete statements, the database file size did not become smaller, so that every insertion operation of the database will make the database larger.
Instead of not being able to delete it, let him keep it. I found that when using Update, as long as the new data is not larger than the original, the database size will not increase (it is easy to see the effect when stored in the database).
Therefore, I personally recommend using the Update method to mark the deleted record. If there is a record marked as deleted when adding a new record, the record will be updated as a new record. The judgment when adding new records is also relatively simple:
Copy the code as follows: rs.Open "select * from tableName where deleted=1 order by ID asc"If rs.EOF Then rs.AddNew
rs(1).Value="...";
'.....
rs.Update
When we need to add new data, we first check whether there is any data marked as deleted. If there is no (rs.EOF), insert the record (addNew), otherwise the new data will be overwritten the first query record.
The above is the content we summarized for all friends that better use delete or update to delete database records. I hope it can help you. The editor of the Wrong New Technology Channel will patiently answer your questions.