Created
July 17, 2017 15:10
-
-
Save justdoit0823/e64ff7bebb4285956fdf41ce999027e2 to your computer and use it in GitHub Desktop.
Update same row multiple times in postgresql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table if exists s_multi_update_same_row; | |
create table s_multi_update_same_row( | |
id int, | |
count int | |
); | |
insert into s_multi_update_same_row select id, 0 from generate_series(1, 1000) as id; | |
update s_multi_update_same_row A set count = count + 1 from generate_series(1, 10000) as B(id) where A.id = B.id % 1000 + 1; | |
select id, count from s_multi_update_same_row limit 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment