I need to get following SQL script syntax right. In postgres, you can't really chain "alter sequence" with "select max(id)". So what's the right way to write script in a way that PostgreSQL accepts it?
Here is the script so you can have an idea what I need:
alter SEQUENCE notification_settings_seq START with (select max(id) from game_user)
This restarts your sequence with new value:
do $$
declare maxid int;
begin
select max(id) from game_user into maxid;
execute 'alter SEQUENCE seq_name RESTART with '|| maxid;
end;
$$ language plpgsql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With