Database Development

Create sequence starting with maximum id from a table

I’m trying to create a sequence in the following way: create sequence some_seq start with (select max(id) + 1 from some_table); But I’m getting the following error: ERROR: syntax error at or near “(” I’ve also tried this approach: DO $$ DECLARE min_seq_value int8 := (select max(id) + 1 from some_table); BEGIN create sequence some_seq […]