开发者

postgresql is incrementing an update by 2?

开发者 https://www.devze.com 2023-01-03 08:31 出处:网络
I\'m migrating our model to postgresql for the FTS and data integrity update myschema.counters set counter_count= (counter_count+1) where counter_id =?

I'm migrating our model to postgresql for the FTS and data integrity

update myschema.counters set counter_count= (counter_count+1) where counter_id =?

Work开发者_如何学运维s as expected in mysql, however in postgres it is incrementing by 2 each time? It is simple int field I believe, I don't have anything special going on.


You should use a sequence to populate the value.

CREATE SEQUENCE counter_seq START 1;

UPDATE myschema.counters 
   SET counter_count = NEXTVAL('counter_seq')
 WHERE counter_id = ?
0

精彩评论

暂无评论...
验证码 换一张
取 消