I have table in Postgres
create table foo(bar int);
I know I can insert sequential data like this
insert into public.foo (select i from generate_series(1, 10) as i);
Now I want to update rows
update public.foo set bar = sq.t from (select t from generate_series(100, 10000) as t) as sq;
but this will update column to all the same values.
I know I need to use where
somehow, but how can I use it without primary keys from both sides?
EDIT:
I will add more real life detail. I have complex table with around 20 columns. Around 40k rows. I am interested in two columns here, pk
(or id, integer, with id_seq) and created_date
.
I populated this table with duplicating initial 10 rows, so created_date
are repeating (like 123123123
). I want to pick big range of dates from generate_series
with 1 min interval and put them in created_date
column to have sequential data there. And ideally regenerate ids from 1. How can I do it?