2013年9月10日星期二

Increment primary key field value exchange problem

Non-primary key fields , such as the case of this post said http://bbs.csdn.net/topics/390528495

However, the values ​​need to be exchanged is the primary key in case you can not like this post said that there would be similar to those methods such errors
ERROR 1062 (23000): Duplicate entry '2 'for key' PRIMARY '

So how to solve it ? Use the search engine to see such a post resolve the above error http://www.softwareprojects.com/resources/programming/t-how-to-fix-mysql-duplicate-entry-for-key-primary-o- 1844.html

but could not solve my problem you do not know what a good big cow exchange solutions and the primary key for the primary key value increment
------ Solution - ------------------------------------------
this is no way
------ Solution ------------------------------------------ -
first a = 1, a = 2 check out into a temporary table inside, let a = 1,2 plus a very large number , to ensure a unique value . . Data in the temporary table and then update to the row you want to put . . .
------ Solution ---------------------------------------- 1,2 ----
a field is the primary key , the database automatically generated and can not be changed , but added 1,2 b field can be exchanged
------ For reference only - -------------------------------------
assuming there is such a table

a primary key field, then how to exchange a field value of 1 and 2 without affecting the b field
------ For reference only ------------- --------------------------
ah understand

没有评论:

发表评论