This article is a mirror article of machine translation, please click here to jump to the original article.

View: 132|Reply: 0

[Tips] Database soft deletion (tombod) field uniqueness issue

[Copy link]
Posted on 1/7/2026 4:40:20 PM | | | |
Requirements: In order to prevent accidental deletion and data loss, the deletion operation may not be physical deletion, but soft deletion (logical deletion). If there are unique fields in the table, such as :code, soft deletion introduces new problems.

SQL Server solutions

SQL Server supports Filtered Indexes, which are indexes with a WHERE clause that only create indexes for rows that meet the criteria, and can enforce uniqueness on these parts of the data.

The test script is as follows:
The test is shown below:



MySQL solutions

MySQL handles NULL by allowing multiple NULL values, but not the same non-NULL values. A uniqueness conflict is triggered only if all fields are non-NULL values.

The test script is as follows:
The test is shown below:





Previous:MikroTik (11) RouterOS specifies that the CIDR block is accessed using pptp-client
Next:SQL Server database table row compression and page compression
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com