Delete database records, delete good or update? _ Application Tips

Source: Internet
Author: User

Personally, it's better to use update.
After some tests, it was found that almost all databases use the DELETE statement, the database file size does not become smaller, so that every time the database insert operation, the database volume will be larger.

Instead of deleting it, let him keep it. found that when using update, as long as the new data is not larger than the original, the size of the database will not increase (the file is stored to the database is very easy to see effect).

Therefore, it is recommended that you use the Update method to mark the deletion of records, and when you add a new record, update the record as a new record if there is a record marked for deletion. When you add a new record, the judgment is simple:

Copy Code 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 query for any data that is marked for deletion, if not (Rs. EOF), inserts a record (ADDNEW) or overwrites the new data to the first queried record.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.