You could use client-specific functionality like substitution variables for this, e.g. in SQL*Plus or SQL Developer:
column v_start new_value v_start
select nvl(max(department_id), 0) + 1 as v_start from hr_departments;
create sequence q9_seq start with &v_start;
old:create sequence q9_seq start with &v_start
new:create sequence q9_seq start with 43
Sequence Q9_SEQ created.
select q9_seq.nextval from dual;
NEXTVAL
----------
43
or you could alter an existing sequence to skip numbers, or call nextval
until you reach the existing maximum (as here).
Or you could use a simple anonymous block:
declare
l_start number;
begin
select nvl(max(department_id), 0) + 1 into l_start from hr_departments;
execute immediate 'create sequence q9_seq start with ' || l_start;
end;
/
PL/SQL procedure successfully completed.
select q9_seq.nextval from dual;
NEXTVAL
----------
43
The dynamic SQL statement is generated the same as with the substitution variable approach, as create sequence q9_seq start with 43
.
(Both of these assume your table's highest current value is 42...)