The updated or deleted row value either does not make the row a unique row, or changes multiple rows, how to resolve

Source: Internet
Author: User

When you manipulate a database, you often encounter an updated or deleted row value that either does not make the row a unique row or changes multiple rows, as follows:















Reason analysis: Prompt that the deleted row is not the only row, and then check it again and discover:

is a duplicate key value or data that appears in the database, prompting an error when you try to delete it.

Workaround:
Method One: Add a primary key to make the row value unique.

SQL statement: ALTER table name
Add ID int Identity primary KEY (note: Identity must be added, otherwise the addition will fail)

Or through the DBMS graphical interface to add, click the following figure small key, according to the prompts step-by-step:









Method Two: Simple and rough. Through the DBMS's own Query Analyzer, new query directly delete it, fast and concise. As follows:

A successful deletion will prompt several rows to be affected.

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.