SQL: updated or deleted row values cannot be unique or changed.

Source: Internet
Author: User
ViewPostSQL: The updated or deleted row values cannot be used to make the row a unique row, or change multiple rows during SQL database maintenance, several lines of records are found to have obvious errors but cannot be deleted. When you execute the DELETE command, the system prompts that the row values that have been updated or deleted are either unable to make the row a unique row, or multiple rows (X rows) are changed ). Shown in: Database

View Post SQL: updated or deleted row values cannot be used to make the row a unique row or change multiple rows during SQL database maintenance, several lines of records are found to have obvious errors but cannot be deleted. When you execute the DELETE command, the system prompts that the row values that have been updated or deleted are either unable to make the row a unique row, or multiple rows (X rows) are changed ). Shown in: Database

View Post

SQL: updated or deleted row values cannot make the row unique or change multiple rows.

During SQL database maintenance, several lines of records are found to have errors but cannot be deleted in the server space, when the DELETE command is executed, the system prompts "the updated or deleted row values cannot make the row a unique row or change multiple rows (X rows )." The error message is displayed when duplicate key values or data appear in the database. The problem is that the created tables do not have keywords. The Hong Kong virtual host is configured with keywords to solve the problem.

Method 1: this problem is mostly caused by no primary key. You can add a primary key column to solve this problem.

1. Add a primary key

Alter table name

Add id int identity primary key (Note: you must add identity; otherwise, adding will fail)

2. Delete duplicate data

You can either manually or use a query statement to search for it and then delete it.

3. Delete the newly added primary key column and reset a column as the primary key in the original table.

Method 2:

Use insert into to perform some small transformations. The specific steps are as follows:

Back up the original table, export the data that meets the conditions to the new table, clear the original table, and select the data in the backup table.

Step 1: import the required data in the backup table

Insert into DataFile_backup
Select * from DataFile where year (consumedate) = Condition

Posted on

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.