on-duplicate-key

Prevent InnoDB auto increment ON DUPLICATE KEY

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 16:45:46
I am currently having problems with a primary key ID which is set to auto increment . It keeps incrementing ON DUPLICATE KEY . For Example: ID | field1 | field2 1 | user | value 5 | secondUser | value 86 | thirdUser | value From the description above, you'll notice that I have 3 inputs in that table but due to auto increment on each update, ID has 86 for the third input. Is there anyway to avoid this ? Here's what my mySQL query looks like: INSERT INTO table ( field1, field2 ) VALUES (:value1, :value2) ON DUPLICATE KEY UPDATE field1 = :value1, field2 = :value2 And here's what my table looks

Too many auto increments with ON DUPLICATE KEY UPDATE

不羁岁月 提交于 2019-11-26 13:55:55
问题 I have a basic table with columns: id (primary with AI) name (unique) etc If the unique column doesn't exist, INSERT the row, otherwise UPDATE the row.... INSERT INTO pages (name, etc) VALUES 'bob', 'randomness' ON DUPLICATE KEY UPDATE name = VALUES(name), etc = VALUES(etc) The problem is that if it performs an UPDATE, the auto_increment value on the id column goes up. So if a whole bunch of UPDATES are performed, the id auto_increment goes through the roof. Apparently it was a bug: http:/

Prevent InnoDB auto increment ON DUPLICATE KEY

久未见 提交于 2019-11-26 04:55:48
问题 I am currently having problems with a primary key ID which is set to auto increment . It keeps incrementing ON DUPLICATE KEY . For Example: ID | field1 | field2 1 | user | value 5 | secondUser | value 86 | thirdUser | value From the description above, you\'ll notice that I have 3 inputs in that table but due to auto increment on each update, ID has 86 for the third input. Is there anyway to avoid this ? Here\'s what my mySQL query looks like: INSERT INTO table ( field1, field2 ) VALUES (

MySQL LOAD DATA INFILE with ON DUPLICATE KEY UPDATE

时间秒杀一切 提交于 2019-11-26 01:53:29
问题 For loading huge amounts of data into MySQL, LOAD DATA INFILE is by far the fastest option. Unfortunately, while this can be used in a way INSERT IGNORE or REPLACE works, ON DUPLICATE KEY UPDATE is not currently supported. However, ON DUPLICATE KEY UPDATE has advantages over REPLACE . The latter does a delete and an insert when a duplicate exists. This brings overhead for key management. Also, autoincrement ids will not stay the same on a replace. How can ON DUPLICATE KEY UPDATE be emulated

On Duplicate Key Update same as insert

Deadly 提交于 2019-11-26 01:44:52
问题 I\'ve searched around but didn\'t find if it\'s possible. I\'ve this MySQL query: INSERT INTO table (id,a,b,c,d,e,f,g) VALUES (1,2,3,4,5,6,7,8) Field id has a \"unique index\", so there can\'t be two of them. Now if the same id is already present in the database, I\'d like to update it. But do I really have to specify all these field again, like: INSERT INTO table (id,a,b,c,d,e,f,g) VALUES (1,2,3,4,5,6,7,8) ON DUPLICATE KEY UPDATE a=2,b=3,c=4,d=5,e=6,f=7,g=8 Or: INSERT INTO table (id,a,b,c,d

On Duplicate Key Update same as insert

梦想与她 提交于 2019-11-26 01:07:03
I've searched around but didn't find if it's possible. I've this MySQL query: INSERT INTO table (id,a,b,c,d,e,f,g) VALUES (1,2,3,4,5,6,7,8) Field id has a "unique index", so there can't be two of them. Now if the same id is already present in the database, I'd like to update it. But do I really have to specify all these field again, like: INSERT INTO table (id,a,b,c,d,e,f,g) VALUES (1,2,3,4,5,6,7,8) ON DUPLICATE KEY UPDATE a=2,b=3,c=4,d=5,e=6,f=7,g=8 Or: INSERT INTO table (id,a,b,c,d,e,f,g) VALUES (1,2,3,4,5,6,7,8) ON DUPLICATE KEY UPDATE a=VALUES(a),b=VALUES(b),c=VALUES(c),d=VALUES(d),e